[cs631apue] HW5 questions
jschauma at stevens.edu
Thu Dec 8 13:20:11 EST 2011
Rob Hoffmann <rhoffman at stevens.edu> wrote:
> I am struggling with this issue as well. When I run "gcc -Wall cmp.c
> ls.c main.c print.c util.c -o ls" there are a /lot/ of errors shown.
Go through them one by one and figure out what they mean and what code
they relate to.
> I understand that Linux has functionally equivalent functions for
> some things, but many of these errors have to do with undefined
> constants (HN_AUTOSCALE, HN_NOSPACE), missing header files (util.h,
Think about what these constants define. If they are not currently
defined on this platform, how would you define them? Knowing that they
must be defined in a header file on NetBSD, you can track down and find
their definition (hint: check out src/include via cvs and look at the
> and missing data structure members (no st_mtimensec in
> struct stat).
If one platform does not have these data structure members, which ones
would you use to get the same (or the closest) result?
> I don't know if all this was the intent of the assignment, but at what
> point do we draw the line between trying to fix everything and simply
> removing code that is not defined?
The intention is for you to learn how to read code, understand what it
does and, if necessary, make changes. If those changes involve removing
some things, then that's fine; if it involves adding things, that's
fine; if it involves re-arranging things, that's fine, too.
In total, most of the problems come down to
- unknown definition of __RCSID, __COPYRIGHT
- What might these do? Where might they be defined?
(Recall that upper-case usually indicates a macro, which would have
to be defined in a header...)
If you can't identify a definition or replacement, can you delete
them (ie would functionality be lost)? Can you conditionally not
- struct member not found in struct stat
- as noted above; for 'whiteout' files we already discussed this prior
to the midterm
- headers not found: util.h, tzfile.h
- are they needed? What for? Can you just... not use them?
- unknown functions setprogname, getbsize, user_from_uid,
group_from_gid, flags_to_string, humanize_number
- we already discussed 'setprogname' earlier in the semester
- you can find the definition of what 'getbsize' might do online and
you can figure out how to replace it easily by looking at where it's
used and how your ls implementation did this
- likewise for *_from_*
- flags_to_string only make sense if your system supports file
- unknown definitions of HN_ and related macros
- see above
Use your internet search skills to figure out the rest.
More information about the cs631apue