- , .
FILE
fiIe, , ,
file , :
− ;
− vnode;
− ;
− ;
− , , ( );
− file, ' .
(, ) , .
' . ' . . ' :
1.
, . , file.
: . , .
0..N. N include- <sys/param.h>.
[ N, sysconf _SC_OPEN_MAX, , :
printf(_SC_OPEN_MAX = %ld\n, sysconf(_SC_OPEN_MAX));
Linux 2.4 1024, FREEBSD 957, Solaris 256.]
. - ' ( ). : () ' . . , "'" ( ); ² /. , .
. ' file.
' , , ' .
. ֳ "stdio.h".
|
|
FILE * stdin , .
FILE * stdout , .
FILE * stderr , , .
.
0 STDIN_FILENO
1 STDOUT_FILENO
2 STDERR_FILENO
' , .
2.
. , , - stat, lstat fstat - ls.
stat '
include <sys/stat.h>
int stat(const char *path, struct stat *buf)
path - '
struct stat *buf - ,
0 , -1 ( - errno)
lstat '
include <sys/stat.h>
int lstat(const char*path, struct stat *buf);
path - '
struct stat *buf -
0 , -1 ( - errno) */
fstat
#include <sys/stat.h>
int fstat(const int fd, struct stat *buf);
fd -
struct stat *buf -
0 , -1 ( - errno)
stat ' . fstat . lstat stat - ' , , ', *. , stat, .
stat. , ,
struct stat stat, fstat lstat
struct stat {
dev_t st_dev;
ino_t st_ino;
mode_t st_mode; ,
nlink_t st_nlink; -
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev; (
)
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
blksize_t st_blksize; (
-)
blkcnt_t st_blocks; - 512
|
|
}
( dev_t) - , , NFS-. , st_dev st_ino - .- . , - .
st.dev - , . st_rdev , .
st_size . , - ( - ). ' ' - '. - .
st_blksize . , , , .
, - , st_blocks * 512 st_size.
fstat , , , , . ' st_mode, st_ino, st_dev, st_uid, st_gid, st_atime, st_ctime st_mtime , - . , st_size, , .
st_ctime (st_ctime) . ( ) creat, chmod, chown, link, unlink, mknod, utime*, write ( ); . ;
st_mtime - write, creat, mknod, utime; ();
st_atime - read, creat, mknod, utime; ().