New stat structure.
* VFS and installed MFSes must be in sync before and after this change * Use struct stat from NetBSD. It requires adding new STAT, FSTAT and LSTAT syscalls. Libc modification is both backward and forward compatible. Also new struct stat uses modern field sizes to avoid ABI incompatibility, when we update uid_t, gid_t and company. Exceptions are ino_t and off_t in old libc (though paddings added).
This commit is contained in:
@@ -7,7 +7,7 @@ MAN= accept.2 access.2 alarm.2 bind.2 brk.2 chdir.2 chmod.2 chown.2 \
|
||||
read.2 readlink.2 reboot.2 recv.2 recvfrom.2 recvmsg.2 rename.2 \
|
||||
rmdir.2 select.2 send.2 sendmsg.2 sendto.2 setsid.2 \
|
||||
setsockopt.2 setuid.2 shutdown.2 sigaction.2 sigpending.2 \
|
||||
sigprocmask.2 sigsuspend.2 socket.2 socketpair.2 stat.2 \
|
||||
sigprocmask.2 sigsuspend.2 socket.2 socketpair.2 \
|
||||
statvfs.2 svrctl.2 symlink.2 sync.2 time.2 times.2 truncate.2 \
|
||||
umask.2 uname.2 unlink.2 utime.2 wait.2 write.2
|
||||
|
||||
|
||||
179
man/man2/stat.2
179
man/man2/stat.2
@@ -1,179 +0,0 @@
|
||||
.\" Copyright (c) 1980 Regents of the University of California.
|
||||
.\" All rights reserved. The Berkeley software License Agreement
|
||||
.\" specifies the terms and conditions for redistribution.
|
||||
.\"
|
||||
.\" @(#)stat.2 6.5 (Berkeley) 5/12/86
|
||||
.\"
|
||||
.TH STAT 2 "May 12, 1986"
|
||||
.UC 4
|
||||
.SH NAME
|
||||
stat, lstat, fstat \- get file status
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.ft B
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
.ta +54n
|
||||
int stat(const char *\fIpath\fP, struct stat *\fIbuf\fP)
|
||||
int lstat(const char *\fIpath\fP, struct stat *\fIbuf\fP)
|
||||
int fstat(int \fIfd\fP, struct stat *\fIbuf\fP)
|
||||
.fi
|
||||
.ft R
|
||||
.SH DESCRIPTION
|
||||
.B Stat
|
||||
obtains information about the file
|
||||
.IR path .
|
||||
Read, write or execute
|
||||
permission of the named file is not required, but all directories
|
||||
listed in the path name leading to the file must be reachable.
|
||||
.PP
|
||||
.B Lstat
|
||||
is like \fBstat\fP except in the case where the named file is a symbolic link,
|
||||
in which case
|
||||
.B lstat
|
||||
returns information about the link,
|
||||
while
|
||||
.B stat
|
||||
returns information about the file the link references.
|
||||
.PP
|
||||
.B Fstat
|
||||
obtains the same information about an open file
|
||||
referenced by the argument descriptor, such as would
|
||||
be obtained by an \fBopen\fP call. Pipe descriptors
|
||||
look like named pipes with a link count of zero. The
|
||||
st_size field of pipes or named pipes shows the amount of
|
||||
bytes currently buffered in the pipe.
|
||||
.PP
|
||||
.I Buf
|
||||
is a pointer to a
|
||||
.B stat
|
||||
structure into which information is placed concerning the file.
|
||||
The contents of the structure pointed to by
|
||||
.I buf
|
||||
is as follows:
|
||||
.PP
|
||||
.if t .RS
|
||||
.nf
|
||||
.ta +0.4i +0.8i +1i
|
||||
struct stat {
|
||||
dev_t st_dev; /* device inode resides on */
|
||||
ino_t st_ino; /* this inode's number */
|
||||
mode_t st_mode; /* file mode, protection bits, etc. */
|
||||
nlink_t st_nlink; /* number or hard links to the file */
|
||||
uid_t st_uid; /* user-id of the file's owner */
|
||||
gid_t st_gid; /* group-id of the file's owner */
|
||||
dev_t st_rdev; /* the device type, for inode that is device */
|
||||
off_t st_size; /* total size of file */
|
||||
time_t st_atime; /* time of last access */
|
||||
time_t st_mtime; /* time of last data modification */
|
||||
time_t st_ctime; /* time of last file status change */
|
||||
};
|
||||
.fi
|
||||
.if t .RE
|
||||
.DT
|
||||
.PP
|
||||
.TP 12
|
||||
st_atime
|
||||
Time when file data was last read or modified. Changed by the following system
|
||||
calls:
|
||||
.BR mknod (2),
|
||||
.BR utime (2),
|
||||
.BR read (2),
|
||||
and
|
||||
.BR write (2).
|
||||
For reasons of efficiency,
|
||||
st_atime is not set when a directory
|
||||
is searched, although this would be more logical.
|
||||
.TP 12
|
||||
st_mtime
|
||||
Time when data was last modified.
|
||||
It is not set by changes of owner, group, link count, or mode.
|
||||
Changed by the following system calls:
|
||||
.BR mknod (2),
|
||||
.BR utime (2),
|
||||
.BR write (2).
|
||||
.TP 12
|
||||
st_ctime
|
||||
Time when file status was last changed.
|
||||
It is set both both by writing and changing the i-node.
|
||||
Changed by the following system calls:
|
||||
.BR chmod (2)
|
||||
.BR chown (2),
|
||||
.BR link (2),
|
||||
.BR mknod (2),
|
||||
.BR rename (2),
|
||||
.BR unlink (2),
|
||||
.BR utime (2),
|
||||
.BR write (2).
|
||||
.PP
|
||||
The file type information in \fBst_mode\fP has bits:
|
||||
.PP
|
||||
.nf
|
||||
.in +5n
|
||||
.ta 1.6i 2.5i 3i
|
||||
#define S_IFMT 0170000 /* type of file */
|
||||
#define\ \ \ \ S_IFIFO 0010000 /* named pipe */
|
||||
#define\ \ \ \ S_IFCHR 0020000 /* character special */
|
||||
#define\ \ \ \ S_IFDIR 0040000 /* directory */
|
||||
#define\ \ \ \ S_IFBLK 0060000 /* block special */
|
||||
#define\ \ \ \ S_IFREG 0100000 /* regular */
|
||||
#define\ \ \ \ S_IFLNK 0120000 /* symbolic link */
|
||||
.fi
|
||||
.in -5n
|
||||
.PP
|
||||
The mode bits 0007777 encode set-uid/gid bits and
|
||||
permission bits (see
|
||||
.BR chmod (2)).
|
||||
.SH "RETURN VALUE
|
||||
Upon successful completion a value of 0 is returned.
|
||||
Otherwise, a value of \-1 is returned and
|
||||
.B errno
|
||||
is set to indicate the error.
|
||||
.SH "ERRORS
|
||||
.B Stat
|
||||
and
|
||||
.B lstat
|
||||
will fail if one or more of the following are true:
|
||||
.TP 15
|
||||
[ENOTDIR]
|
||||
A component of the path prefix is not a directory.
|
||||
.TP 15
|
||||
[ENAMETOOLONG]
|
||||
The path name exceeds PATH_MAX characters.
|
||||
.TP 15
|
||||
[ENOENT]
|
||||
The named file does not exist.
|
||||
.TP 15
|
||||
[EACCES]
|
||||
Search permission is denied for a component of the path prefix.
|
||||
.TP 15
|
||||
[ELOOP]
|
||||
Too many symbolic links were encountered in translating the pathname.
|
||||
.TP 15
|
||||
[EFAULT]
|
||||
.I Buf
|
||||
or
|
||||
.I name
|
||||
points to an invalid address.
|
||||
.TP 15
|
||||
[EIO]
|
||||
An I/O error occurred while reading from or writing to the file system.
|
||||
.PP
|
||||
.B Fstat
|
||||
will fail if one or both of the following are true:
|
||||
.TP 15
|
||||
[EBADF]
|
||||
.I Fildes
|
||||
is not a valid open file descriptor.
|
||||
.TP 15
|
||||
[EFAULT]
|
||||
.I Buf
|
||||
points to an invalid address.
|
||||
.TP 15
|
||||
[EIO]
|
||||
An I/O error occurred while reading from or writing to the file system.
|
||||
.SH "SEE ALSO"
|
||||
.BR chmod (2),
|
||||
.BR chown (2),
|
||||
.BR utime (2).
|
||||
Reference in New Issue
Block a user