Fork me on GitHub

root/include/fiwix/fcntl.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * fiwix/include/fiwix/fcntl.h
   3  *
   4  * Copyright 2018, Jordi Sanfeliu. All rights reserved.
   5  * Distributed under the terms of the Fiwix License.
   6  */
   7 
   8 #ifndef _FIWIX_FCNTL_H
   9 #define _FIWIX_FCNTL_H
  10 
  11 #include <fiwix/types.h>
  12 
  13 #define O_ACCMODE          0003
  14 #define O_RDONLY             00
  15 #define O_WRONLY             01
  16 #define O_RDWR               02
  17 
  18 /* for open() only */
  19 #define O_CREAT            0100 /* create file if it does not exist */
  20 #define O_EXCL             0200 /* exclusive use flag */
  21 #define O_NOCTTY           0400 /* do not assign controlling terminal */
  22 #define O_TRUNC           01000 /* truncate flag */
  23 #define O_NOFOLLOW      0400000 /* do not follow symbolic links */
  24 
  25 #define O_APPEND          02000
  26 #define O_NONBLOCK        04000
  27 #define O_NDELAY        O_NONBLOCK
  28 #define O_SYNC           010000
  29 
  30 #define F_DUPFD         0       /* duplicate file descriptor */
  31 #define F_GETFD         1       /* get file descriptor flags */
  32 #define F_SETFD         2       /* set file descriptor flags */
  33 #define F_GETFL         3       /* get status flags and file access modes */
  34 #define F_SETFL         4       /* set file status flags */
  35 #define F_GETLK         5       /* get record locking information */
  36 #define F_SETLK         6       /* set record locking information */
  37 #define F_SETLKW        7       /* same as F_SETLK; wait if blocked */
  38 
  39 /* get/set process or process group ID to receive SIGURG signals */
  40 #define F_SETOWN        8       /* for sockets only */
  41 #define F_GETOWN        9       /* for sockets only */
  42 
  43 /* for F_[GET|SET]FL */
  44 #define FD_CLOEXEC      1       /* close the file descriptor upon exec() */
  45 
  46 /* for POSIX fcntl() */
  47 #define F_RDLCK         0       /* shared or read lock */
  48 #define F_WRLCK         1       /* exclusive or write lock */
  49 #define F_UNLCK         2       /* unlock */
  50 
  51 /* for BSD flock() */
  52 #define LOCK_SH         1       /* shared lock */
  53 #define LOCK_EX         2       /* exclusive lock */
  54 #define LOCK_NB         4       /* or'd with one of the above to prevent
  55                                    blocking */
  56 #define LOCK_UN         8       /* unlock */
  57 
  58 /* IEEE Std 1003.1, 2004 Edition */
  59 struct flock {
  60         short int l_type;       /* type of lock: F_RDLCK, F_WRLCK, F_UNLCK */
  61         short int l_whence;     /* flag for 'l_start': SEEK_SET, SEEK_CUR, ...*/
  62         __off_t l_start;        /* relative offset in bytes */
  63         __off_t l_len;          /* size; if 0 then until EOF */
  64         __pid_t l_pid;          /* PID holding the lock; returned in F_GETLK */
  65 };
  66 
  67 #endif /* _FIWIX_FCNTL_H */

/* [previous][next][first][last][top][bottom][index][help] */