os161-1.99
 All Data Structures
fcntl.h
00001 /*
00002  * Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008
00003  *      The President and Fellows of Harvard College.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. Neither the name of the University nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  */
00029 
00030 #ifndef _KERN_FCNTL_H_
00031 #define _KERN_FCNTL_H_
00032 
00033 /*
00034  * Constants for libc's <fcntl.h>.
00035  */
00036 
00037 
00038 /*
00039  * Important
00040  */
00041 
00042 /* Flags for open: choose one of these: */
00043 #define O_RDONLY      0      /* Open for read */
00044 #define O_WRONLY      1      /* Open for write */
00045 #define O_RDWR        2      /* Open for read and write */
00046 /* then or in any of these: */
00047 #define O_CREAT       4      /* Create file if it doesn't exist */
00048 #define O_EXCL        8      /* With O_CREAT, fail if file already exists */
00049 #define O_TRUNC      16      /* Truncate file upon open */
00050 #define O_APPEND     32      /* All writes happen at EOF (optional feature) */
00051 #define O_NOCTTY     64      /* Required by POSIX, != 0, but does nothing */
00052 
00053 /* Additional related definition */
00054 #define O_ACCMODE     3      /* mask for O_RDONLY/O_WRONLY/O_RDWR */
00055 
00056 /*
00057  * Not so important
00058  */
00059 
00060 /* operation codes for flock() */
00061 #define LOCK_SH         1       /* shared lock */
00062 #define LOCK_EX         2       /* exclusive lock */
00063 #define LOCK_UN         3       /* release the lock */
00064 #define LOCK_NB         4       /* flag: don't block */
00065 
00066 /*
00067  * Mostly pretty useless
00068  */
00069 
00070 /* fcntl() operations */
00071 #define F_DUPFD         0       /* like dup() but not quite */  
00072 #define F_GETFD         1       /* get per-handle flags */
00073 #define F_SETFD         2       /* set per-handle flags */
00074 #define F_GETFL         3       /* get per-file flags (O_* open flags) */
00075 #define F_SETFL         4       /* set per-file flags (O_* open flags) */
00076 #define F_GETOWN        5       /* get process/pgroup for SIGURG and SIGIO */
00077 #define F_SETOWN        6       /* set process/pgroup for SIGURG and SIGIO */
00078 #define F_GETLK         7       /* inspect record locks */
00079 #define F_SETLK         8       /* acquire record locks nonblocking */
00080 #define F_SETLKW        9       /* acquire record locks and wait */
00081 
00082 /* flag for F_GETFD and F_SETFD */
00083 #define FD_CLOEXEC      1       /* close-on-exec */
00084 
00085 /* modes for fcntl (F_GETLK/SETLK) locking */
00086 #define F_RDLCK         0       /* shared lock */
00087 #define F_WRLCK         1       /* exclusive lock */
00088 #define F_UNLCK         2       /* unlock */
00089 
00090 /* struct for fcntl (F_GETLK/SETLK) locking */
00091 struct flock {
00092         off_t l_start;          /* place in file */
00093         int l_whence;           /* SEEK_SET, SEEK_CUR, or SEEK_END */
00094         int l_type;             /* F_RDLCK or F_WRLCK */
00095         off_t l_len;            /* length of locked region */
00096         pid_t l_pid;            /* process that holds the lock */
00097 };
00098 
00099 
00100 #endif /* _KERN_FCNTL_H_ */
 All Data Structures