Annotation of prex-old/include/sys/fcntl.h, Revision 1.1
1.1 ! nbrk 1: /*-
! 2: * Copyright (c) 1983, 1990, 1993
! 3: * The Regents of the University of California. All rights reserved.
! 4: * (c) UNIX System Laboratories, Inc.
! 5: * All or some portions of this file are derived from material licensed
! 6: * to the University of California by American Telephone and Telegraph
! 7: * Co. or Unix System Laboratories, Inc. and are reproduced herein with
! 8: * the permission of UNIX System Laboratories, Inc.
! 9: *
! 10: * Redistribution and use in source and binary forms, with or without
! 11: * modification, are permitted provided that the following conditions
! 12: * are met:
! 13: * 1. Redistributions of source code must retain the above copyright
! 14: * notice, this list of conditions and the following disclaimer.
! 15: * 2. Redistributions in binary form must reproduce the above copyright
! 16: * notice, this list of conditions and the following disclaimer in the
! 17: * documentation and/or other materials provided with the distribution.
! 18: * 3. Neither the name of the University nor the names of its contributors
! 19: * may be used to endorse or promote products derived from this software
! 20: * without specific prior written permission.
! 21: *
! 22: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 23: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 24: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 25: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 26: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 27: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 28: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 29: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 30: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 31: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 32: * SUCH DAMAGE.
! 33: *
! 34: * @(#)fcntl.h 8.3 (Berkeley) 1/21/94
! 35: */
! 36:
! 37: #ifndef _SYS_FCNTL_H_
! 38: #define _SYS_FCNTL_H_
! 39:
! 40: /*
! 41: * This file includes the definitions for open and fcntl
! 42: * described by POSIX for <fcntl.h>.
! 43: */
! 44:
! 45: #include <sys/types.h>
! 46:
! 47: /*
! 48: * File status flags: these are used by open(2), fcntl(2).
! 49: * They are also used (indirectly) in the kernel file structure f_flags,
! 50: * which is a superset of the open/fcntl flags. Open flags and f_flags
! 51: * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
! 52: * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
! 53: */
! 54: /* open-only flags */
! 55: #define O_RDONLY 0x00000000 /* open for reading only */
! 56: #define O_WRONLY 0x00000001 /* open for writing only */
! 57: #define O_RDWR 0x00000002 /* open for reading and writing */
! 58: #define O_ACCMODE 0x00000003 /* mask for above modes */
! 59:
! 60: /*
! 61: * Kernel encoding of open mode; separate read and write bits that are
! 62: * independently testable: 1 greater than the above.
! 63: */
! 64: #define FREAD 0x00000001
! 65: #define FWRITE 0x00000002
! 66:
! 67: #define O_NONBLOCK 0x00000004 /* no delay */
! 68: #define O_APPEND 0x00000008 /* set append mode */
! 69: #define O_SHLOCK 0x00000010 /* open with shared file lock */
! 70: #define O_EXLOCK 0x00000020 /* open with exclusive file lock */
! 71: #define O_ASYNC 0x00000040 /* signal pgrp when data ready */
! 72: #define O_SYNC 0x00000080 /* synchronous writes */
! 73: #define O_CREAT 0x00000200 /* create if nonexistent */
! 74: #define O_TRUNC 0x00000400 /* truncate to zero length */
! 75: #define O_EXCL 0x00000800 /* error if already exists */
! 76:
! 77: /* defined by POSIX 1003.1; BSD default, so no bit required */
! 78: #define O_NOCTTY 0 /* don't assign controlling terminal */
! 79:
! 80: /* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */
! 81: #define FFLAGS(oflags) ((oflags) + 1)
! 82: #define OFLAGS(fflags) ((fflags) - 1)
! 83:
! 84: /*
! 85: * Constants used for fcntl(2)
! 86: */
! 87:
! 88: /* command values */
! 89: #define F_DUPFD 0 /* duplicate file descriptor */
! 90: #define F_GETFD 1 /* get file descriptor flags */
! 91: #define F_SETFD 2 /* set file descriptor flags */
! 92: #define F_GETFL 3 /* get file status flags */
! 93: #define F_SETFL 4 /* set file status flags */
! 94: #define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */
! 95: #define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */
! 96: #define F_GETLK 7 /* get record locking information */
! 97: #define F_SETLK 8 /* set record locking information */
! 98: #define F_SETLKW 9 /* F_SETLK; wait if blocked */
! 99:
! 100: /* file descriptor flags (F_GETFD, F_SETFD) */
! 101: #define FD_CLOEXEC 1 /* close-on-exec flag */
! 102:
! 103: /* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
! 104: #define F_RDLCK 1 /* shared or read lock */
! 105: #define F_UNLCK 2 /* unlock */
! 106: #define F_WRLCK 3 /* exclusive or write lock */
! 107:
! 108: /*
! 109: * Advisory file segment locking data type -
! 110: * information passed to system by user
! 111: */
! 112: struct flock {
! 113: off_t l_start; /* starting offset */
! 114: off_t l_len; /* len = 0 means until end of file */
! 115: pid_t l_pid; /* lock owner */
! 116: short l_type; /* lock type: read/write, etc. */
! 117: short l_whence; /* type of l_start */
! 118: };
! 119:
! 120: /* lock operations for flock(2) */
! 121: #define LOCK_SH 0x01 /* shared file lock */
! 122: #define LOCK_EX 0x02 /* exclusive file lock */
! 123: #define LOCK_NB 0x04 /* don't block when locking */
! 124: #define LOCK_UN 0x08 /* unlock file */
! 125:
! 126:
! 127: #include <sys/cdefs.h>
! 128:
! 129: __BEGIN_DECLS
! 130: int open(const char *, int, ...);
! 131: int creat(const char *, mode_t);
! 132: int fcntl(int, int, ...);
! 133: int flock(int, int);
! 134: __END_DECLS
! 135:
! 136: #endif /* !_SYS_FCNTL_H_ */
CVSweb