1FSTAT(3P)                  POSIX Programmer's Manual                 FSTAT(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       fstat - get file status
13

SYNOPSIS

15       #include <sys/stat.h>
16
17       int fstat(int fildes, struct stat *buf);
18
19

DESCRIPTION

21       The fstat() function shall obtain information about an open file  asso‐
22       ciated  with the file descriptor fildes, and shall write it to the area
23       pointed to by buf.
24
25       If fildes references a shared memory object, the  implementation  shall
26       update  in  the  stat structure pointed to by the buf argument only the
27       st_uid, st_gid, st_size, and st_mode  fields,  and  only  the  S_IRUSR,
28       S_IWUSR,  S_IRGRP,  S_IWGRP,  S_IROTH, and S_IWOTH file permission bits
29       need be valid. The implementation may update other fields and flags.
30
31       If fildes references a typed memory object,  the  implementation  shall
32       update  in  the  stat structure pointed to by the buf argument only the
33       st_uid, st_gid, st_size, and st_mode  fields,  and  only  the  S_IRUSR,
34       S_IWUSR,  S_IRGRP,  S_IWGRP,  S_IROTH, and S_IWOTH file permission bits
35       need be valid. The implementation may update other fields and flags.
36
37       The buf argument is a pointer  to  a  stat  structure,  as  defined  in
38       <sys/stat.h>, into which information is placed concerning the file.
39
40       The   structure   members  st_mode,  st_ino,  st_dev,  st_uid,  st_gid,
41       st_atime, st_ctime, and st_mtime shall have meaningful values  for  all
42       other  file  types  defined in this volume of IEEE Std 1003.1-2001. The
43       value of the member st_nlink shall be set to the number of links to the
44       file.
45
46       An  implementation  that provides additional or alternative file access
47       control mechanisms may, under implementation-defined conditions,  cause
48       fstat() to fail.
49
50       The  fstat() function shall update any time-related fields as described
51       in the Base Definitions volume of  IEEE Std 1003.1-2001,  Section  4.7,
52       File Times Update, before writing into the stat structure.
53

RETURN VALUE

55       Upon successful completion, 0 shall be returned. Otherwise, -1 shall be
56       returned and errno set to indicate the error.
57

ERRORS

59       The fstat() function shall fail if:
60
61       EBADF  The fildes argument is not a valid file descriptor.
62
63       EIO    An I/O error occurred while reading from the file system.
64
65       EOVERFLOW
66              The file size in bytes or the number of blocks allocated to  the
67              file  or  the file serial number cannot be represented correctly
68              in the structure pointed to by buf.
69
70
71       The fstat() function may fail if:
72
73       EOVERFLOW
74              One of the values is too  large  to  store  into  the  structure
75              pointed to by the buf argument.
76
77
78       The following sections are informative.
79

EXAMPLES

81   Obtaining File Status Information
82       The following example shows how to obtain file status information for a
83       file named /home/cnd/mod1. The structure variable buffer is defined for
84       the  stat  structure. The /home/cnd/mod1 file is opened with read/write
85       privileges and is passed to the open file descriptor fildes.
86
87
88              #include <sys/types.h>
89              #include <sys/stat.h>
90              #include <fcntl.h>
91
92
93              struct stat buffer;
94              int         status;
95              ...
96              fildes = open("/home/cnd/mod1", O_RDWR);
97              status = fstat(fildes, &buffer);
98

APPLICATION USAGE

100       None.
101

RATIONALE

103       None.
104

FUTURE DIRECTIONS

106       None.
107

SEE ALSO

109       lstat(), stat(), the Base Definitions volume  of  IEEE Std 1003.1-2001,
110       <sys/stat.h>, <sys/types.h>
111
113       Portions  of  this text are reprinted and reproduced in electronic form
114       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
115       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
116       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
117       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
118       event of any discrepancy between this version and the original IEEE and
119       The  Open Group Standard, the original IEEE and The Open Group Standard
120       is the referee document. The original Standard can be  obtained  online
121       at http://www.opengroup.org/unix/online.html .
122
123
124
125IEEE/The Open Group                  2003                            FSTAT(3P)
Impressum