CT320 HW7: Size matters
For this assignment, you will write a program called
enforces limits on disk space. OK, it doesn’t enforce them—it just
complains when the limits are violated.
bigness takes, as arguments, at least one limit file, as
- First line will be one of:
- an absolute path starting with
- an absolute path starting with
- a username, indicating to check that user’s home directory.
- Subsequent lines will be one of, in no particular order
(at least one needs to be present):
(indicating a minimum total size, in bytes, of all plain files)
(indicating a maximum total size, in bytes, of all plain files)
(indicating a minimum number of plain files)
(indicating a maximum number of plain files)
- A value will be one of these appallingly non-standard forms,
where either upper or lower case is acceptable.
|integer||1||just the number|
- For example,
n<3My means that the number of plain files must
be less than thirty thousand.
t>23mi means that the total size of all plain files
must be greater than twenty-three million.
- Empty lines in the limit file are ignored.
- Comment lines beginning with
# in the first column are ignored.
bigness will check to see if any of the requirements are violated.
Each requirement that is violated must produce a message to
that is exactly of one of these forms:
: too many files, should be fewer than value
: too few files, should be more than value
: too much space, should be less than value
: too little space, should be more than value
I’m serious about “exactly”. Change the italic words, but nothing
else. Spelling counts. Upper-/lower-case counts. Spaces count.
Here is a sample run, where “%” is my shell prompt:
% cat constraints
# We’re interested in the home directory of this user:
# On our systems, the home directory of user “games” is /usr/games,
# which is empty.
# I expect this to pass:
# I expect both of these to fail:
% ./bigness constraints
/usr/games: too few files, should be more than 4
/usr/games: too few files, should be more than 100bi
% ./bigness bogusfile
./bigness: no such file “bogusfile”
If you encounter “STACK FRAME LINK OVERFLOW”, then try this:
- Comment & empty lines may be anywhere in the limit file,
even before the “first” line.
- No matter what style the first line of the limit file takes, the
message for exceeding a limit must start with an absolute directory.
- The message for exceeding a limit must include the size in its
original form with its original case, e.g.,
- File sizes and total sizes may be up to one trillion bytes.
- Produce multiple messages if multiple constraints are violated.
- Produce an error message to
containing the real program name, and terminate, if:
- no arguments are given
- non-existent user in a limit file
- bad directory in a limit file
- a limit file is bad in any other way, including being
syntactically incorrect, not existing, being unreadable, etc.
- A “plain file” is a plain old data file. It is not a:
- symbolic link
- named pipe
- Ignore all non-plain files, including symbolic links.
- The number & total refer to all plain files in the directory
hierarcy, including files in subdirectories, sub-sub-directories, etc.
- You may not use any existing limit program, such as
quot. In general, you may not use any program that solves
the majority of the assignment for you.
- You may use the
Implementation & Testing
You may write your program in any language that we have on the CS Dept.
computers in CSB 120. For example, awk, bash, c, c++, csh, fortran, go,
julia, lisp, lua, perl, php, python2, python3, and ruby are all
We will test your program like this:
- If a
Makefile was turned in:
chmod u+x bigness
./bigness quotafile1 quotafile2 …
Use web checkin, or:
~ct320/bin/checkin HW7 bigness
~ct320/bin/checkin HW7 Makefile bigness.c
or whatever other files your solution uses.
Turn in your script or source code, not the output of a compiler.
How to receive negative points:
Turn in someone else’s work.