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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

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

APPLICATION USAGE

79       None.
80

RATIONALE

82       None.
83

FUTURE DIRECTIONS

85       None.
86

SEE ALSO

88       chmod(), chown(), creat(),  fcntl(),  fstatat(),  fstatvfs(),  mknod(),
89       open(), read(), write()
90
91       The Base Definitions volume of POSIX.1‐2017, <sys_stat.h>
92
94       Portions  of  this text are reprinted and reproduced in electronic form
95       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
96       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
97       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
98       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
99       event of any discrepancy between this version and the original IEEE and
100       The  Open Group Standard, the original IEEE and The Open Group Standard
101       is the referee document. The original Standard can be  obtained  online
102       at http://www.opengroup.org/unix/online.html .
103
104       Any  typographical  or  formatting  errors that appear in this page are
105       most likely to have been introduced during the conversion of the source
106       files  to  man page format. To report such errors, see https://www.ker
107       nel.org/doc/man-pages/reporting_bugs.html .
108
109
110
111IEEE/The Open Group                  2017                           FCHMOD(3P)
Impressum