FCHMOD(3)                  POSIX Programmer's Manual                 FCHMOD(3)



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


NNAAMMEE
       fchmod -- change mode of a file

SSYYNNOOPPSSIISS
       #include <sys/stat.h>

       int fchmod(int _f_i_l_d_e_s, mode_t _m_o_d_e);

DDEESSCCRRIIPPTTIIOONN
       The _f_c_h_m_o_d() function shall be equivalent to _c_h_m_o_d() except that the
       file whose permissions are changed is specified by the file descriptor
       _f_i_l_d_e_s.

       If _f_i_l_d_e_s references a shared memory object, the _f_c_h_m_o_d() function need
       only affect the S_IRUSR, S_IWUSR, S_IRGRP, S_IWGRP, S_IROTH, and
       S_IWOTH file permission bits.

       If _f_i_l_d_e_s references a typed memory object, the behavior of _f_c_h_m_o_d() is
       unspecified.

       If _f_i_l_d_e_s refers to a socket, the behavior of _f_c_h_m_o_d() is unspecified.

       If _f_i_l_d_e_s refers to a STREAM (which is _f_a_t_t_a_c_h()-ed into the file
       system name space) the call returns successfully, doing nothing.

RREETTUURRNN VVAALLUUEE
       Upon successful completion, _f_c_h_m_o_d() shall return 0. Otherwise, it
       shall return -1 and set _e_r_r_n_o to indicate the error.

EERRRROORRSS
       The _f_c_h_m_o_d() function shall fail if:

       EEBBAADDFF  The _f_i_l_d_e_s argument is not an open file descriptor.

       EEPPEERRMM  The effective user ID does not match the owner of the file and
              the process does not have appropriate privileges.

       EERROOFFSS  The file referred to by _f_i_l_d_e_s resides on a read-only file
              system.

       The _f_c_h_m_o_d() function may fail if:

       EEIINNTTRR  The _f_c_h_m_o_d() function was interrupted by a signal.

       EEIINNVVAALL The value of the _m_o_d_e argument is invalid.

       EEIINNVVAALL The _f_i_l_d_e_s argument refers to a pipe and the implementation
              disallows execution of _f_c_h_m_o_d() on a pipe.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
   CChhaannggiinngg tthhee CCuurrrreenntt PPeerrmmiissssiioonnss ffoorr aa FFiillee
       The following example shows how to change the permissions for a file
       named //hhoommee//ccnndd//mmoodd11 so that the owner and group have
       read/write/execute permissions, but the world only has read/write
       permissions.

           ##iinncclluuddee <<ssyyss//ssttaatt..hh>>
           ##iinncclluuddee <<ffccnnttll..hh>>

           mode_t mode;
           int    fildes;
           ...
           fildes = open("/home/cnd/mod1", O_RDWR);
           fchmod(fildes, S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH);

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       None.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _c_h_m_o_d(), _c_h_o_w_n(), _c_r_e_a_t(), _f_c_n_t_l(), _f_s_t_a_t_a_t(), _f_s_t_a_t_v_f_s(), _m_k_n_o_d(),
       _o_p_e_n(), _r_e_a_d(), _w_r_i_t_e()

       The Base Definitions volume of POSIX.1-2008, <<ssyyss__ssttaatt..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                            FCHMOD(3)
