|
|
4.17.
|
|
[View full width] #include <unistd.h> int symlink(const char * actualpath , const char |
|
Returns: 0 if OK, 1 on error |
A new directory entry, sympath , is created that points to actualpath . It is not required that actualpath exist when the symbolic link is created. (We saw this in the example at the end of the previous section.) Also, actualpath and sympath need not reside in the same file system.
Because the
|
[View full width] #include <unistd.h> ssize_t readlink(const char* restrict pathname , |
|
Returns: number of bytes read if OK, 1 on error |
This function combines the actions of
open
,
read
, and
close
. If the function is successful, it returns the number of bytes placed into
buf
. The contents of the symbolic link that are returned in
buf
are not null
|
|
|
|
4.18. File Times
Three time fields are
Figure 4.19. The three time values associated with each file
Note the difference between the modification time (
st_mtime
) and the changed-status time (
st_ctime
). The modification time is when the contents of the file were last modified. The changed-status time is when the i-node of the file was last modified. In this chapter, we've described many operations that affect the i-node without changing the actual contents of the file: changing the file access permissions, changing the
Note that the system does not maintain the last-access time for an i-node. This is why the functions access and stat , for example, don't change any of the three times.
The access time is often used by system administrators to delete files that have not been accessed for a certain amount of time. The classic example is the removal of files named
a.out
or
The modification time and the changed-status time can be used to archive only those files that have had their contents modified or their i-node modified. The ls command displays or sorts only on one of the three time values. By default, when invoked with either the -l or the -t option, it uses the modification time of a file. The -u option causes it to use the access time, and the -c option causes it to use the changed-status time.
Figure 4.20 summarizes the effects of the various functions that we've described on these three times. Recall from Section 4.14 that a directory is simply a file containing directory entries: filenames and associated i-node
Figure 4.20. Effect of various functions on the access, modification, and changed-status times
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|