fcntl.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* $Id$ */
  2. /* Copied from Minix, with some changes */
  3. /* The <fcntl.h> header is needed by the open() and fcntl() system calls,
  4. * which have a variety of parameters and flags. They are described here.
  5. * The formats of the calls to each of these are:
  6. *
  7. * open(path, oflag [,mode]) open a file
  8. * fcntl(fd, cmd [,arg]) get or set file attributes
  9. *
  10. */
  11. #ifdef __BSD4_2
  12. #ifndef _FCNTL_H
  13. #define _FCNTL_H
  14. /* These values are used for cmd in fcntl(). POSIX Table 6-1. */
  15. #define F_DUPFD 0 /* duplicate file descriptor */
  16. #define F_GETFD 1 /* get file descriptor flags */
  17. #define F_SETFD 2 /* set file descriptor flags */
  18. #define F_GETFL 3 /* get file status flags */
  19. #define F_SETFL 4 /* set file status flags */
  20. #define F_GETLK 7 /* get record locking information */
  21. #define F_SETLK 8 /* set record locking information */
  22. #define F_SETLKW 9 /* set record locking info; wait if blocked */
  23. /* File descriptor flags used for fcntl(). POSIX Table 6-2. */
  24. #define FD_CLOEXEC 1 /* close on exec flag for third arg of fcntl */
  25. /* L_type values for record locking with fcntl(). POSIX Table 6-3. */
  26. #define F_RDLCK 1 /* shared or read lock */
  27. #define F_WRLCK 2 /* exclusive or write lock */
  28. #define F_UNLCK 3 /* unlock */
  29. /* Oflag values for open(). POSIX Table 6-4. */
  30. #define O_CREAT 0001000 /* creat file if it doesn't exist */
  31. #define O_EXCL 0004000 /* exclusive use flag */
  32. #define O_NOCTTY 0100000 /* do not assign a controlling terminal */
  33. #define O_TRUNC 0002000 /* truncate flag */
  34. /* File status flags for open() and fcntl(). POSIX Table 6-5. */
  35. #define O_APPEND 0000010 /* set append mode */
  36. #define O_NONBLOCK 0040000 /* no delay */
  37. #define O_NDELAY 0000004 /* no delay (BSD) */
  38. /* File access modes for open() and fcntl(). POSIX Table 6-6. */
  39. #define O_RDONLY 0 /* open(name, O_RDONLY) opens read only */
  40. #define O_WRONLY 1 /* open(name, O_WRONLY) opens write only */
  41. #define O_RDWR 2 /* open(name, O_RDWR) opens read/write */
  42. /* Mask for use with file access modes. POSIX Table 6-7. */
  43. #define O_ACCMODE 03 /* mask for file access modes */
  44. #endif /* _FCNTL_H */
  45. #endif /* __BSD4_2 */