Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

142 Files and Directories Chapter 4


4.15 Examine the archive formats used by the cpio( 1 ) and tar( 1 ) commands. (These
descriptions areusually found in Section 5 of theUNIX Programmer ’sManual.) How many
of the three possible time values aresaved for each file? When a file is restored, what value
do you think the access time is set to, and why?
4.16 Does the UNIX System have a fundamental limitation on the depth of a directory tree? To
find out, write a program that creates a directory and then changes to that directory, in a
loop. Make certain that the length of the absolute pathname of the leaf of this directory is
greater than your system’sPATH_MAXlimit. Can you callgetcwdto fetch the directory’s
pathname? How do the standardUNIX System tools deal with this long pathname? Can
you archive the directory using eithertarorcpio?
4.17 In Section 3.16, we described the/dev/fdfeature. For any user to be able to access these
files, their permissions must berw-rw-rw-.Some programs that create an output file
delete the file first, in case it already exists, ignoring the return code:
unlink(path);
if ((fd = creat(path, FILE_MODE)) < 0)
err_sys(...);
What happens ifpathis/dev/fd/1?
Free download pdf