1FCHMOD(3P)                 POSIX Programmer's Manual                FCHMOD(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       fchmod - change mode of a file
13

SYNOPSIS

15       #include <sys/stat.h>
16
17       int fchmod(int fildes, mode_t mode);
18
19

DESCRIPTION

21       The fchmod() function shall be equivalent to chmod()  except  that  the
22       file  whose permissions are changed is specified by the file descriptor
23       fildes.
24
25       If fildes references a shared memory object, the fchmod() function need
26       only  affect  the  S_IRUSR,  S_IWUSR,  S_IRGRP,  S_IWGRP,  S_IROTH, and
27       S_IWOTH file permission bits.
28
29       If fildes references a typed memory object, the behavior of fchmod() is
30       unspecified.
31
32       If fildes refers to a socket, the behavior of fchmod() is unspecified.
33
34       If  fildes refers to a STREAM (which is fattach()-ed into the file sys‐
35       tem name space) the call returns successfully, doing nothing.
36

RETURN VALUE

38       Upon successful completion, fchmod()  shall  return  0.  Otherwise,  it
39       shall return -1 and set errno to indicate the error.
40

ERRORS

42       The fchmod() function shall fail if:
43
44       EBADF  The fildes argument is not an open file descriptor.
45
46       EPERM  The  effective  user ID does not match the owner of the file and
47              the process does not have appropriate privilege.
48
49       EROFS  The file referred to by fildes resides on a read-only file  sys‐
50              tem.
51
52
53       The fchmod() function may fail if:
54
55       EINTR  The fchmod() function was interrupted by a signal.
56
57       EINVAL The value of the mode argument is invalid.
58
59       EINVAL The fildes argument refers to a pipe and the implementation dis‐
60              allows execution of fchmod() on a pipe.
61
62
63       The following sections are informative.
64

EXAMPLES

66   Changing the Current Permissions for a File
67       The following example shows how to change the permissions  for  a  file
68       named  /home/cnd/mod1  so that the owner and group have read/write/exe‐
69       cute permissions, but the world only has read/write permissions.
70
71
72              #include <sys/stat.h>
73              #include <fcntl.h>
74
75
76              mode_t mode;
77              int    fildes;
78              ...
79              fildes = open("/home/cnd/mod1", O_RDWR);
80              fchmod(fildes, S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH);
81

APPLICATION USAGE

83       None.
84

RATIONALE

86       None.
87

FUTURE DIRECTIONS

89       None.
90

SEE ALSO

92       chmod(),  chown(),  creat(),  fcntl(),  fstatvfs(),  mknod(),   open(),
93       read(),    stat(),    write(),   the   Base   Definitions   volume   of
94       IEEE Std 1003.1-2001, <sys/stat.h>
95
97       Portions of this text are reprinted and reproduced in  electronic  form
98       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
99       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
100       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
101       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
102       event of any discrepancy between this version and the original IEEE and
103       The Open Group Standard, the original IEEE and The Open Group  Standard
104       is  the  referee document. The original Standard can be obtained online
105       at http://www.opengroup.org/unix/online.html .
106
107
108
109IEEE/The Open Group                  2003                           FCHMOD(3P)
Impressum