Added a BeOS like fcntl.h, with some additions (which might be implemented

some day).
Cleaned up sys/stat.h a bit, and added new definitions for different types
of symlinks I plan to add - though I am still not sure if it's a good idea ;-)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@580 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2002-08-05 01:26:14 +00:00
parent 6a75716301
commit 2311f9f79f
2 changed files with 119 additions and 25 deletions

90
headers/posix/fcntl.h Normal file
View File

@ -0,0 +1,90 @@
#ifndef _FCNTL_H
#define _FCNTL_H
//#include <sys/types.h> /* for mode_t */
#include <ktypes.h> /* ToDo: remove me */
#include <sys/stat.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
#if __GNUC__
# define FD_CLOEXEC 1 /* Close on exec. */
#else
# define FD_CLOEXEC 0x0800
#endif
/* 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_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 */
// currently not implemented additions:
#define O_NOFOLLOW 0x00010000
/* 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_DIRECT O_DIRECT
#define O_SHLOCK 0x00040000
#define O_EXLOCK 0x00080000
#define O_FSYNC 0x10000000
/* advisory file locking */
struct flock {
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 */
#define LOCK_EX 0x02 /* exclusive file lock */
#define LOCK_NB 0x04 /* don't block when locking */
#define LOCK_UN 0x08 /* unlock file */
#define S_IREAD 0x0100 /* owner may read */
#define S_IWRITE 0x0080 /* owner may write */
#ifdef __cplusplus
extern "C" {
#endif
extern int creat(const char *path, mode_t mode);
extern int open(const char *pathname, int oflags, ...);
/* the third argument is the permissions of the created file when O_CREAT
is passed in oflags */
extern int fcntl(int fd, int op, ...);
extern int flock(int fd, int op);
#ifdef __cplusplus
}
#endif
#endif /* _FCNTL_H */

View File

@ -26,34 +26,38 @@ struct stat {
};
/* extended file types */
#define S_ATTR_DIR 01000000000 /* attribute directory */
#define S_ATTR 02000000000 /* attribute */
#define S_INDEX_DIR 04000000000 /* index (or index directory) */
#define S_STR_INDEX 00100000000 /* string index */
#define S_INT_INDEX 00200000000 /* int32 index */
#define S_UINT_INDEX 00400000000 /* uint32 index */
#define S_LONG_LONG_INDEX 00010000000 /* int64 index */
#define S_ULONG_LONG_INDEX 00020000000 /* uint64 index */
#define S_FLOAT_INDEX 00040000000 /* float index */
#define S_DOUBLE_INDEX 00001000000 /* double index */
#define S_ALLOW_DUPS 00002000000 /* allow duplicate entries (currently unused) */
#define S_ATTR_DIR 01000000000 /* attribute directory */
#define S_ATTR 02000000000 /* attribute */
#define S_INDEX_DIR 04000000000 /* index (or index directory) */
#define S_STR_INDEX 00100000000 /* string index */
#define S_INT_INDEX 00200000000 /* int32 index */
#define S_UINT_INDEX 00400000000 /* uint32 index */
#define S_LONG_LONG_INDEX 00010000000 /* int64 index */
#define S_ULONG_LONG_INDEX 00020000000 /* uint64 index */
#define S_FLOAT_INDEX 00040000000 /* float index */
#define S_DOUBLE_INDEX 00001000000 /* double index */
#define S_ALLOW_DUPS 00002000000 /* allow duplicate entries (currently unused) */
/* link types */
#define S_LINK_SELF_HEALING 00001000000 /* link will be updated if you move its target */
#define S_LINK_AUTO_DELETE 00002000000 /* link will be deleted if you delete its target */
/* standard file types */
#define S_IFMT 00000170000 /* type of file */
#define S_IFLNK 00000120000 /* symbolic link */
#define S_IFREG 00000100000 /* regular */
#define S_IFBLK 00000060000 /* block special */
#define S_IFDIR 00000040000 /* directory */
#define S_IFCHR 00000020000 /* character special */
#define S_IFIFO 00000010000 /* fifo */
#define S_IFMT 00000170000 /* type of file */
#define S_IFLNK 00000120000 /* symbolic link */
#define S_IFREG 00000100000 /* regular */
#define S_IFBLK 00000060000 /* block special */
#define S_IFDIR 00000040000 /* directory */
#define S_IFCHR 00000020000 /* character special */
#define S_IFIFO 00000010000 /* fifo */
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#define S_ISINDEX(m) (((m) & S_INDEX_DIR) == S_INDEX_DIR)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#define S_ISINDEX(m) (((m) & S_INDEX_DIR) == S_INDEX_DIR)
#define S_IUMSK 07777 /* user settable bits */