The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/include/fcntl.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /* The <fcntl.h> header is needed by the open() and fcntl() system calls,
    2  * which  have a variety of parameters and flags.  They are described here.  
    3  * The formats of the calls to each of these are:
    4  *
    5  *      open(path, oflag [,mode])       open a file
    6  *      fcntl(fd, cmd [,arg])           get or set file attributes
    7  * 
    8  */
    9 
   10 #ifndef _FCNTL_H
   11 #define _FCNTL_H
   12 
   13 #ifndef _TYPES_H
   14 #include <sys/types.h>
   15 #endif
   16 
   17 /* These values are used for cmd in fcntl().  POSIX Table 6-1.  */
   18 #define F_DUPFD            0    /* duplicate file descriptor */
   19 #define F_GETFD            1    /* get file descriptor flags */
   20 #define F_SETFD            2    /* set file descriptor flags */
   21 #define F_GETFL            3    /* get file status flags */
   22 #define F_SETFL            4    /* set file status flags */
   23 #define F_GETLK            5    /* get record locking information */
   24 #define F_SETLK            6    /* set record locking information */
   25 #define F_SETLKW           7    /* set record locking info; wait if blocked */
   26 
   27 /* File descriptor flags used for fcntl().  POSIX Table 6-2. */
   28 #define FD_CLOEXEC         1    /* close on exec flag for third arg of fcntl */
   29 
   30 /* L_type values for record locking with fcntl().  POSIX Table 6-3. */
   31 #define F_RDLCK            1    /* shared or read lock */
   32 #define F_WRLCK            2    /* exclusive or write lock */
   33 #define F_UNLCK            3    /* unlock */
   34 
   35 /* Oflag values for open().  POSIX Table 6-4. */
   36 #define O_CREAT        00100    /* creat file if it doesn't exist */
   37 #define O_EXCL         00200    /* exclusive use flag */
   38 #define O_NOCTTY       00400    /* do not assign a controlling terminal */
   39 #define O_TRUNC        01000    /* truncate flag */
   40 
   41 /* File status flags for open() and fcntl().  POSIX Table 6-5. */
   42 #define O_APPEND       02000    /* set append mode */
   43 #define O_NONBLOCK     04000    /* no delay */
   44 
   45 /* File access modes for open() and fcntl().  POSIX Table 6-6. */
   46 #define O_RDONLY           0    /* open(name, O_RDONLY) opens read only */
   47 #define O_WRONLY           1    /* open(name, O_WRONLY) opens write only */
   48 #define O_RDWR             2    /* open(name, O_RDWR) opens read/write */
   49 
   50 /* Mask for use with file access modes.  POSIX Table 6-7. */
   51 #define O_ACCMODE         03    /* mask for file access modes */
   52 
   53 /* Struct used for locking.  POSIX Table 6-8. */
   54 struct flock {
   55   short l_type;                 /* type: F_RDLCK, F_WRLCK, or F_UNLCK */
   56   short l_whence;               /* flag for starting offset */
   57   off_t l_start;                /* relative offset in bytes */
   58   off_t l_len;                  /* size; if 0, then until EOF */
   59   pid_t l_pid;                  /* process id of the locks' owner */
   60 };
   61 
   62 /* Function Prototypes. */
   63 _PROTOTYPE( int creat, (const char *_path, _mnx_Mode_t _mode)           );
   64 _PROTOTYPE( int fcntl, (int _filedes, int _cmd, ...)                    );
   65 _PROTOTYPE( int open,  (const char *_path, int _oflag, ...)             );
   66 
   67 #endif /* _FCNTL_H */

Cache object: 0c39d39654cd37515f1ffc70539533f6


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.