Added comments to definitions.

Added preliminary O_TEMPORARY flag.
Made it a bit more POSIX compliant.
Cleaned up header.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9026 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2004-09-21 22:45:08 +00:00
parent 0d21a7f43f
commit 130b146f78

View File

@ -1,64 +1,74 @@
/*
** Distributed under the terms of the Haiku License.
*/
#ifndef _FCNTL_H
#define _FCNTL_H
/*
** Distributed under the terms of the OpenBeOS License.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
/* commands that can be passed to fcntl */
#define F_DUPFD 0x0001
#define F_GETFD 0x0002
#define F_SETFD 0x0004
#define F_GETFL 0x0008
#define F_SETFL 0x0010
#define F_GETLK 0x0020
#define F_RDLCK 0x0040
#define F_SETLK 0x0080
#define F_SETLKW 0x0100
#define F_UNLCK 0x0200
#define F_WRLCK 0x0400
#define FD_CLOEXEC 1 /* Close on exec. */
/* commands that can be passed to fcntl() */
#define F_DUPFD 0x0001 /* duplicate fd */
#define F_GETFD 0x0002 /* get fd flags */
#define F_SETFD 0x0004 /* set fd flags */
#define F_GETFL 0x0008 /* get file status flags and access mode */
#define F_SETFL 0x0010 /* set file status flags */
#define F_GETLK 0x0020 /* get locking information */
#define F_RDLCK 0x0040 /* read or shared lock */
#define F_SETLK 0x0080 /* set locking information */
#define F_SETLKW 0x0100 /* as above, but waits if blocked */
#define F_UNLCK 0x0200 /* unlock */
#define F_WRLCK 0x0400 /* write or exclusive lock */
/* file descriptor flags for fcntl() */
#define FD_CLOEXEC 1 /* close on exec */
/* file access modes for open() */
#define O_RDONLY 0x0000 /* read only */
#define O_WRONLY 0x0001 /* write only */
#define O_RDWR 0x0002 /* read and write */
#define O_ACCMODE 0x0003 /* mask to get the access modes above */
#define O_RWMASK O_ACCMODE
/* flags for open() */
#define O_RDONLY 0 /* read only */
#define O_WRONLY 1 /* write only */
#define O_RDWR 2 /* read and write */
#define O_RWMASK 3 /* Mask to get open mode */
#define O_EXCL 0x0100 /* exclusive creat */
#define O_CREAT 0x0200 /* create and open file */
#define O_TRUNC 0x0400 /* open with truncation */
#define O_NOCTTY 0x1000 /* currently unsupported */
#define O_NOTRAVERSE 0x2000 /* do not traverse leaf link */
#define O_CLOEXEC 0x0040 /* close fd on exec */
#define O_NONBLOCK 0x0080 /* non blocking io */
#define O_EXCL 0x0100 /* exclusive creat */
#define O_CREAT 0x0200 /* create and open file */
#define O_TRUNC 0x0400 /* open with truncation */
#define O_APPEND 0x0800 /* to end of file */
#define O_NOCTTY 0x1000 /* currently unsupported */
#define O_NOTRAVERSE 0x2000 /* do not traverse leaf link */
#define O_ACCMODE 0x0003 /* currently unsupported */
#define O_TEXT 0x4000 /* CR-LF translation */
#define O_BINARY 0x8000 /* no translation */
/* flags for open() and fcntl() */
#define O_CLOEXEC 0x00000040 /* close on exec */
#define O_NONBLOCK 0x00000080 /* non blocking io */
#define O_APPEND 0x00000800 /* to end of file */
#define O_TEXT 0x00004000 /* CR-LF translation */
#define O_BINARY 0x00008000 /* no translation */
#define O_SYNC 0x00010000 /* write synchronized I/O file integrity */
#define O_RSYNC 0x00020000 /* read synchronized I/O file integrity */
#define O_DSYNC 0x00040000 /* write synchronized I/O data integrity */
// currently not implemented additions:
#define O_NOFOLLOW 0x00010000
// ToDo: currently not implemented additions:
#define O_NOFOLLOW 0x00080000
/* should we implement this? it's similar to O_NOTRAVERSE but will fail on symlinks */
#define O_NOCACHE 0x00020000 /* doesn't use the file system cache if possible */
#define O_NOCACHE 0x00100000 /* doesn't use the file system cache if possible */
#define O_DIRECT O_NOCACHE
#define O_SHLOCK 0x00040000
#define O_EXLOCK 0x00080000
#define O_MOUNT 0x00100000 /* for file systems */
#define O_FSYNC 0x10000000
#define O_MOUNT 0x00200000 /* for file systems */
#define O_TEMPORARY 0x00400000 /* used to avoid writing temporary files to disk */
#define O_SHLOCK 0x01000000 /* obtain shared lock */
#define O_EXLOCK 0x02000000 /* obtain exclusive lock */
/* advisory file locking */
struct flock {
short l_type;
short l_whence;
off_t l_start;
off_t l_len;
pid_t l_pid;
short l_type;
short l_whence;
off_t l_start;
off_t l_len;
pid_t l_pid;
};
#define LOCK_SH 0x01 /* shared file lock */