diff options
| author | cgd <cgd@NetBSD.org> | 1995-02-27 12:31:34 +0000 |
|---|---|---|
| committer | cgd <cgd@NetBSD.org> | 1995-02-27 12:31:34 +0000 |
| commit | 4eab61bd40c07b2fc612ad50cface2b77fc110d0 (patch) | |
| tree | 7118747f1d9919499fdea5d7c6908c5cfe04e5a8 /lib/libc/sys/stat.2 | |
| parent | c67e54a2e2b9f3d455a30d68ea4e09e56d7b9136 (diff) | |
merge with lite, keeping most local changes. clean up Ids
Diffstat (limited to 'lib/libc/sys/stat.2')
| -rw-r--r-- | lib/libc/sys/stat.2 | 108 |
1 files changed, 69 insertions, 39 deletions
diff --git a/lib/libc/sys/stat.2 b/lib/libc/sys/stat.2 index 58169e278be..0dcebd4c2df 100644 --- a/lib/libc/sys/stat.2 +++ b/lib/libc/sys/stat.2 @@ -1,5 +1,7 @@ -.\" Copyright (c) 1980, 1991 Regents of the University of California. -.\" All rights reserved. +.\" $NetBSD: stat.2,v 1.8 1995/02/27 12:38:08 cgd Exp $ +.\" +.\" Copyright (c) 1980, 1991, 1993, 1994 +.\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -29,10 +31,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" from: @(#)stat.2 6.9 (Berkeley) 3/10/91 -.\" $Id: stat.2,v 1.7 1994/04/22 00:13:48 jtc Exp $ +.\" @(#)stat.2 8.3 (Berkeley) 4/19/94 .\" -.Dd March 10, 1991 +.Dd April 19, 1994 .Dt STAT 2 .Os BSD 4 .Sh NAME @@ -44,11 +45,11 @@ .Fd #include <sys/types.h> .Fd #include <sys/stat.h> .Ft int -.Fn stat "const char *path" "struct stat *buf" +.Fn stat "const char *path" "struct stat *sb" .Ft int -.Fn lstat "const char *path" "struct stat *buf" +.Fn lstat "const char *path" "struct stat *sb" .Ft int -.Fn fstat "int fd" "struct stat *buf" +.Fn fstat "int fd" "struct stat *sb" .Sh DESCRIPTION The .Fn stat @@ -68,19 +69,24 @@ returns information about the link, while .Fn stat returns information about the file the link references. +Unlike other filesystem objects, +symbolic links do not have an owner, group, access mode, times, etc. +Instead, these attributes are taken from the directory that +contains the link. +The only attributes returned from an +.Fn lstat +that refer to the symbolic link itself are the file type (S_IFLNK), +size, blocks, and link count (always 1). .Pp The .Fn fstat obtains the same information about an open file known by the file descriptor -.Fa fd , -such as would -be obtained by an -.Xr open -call. +.Fa fd . .Pp -.Fa Buf -is a pointer to a +The +.Fa sb +argument is a pointer to a .Fn stat structure as defined by @@ -96,15 +102,12 @@ struct stat { uid_t st_uid; /* user-id of owner */ gid_t st_gid; /* group-id of owner */ dev_t st_rdev; /* device type, for special file inode */ + struct timespec st_atimespec; /* time of last access */ + struct timespec st_mtimespec; /* time of last data modification */ + struct timespec st_ctimespec; /* time of last file status change */ off_t st_size; /* file size, in bytes */ - time_t st_atime; /* time of last access */ - long st_spare1; - time_t st_mtime; /* time of last data modification */ - long st_spare2; - time_t st_ctime; /* time of last file status change */ - long st_spare3; - long st_blksize;/* optimal file sys I/O ops blocksize */ - long st_blocks; /* blocks allocated for file */ + quad_t st_blocks; /* blocks allocated for file */ + u_long st_blksize;/* optimal file sys I/O ops blocksize */ u_long st_flags; /* user defined flags for file */ u_long st_gen; /* file generation number */ }; @@ -113,38 +116,53 @@ struct stat { The time-related fields of .Fa struct stat are as follows: -.Bl -tag -width st_blocks +.Bl -tag -width XXXst_mtime .It st_atime -Time when file data last accessed. Changed by the following system -calls: +Time when file data last accessed. +Changed by the .Xr mknod 2 , -.Xr utimes 2 , +.Xr utimes 2 and -.Xr read 2 . +.Xr read 2 +system calls. .It st_mtime Time when file data last modified. -Changed by the following system calls: +Changed by the .Xr mknod 2 , -.Xr utimes 2 , -.Xr write 2 . +.Xr utimes 2 +and +.Xr write 2 +system calls. .It st_ctime Time when file status was last changed (inode data modification). -Changed by the following system calls: -.Xr chmod 2 +Changed by the +.Xr chmod 2 , .Xr chown 2 , .Xr link 2 , .Xr mknod 2 , .Xr rename 2 , .Xr unlink 2 , -.Xr utimes 2 , -.Xr write 2 . +.Xr utimes 2 +and +.Xr write 2 +system calls. +.El +.Pp +The size-related fields of the +.Fa struct stat +are as follows: +.Bl -tag -width XXXst_blksize +.It st_blksize +The optimal I/O block size for the file. .It st_blocks The actual number of blocks allocated for the file in 512-byte units. +As short symbolic links are stored in the inode, this number may +be zero. .El .Pp The status information word .Fa st_mode -has bits: +has the following bits: .Bd -literal #define S_IFMT 0170000 /* type of file */ #define S_IFIFO 0010000 /* named pipe (fifo) */ @@ -172,6 +190,17 @@ Upon successful completion a value of 0 is returned. Otherwise, a value of -1 is returned and .Va errno is set to indicate the error. +.Sh COMPATIBILITY +Previous versions of the system used different types for the +.Li st_dev , +.Li st_uid , +.Li st_gid , +.Li st_rdev , +.Li st_size , +.Li st_blksize +and +.Li st_blocks +fields. .Sh ERRORS .Fn Stat and @@ -193,7 +222,7 @@ Search permission is denied for a component of the path prefix. .It Bq Er ELOOP Too many symbolic links were encountered in translating the pathname. .It Bq Er EFAULT -.Fa Buf +.Fa Sb or .Em name points to an invalid address. @@ -208,13 +237,13 @@ will fail if: .Fa fd is not a valid open file descriptor. .It Bq Er EFAULT -.Fa Buf +.Fa Sb points to an invalid address. .It Bq Er EIO An I/O error occurred while reading from or writing to the file system. .El .Sh CAVEAT -The fields in the stat structure currently marked +The fields in the stat structure currently marked .Fa st_spare1 , .Fa st_spare2 , and @@ -227,6 +256,7 @@ depend on the time stamps being contiguous (in calls to .Xr chmod 2 , .Xr chown 2 , .Xr utimes 2 +.Xr symlink 7 .Sh BUGS Applying .Xr fstat |
