CT320 HW7: Size matters
Description
For this assignment, you will write a program called bigness
that
enforces limits on disk space. OK, it doesn’t enforce them—it just
complains when the limits are violated.
                
Limit Files
bigness
takes, as arguments, at least one limit file, as
described below.
                
- First line will be one of:
- an absolute path starting with
/
- an absolute path starting with
~
username
- 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):
t>
value
(indicating a minimum total size, in bytes, of all plain files)
t<
value
(indicating a maximum total size, in bytes, of all plain files)
n>
value
(indicating a minimum number of plain files)
n<
value
(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.
Form | Multiplier | Explanation |
integer | 1 | just the number |
integer DZ | 12 | dozen |
integer TH | 103 | thousand |
integer MY | 104 | myriad |
integer MI | 106 | million |
integer BI | 109 | billion |
- For example,
n<3My
means that the number of plain files must
be less than thirty thousand.
- Similarly,
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.
Action
bigness
will check to see if any of the requirements are violated.
Each requirement that is violated must produce a message to
{{abbr|stdout|standard output, where the normal output goes}}
that is exactly of one of these forms:
                
- directory
: too many files, should be fewer than
value
- directory
: too few files, should be more than
value
- directory
: too much space, should be less than
value
- directory
: 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.
Punctuation counts.
                
Sample Run
Here is a sample run, where “%” is my shell prompt:
% cat constraints
# We’re interested in the home directory of this user:
games
# On our systems, the home directory of user “games” is /usr/games,
# which is empty.
# I expect this to pass:
t<10MI
# I expect both of these to fail:
n>4
n>100bi
% ./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”
Debugging
If you encounter “STACK FRAME LINK OVERFLOW”, then try this:
export STACK_FRAME_LINK_OVERRIDE=ffff-ad921d60486366258809553a3db49a4a
Requirements
- 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.,
6DZ
, not 72
- 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
{{abbr|stderr|standard error, where the unhappy output goes}},
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:
- directory
- symbolic link
- socket
- named pipe
- etc.
- 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
quota
or
quot
. In general, you may not use any program that solves
the majority of the assignment for you.
- You may use the
du
, ls
, and find
programs.
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
permitted.
                
We will test your program like this:
- If a
Makefile
was turned in: make bigness
chmod u+x bigness
./bigness
quotafile1 quotafile2 …
Submission
Use web checkin, or:
~ct320/bin/checkin HW7 bigness
or:
~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.