stat.h(3head) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

stat.h(3head)

stat.h(3HEAD)                       Headers                      stat.h(3HEAD)

NAME
       stat.h, stat - data returned by stat system call

SYNOPSIS
       #include <sys/types.h>
       #include <sys/stat.h>

DESCRIPTION
       The system calls stat(), lstat(), fstat(), and fstatat() return data in
       a stat structure, which is defined in <sys/stat.h>.


       The following constants are also defined in this file. They may be used
       to  decode  the data provided in the st_mode field of a stat structure,
       or to form mode_t  arguments  to  system  calls  such  as  chmod(2)  or
       mknod(2).


       These  constants are used as bitmasks to separate the bits representing
       the file type from those representing the permissions or access mode:

       tab(); lw(0.92i) lw(4.58i) S_IFMTtype of file S_IAMBaccess mode bits



       The following constants are used as values to compare against the  bits
       representing  the  file type. They are not to be used as bitmasks them‐
       selves when making comparisons, but as values for a range of bits.

       tab();  lw(0.92i)  lw(4.58i)   S_IFIFOfifo   S_IFCHRcharacter   special
       S_IFDIRdirectory S_IFNAMXENIX special named file S_INSEMXENIX semaphore
       subtype of IFNAM S_INSHDXENIX shared data subtype of IFNAM S_IFBLKblock
       special S_IFREGregular S_IFLNKsymbolic link S_IFSOCKsocket S_IFDOORdoor
       S_IFPORTevent port



       The  following constants are used as values to compare against the bits
       representing the access mode. They may be combined using the  |  ("or")
       operator  to  form bitmasks. See chmod(2) for the effects of setting or
       unsetting each bit.

       tab(); lw(0.92i) lw(4.58i) S_ISUIDset user id on  execution  S_ISGIDset
       group  id  on execution S_ISVTXsticky bit S_IREADread permission, owner
       S_IWRITEwrite permission, owner S_IEXECexecute/search permission, owner
       S_ENFMTT{ mandatory file/record locking  enforcement  flag  T}  S_IRWX‐
       Uread, write, execute: owner S_IRUSRread permission: owner S_IWUSRwrite
       permission:  owner S_IXUSRexecute permission: owner S_IRWXGread, write,
       execute: group S_IRGRPread permission: group  S_IWGRPwrite  permission:
       group  S_IXGRPexecute  permission:  group  S_IRWXOread, write, execute:
       other S_IROTHread  permission:  other  S_IWOTHwrite  permission:  other
       S_IXOTHexecute permission: other



       The  following  macros are provided for convenience to compare the file
       type bits of st_mode values against the constant values for those  file
       types.

       tab();   lw(1.57i)  lw(3.93i)  S_ISBLK(mode)block  special  file  S_IS‐
       CHR(mode)character   special    file    S_ISDIR(mode)directory    S_IS‐
       DOOR(mode)door  S_ISFIFO(mode)pipe  or  fifo file S_ISLNK(mode)symbolic
       link   S_ISPORT(mode)event   port   S_ISREG(mode)regular   file   S_IS‐
       SOCK(mode)socket



       The following symbolic constants are defined as distinct integer values
       outside  of the range [0, 999 999 999], for use with the futimens() and
       utimensat() functions:

       tab(); lw(1.57i) lw(3.93i) UTIME_NOWuse the current  time  UTIME_OMITno
       time change


EXAMPLES
       Example 1 Determine type of file from stat() structure  information.



       The following example shows how to determine if a file path refers to a
       directory or not.


         #include <sys/types.h>
         #include <sys/stat.h>
         #include <fcntl.h>
         #include <fcntl.h>

         struct stat buffer;
         int         status;
         ...
         status = stat("/home/cnd/mod1", &buffer);
         if (S_ISDIR(buffer.st_mode)) {
             puts("/home is a directory");
         } else {
             puts("/home is not a directory");
         }




       The if statement could also be written as:


         if ((buffer.st_mode & S_IFMT) == S_IFDIR) {



       Checking  for  buffer.st_mode  & S_IFDIR will cause the code to fail to
       distinguish between directories and other file types which  have  over‐
       lapping bit patterns in their file format values.

ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:

       tab()  box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE TYPEAT‐
       TRIBUTE VALUE _ Interface StabilityCommitted _  StandardSee  the  stan‐
       dards(7) man page.


SEE ALSO
       chmod(2),   futimens(2),  mknod(2),  stat(2),  types.h(3HEAD),  attrib‐
       utes(7), standards(7)

Oracle Solaris 11.4               30 Aug 2024                    stat.h(3HEAD)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3