[cs615asa] hw5 Question

Jan Schaumann jschauma at stevens.edu
Wed Apr 3 23:42:00 EDT 2019


Justin Barish <jbarish at stevens.edu> wrote:

> Since we should check the return code of all functions for failure, how
> should this be handled, since the above causes a return code of 1, as does
> other possible failures? Would a correct answer be to just ignore the
> return value of du, and do checks (such as the existence of the directory)
> separately?

Consider what the user would want and most likely expect.  If I'm trying
to backup a directory, but don't have permissions to access some
subdirectories deep within the hierarchy, would I want:

- the backup to abort, saying that it can't read all the files?

- the backup to continue as best as it can, but let me know that some
  directories could not be backed up?

- to silently ignore the error and thus give me the impression that all
  data was backed up?

I think the third option is not acceptable, but for the first two an
argument can be made either way.  Your choice here then dictates how you
want to handle the other special cases, although I suspect some initial
sanity checking on the arguments given prior to invoking du(1) would
likely make sense.

> Also, should we have du count filesystem mount points, or ignore them (-x
> flag)?

By convention, Unix tools require a flag to be instructed not to cross
mountpoints, so the default is to be mount point agnostic.  Your tool
should follow that convention.  (A future iteration could conceivably
add an option to not traverse mount points, but we don't need that here,
I think.)

-Jan


More information about the cs615asa mailing list