home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / sys / fcntl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-22  |  7.5 KB  |  216 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1992 Carnegie Mellon University
  4.  * All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation is hereby granted, provided that both the copyright
  8.  * notice and this permission notice appear in all copies of the
  9.  * software, derivative works or modified versions, and any portions
  10.  * thereof, and that both notices appear in supporting documentation.
  11.  * 
  12.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15.  * 
  16.  * Carnegie Mellon requests users of this software to return to
  17.  * 
  18.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  19.  *  School of Computer Science
  20.  *  Carnegie Mellon University
  21.  *  Pittsburgh PA 15213-3890
  22.  * 
  23.  * any improvements or extensions that they make and grant Carnegie Mellon 
  24.  * the rights to redistribute these changes.
  25.  */
  26. /*
  27.  * HISTORY
  28.  * $Log:    fcntl.h,v $
  29.  * Revision 2.1  92/04/21  17:16:55  rwd
  30.  * BSDSS
  31.  * 
  32.  *
  33.  */
  34.  
  35. /*-
  36.  * Copyright (c) 1983, 1990 The Regents of the University of California.
  37.  * All rights reserved.
  38.  *
  39.  * Redistribution and use in source and binary forms, with or without
  40.  * modification, are permitted provided that the following conditions
  41.  * are met:
  42.  * 1. Redistributions of source code must retain the above copyright
  43.  *    notice, this list of conditions and the following disclaimer.
  44.  * 2. Redistributions in binary form must reproduce the above copyright
  45.  *    notice, this list of conditions and the following disclaimer in the
  46.  *    documentation and/or other materials provided with the distribution.
  47.  * 3. All advertising materials mentioning features or use of this software
  48.  *    must display the following acknowledgement:
  49.  *    This product includes software developed by the University of
  50.  *    California, Berkeley and its contributors.
  51.  * 4. Neither the name of the University nor the names of its contributors
  52.  *    may be used to endorse or promote products derived from this software
  53.  *    without specific prior written permission.
  54.  *
  55.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  56.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  57.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  58.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  59.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  60.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  61.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  62.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  63.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  64.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  65.  * SUCH DAMAGE.
  66.  *
  67.  *    @(#)fcntl.h    5.14 (Berkeley) 7/1/91
  68.  */
  69.  
  70. #ifndef _FCNTL_H_
  71. #define    _FCNTL_H_
  72.  
  73. /*
  74.  * This file includes the definitions for open and fcntl
  75.  * described by POSIX for <fcntl.h>; it also includes
  76.  * related kernel definitions.
  77.  */
  78.  
  79. #ifndef KERNEL
  80. #include <sys/types.h>
  81. #endif
  82.  
  83. /*
  84.  * File status flags: these are used by open(2), fcntl(2).
  85.  * They are also used (indirectly) in the kernel file structure f_flags,
  86.  * which is a superset of the open/fcntl flags.  Open flags and f_flags
  87.  * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
  88.  * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
  89.  */
  90. /* open-only flags */
  91. #define    O_RDONLY    0x0000        /* open for reading only */
  92. #define    O_WRONLY    0x0001        /* open for writing only */
  93. #define    O_RDWR        0x0002        /* open for reading and writing */
  94. #define    O_ACCMODE    0x0003        /* mask for above modes */
  95.  
  96. #ifdef KERNEL
  97. /*
  98.  * Kernel encoding of open mode; separate read and write bits
  99.  * that are independently testable: 1 greater than the above.
  100.  */
  101. #define    FREAD        0x0001
  102. #define    FWRITE        0x0002
  103. #endif
  104. #define    O_NONBLOCK    0x0004        /* no delay */
  105. #define    O_APPEND    0x0008        /* set append mode */
  106. #ifndef _POSIX_SOURCE
  107. #define    O_SHLOCK    0x0010        /* open with shared file lock */
  108. #define    O_EXLOCK    0x0020        /* open with exclusive file lock */
  109. #define    O_ASYNC        0x0040        /* signal pgrp when data ready */
  110. #define    O_FSYNC        0x0080        /* synchronous writes */
  111. #endif
  112. #define    O_CREAT        0x0200        /* create if nonexistant */
  113. #define    O_TRUNC        0x0400        /* truncate to zero length */
  114. #define    O_EXCL        0x0800        /* error if already exists */
  115. #ifdef KERNEL
  116. #define    FMARK        0x1000        /* mark during gc() */
  117. #define    FDEFER        0x2000        /* defer for next gc pass */
  118. #define    FHASLOCK    0x4000        /* descriptor holds advisory lock */
  119. #endif
  120.  
  121. /* defined by POSIX 1003.1; BSD default, so no bit required */
  122. #define    O_NOCTTY    0        /* don't assign controlling terminal */
  123.  
  124. #ifdef KERNEL
  125. /* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */
  126. #define    FFLAGS(oflags)    ((oflags) + 1)
  127. #define    OFLAGS(fflags)    ((fflags) - 1)
  128.  
  129. /* bits to save after open */
  130. #define    FMASK        (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
  131. /* bits settable by fcntl(F_SETFL, ...) */
  132. #define    FCNTLFLAGS    (FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
  133. #endif
  134.  
  135. /*
  136.  * The O_* flags used to have only F* names, which were used in the kernel
  137.  * and by fcntl.  We retain the F* names for the kernel f_flags field
  138.  * and for backward compatibility for fcntl.
  139.  */
  140. #ifndef _POSIX_SOURCE
  141. #define    FAPPEND        O_APPEND    /* kernel/compat */
  142. #define    FASYNC        O_ASYNC        /* kernel/compat */
  143. #define    FFSYNC        O_FSYNC        /* kernel */
  144. #define    FNONBLOCK    O_NONBLOCK    /* kernel */
  145. #define    FNDELAY        O_NONBLOCK    /* compat */
  146. #define    O_NDELAY    O_NONBLOCK    /* compat */
  147. #endif
  148.  
  149. /*
  150.  * Constants used for fcntl(2)
  151.  */
  152.  
  153. /* command values */
  154. #define    F_DUPFD        0        /* duplicate file descriptor */
  155. #define    F_GETFD        1        /* get file descriptor flags */
  156. #define    F_SETFD        2        /* set file descriptor flags */
  157. #define    F_GETFL        3        /* get file status flags */
  158. #define    F_SETFL        4        /* set file status flags */
  159. #ifndef _POSIX_SOURCE
  160. #define    F_GETOWN    5        /* get SIGIO/SIGURG proc/pgrp */
  161. #define F_SETOWN    6        /* set SIGIO/SIGURG proc/pgrp */
  162. #endif
  163. #define    F_GETLK        7        /* get record locking information */
  164. #define    F_SETLK        8        /* set record locking information */
  165. #define    F_SETLKW    9        /* F_SETLK; wait if blocked */
  166.  
  167. /* file descriptor flags (F_GETFD, F_SETFD) */
  168. #define    FD_CLOEXEC    1        /* close-on-exec flag */
  169.  
  170. /* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
  171. #define    F_RDLCK        1        /* shared or read lock */
  172. #define    F_UNLCK        2        /* unlock */
  173. #define    F_WRLCK        3        /* exclusive or write lock */
  174. #ifdef KERNEL
  175. #define    F_WAIT        0x010        /* Wait until lock is granted */
  176. #define    F_FLOCK        0x020         /* Use flock(2) semantics for lock */
  177. #define    F_POSIX        0x040         /* Use POSIX semantics for lock */
  178. #endif
  179.  
  180. /*
  181.  * Advisory file segment locking data type -
  182.  * information passed to system by user
  183.  */
  184. struct flock {
  185.     short    l_type;        /* lock type: read/write, etc. */
  186.     short    l_whence;    /* type of l_start */
  187.     off_t    l_start;    /* starting offset */
  188.     off_t    l_len;        /* len = 0 means until end of file */
  189.     pid_t    l_pid;        /* lock owner */
  190. };
  191.  
  192.  
  193. #ifndef _POSIX_SOURCE
  194. /* lock operations for flock(2) */
  195. #define    LOCK_SH        0x01        /* shared file lock */
  196. #define    LOCK_EX        0x02        /* exclusive file lock */
  197. #define    LOCK_NB        0x04        /* don't block when locking */
  198. #define    LOCK_UN        0x08        /* unlock file */
  199. #endif
  200.  
  201.  
  202. #ifndef KERNEL
  203. #include <sys/cdefs.h>
  204.  
  205. __BEGIN_DECLS
  206. int    open __P((const char *, int, ...));
  207. int    creat __P((const char *, mode_t));
  208. int    fcntl __P((int, int, ...));
  209. #ifndef _POSIX_SOURCE
  210. int    flock __P((int, int));
  211. #endif /* !_POSIX_SOURCE */
  212. __END_DECLS
  213. #endif
  214.  
  215. #endif /* !_FCNTL_H_ */
  216.