BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / sys / fcntl.h
index bae0043..cc72bca 100644 (file)
@@ -2,9 +2,35 @@
  * Copyright (c) 1983, 1990 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1983, 1990 The Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)fcntl.h     5.12 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)fcntl.h     5.14 (Berkeley) 7/1/91
  */
 
 #ifndef _FCNTL_H_
  */
 
 #ifndef _FCNTL_H_
 
 /*
  * File status flags: these are used by open(2), fcntl(2).
 
 /*
  * File status flags: these are used by open(2), fcntl(2).
- * They are also used in the kernel file structure,
- * which is a superset of the open/fcntl flags.
- * Open/fcntl flags begin with O_; kernel-internal-only
- * flags begin with F.
+ * They are also used (indirectly) in the kernel file structure f_flags,
+ * which is a superset of the open/fcntl flags.  Open flags and f_flags
+ * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
+ * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
  */
 /* open-only flags */
 #define        O_RDONLY        0x0000          /* open for reading only */
  */
 /* open-only flags */
 #define        O_RDONLY        0x0000          /* open for reading only */
 #endif
 #define        O_NONBLOCK      0x0004          /* no delay */
 #define        O_APPEND        0x0008          /* set append mode */
 #endif
 #define        O_NONBLOCK      0x0004          /* no delay */
 #define        O_APPEND        0x0008          /* set append mode */
-#ifdef KERNEL
-#define        FMARK           0x0010          /* mark during gc() */
-#define        FDEFER          0x0020          /* defer for next gc pass */
-#endif
 #ifndef _POSIX_SOURCE
 #ifndef _POSIX_SOURCE
+#define        O_SHLOCK        0x0010          /* open with shared file lock */
+#define        O_EXLOCK        0x0020          /* open with exclusive file lock */
 #define        O_ASYNC         0x0040          /* signal pgrp when data ready */
 #define        O_ASYNC         0x0040          /* signal pgrp when data ready */
-#define        O_SHLOCK        0x0080          /* shared file lock present */
-#define        O_EXLOCK        0x0100          /* exclusive file lock present */
+#define        O_FSYNC         0x0080          /* synchronous writes */
 #endif
 #define        O_CREAT         0x0200          /* create if nonexistant */
 #define        O_TRUNC         0x0400          /* truncate to zero length */
 #define        O_EXCL          0x0800          /* error if already exists */
 #endif
 #define        O_CREAT         0x0200          /* create if nonexistant */
 #define        O_TRUNC         0x0400          /* truncate to zero length */
 #define        O_EXCL          0x0800          /* error if already exists */
-#define        O_FSYNC         0x1000          /* synchronous writes */
+#ifdef KERNEL
+#define        FMARK           0x1000          /* mark during gc() */
+#define        FDEFER          0x2000          /* defer for next gc pass */
+#define        FHASLOCK        0x4000          /* descriptor holds advisory lock */
+#endif
 
 /* defined by POSIX 1003.1; BSD default, so no bit required */
 #define        O_NOCTTY        0               /* don't assign controlling terminal */
 
 /* defined by POSIX 1003.1; BSD default, so no bit required */
 #define        O_NOCTTY        0               /* don't assign controlling terminal */
@@ -66,9 +93,9 @@
 #define        OFLAGS(fflags)  ((fflags) - 1)
 
 /* bits to save after open */
 #define        OFLAGS(fflags)  ((fflags) - 1)
 
 /* bits to save after open */
-#define        FMASK           (FREAD|FWRITE|FAPPEND|FASYNC|FNONBLOCK)
+#define        FMASK           (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
 /* bits settable by fcntl(F_SETFL, ...) */
 /* bits settable by fcntl(F_SETFL, ...) */
-#define        FCNTLFLAGS      (O_NONBLOCK|O_APPEND|O_ASYNC|O_FSYNC)
+#define        FCNTLFLAGS      (FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
 #endif
 
 /*
 #endif
 
 /*
  * and for backward compatibility for fcntl.
  */
 #ifndef _POSIX_SOURCE
  * and for backward compatibility for fcntl.
  */
 #ifndef _POSIX_SOURCE
-#define        FAPPEND         O_APPEND
-#define        FASYNC          O_ASYNC
-#define        FNDELAY         O_NONBLOCK
-#define        O_NDELAY        O_NONBLOCK
+#define        FAPPEND         O_APPEND        /* kernel/compat */
+#define        FASYNC          O_ASYNC         /* kernel/compat */
+#define        FFSYNC          O_FSYNC         /* kernel */
+#define        FNONBLOCK       O_NONBLOCK      /* kernel */
+#define        FNDELAY         O_NONBLOCK      /* compat */
+#define        O_NDELAY        O_NONBLOCK      /* compat */
 #endif
 
 #endif
 
-#ifdef KERNEL
-#define        FCREAT          O_CREAT         /* not stored in f_flags */
-#define        FEXCL           O_EXCL          /* not stored in f_flags */
-#define        FTRUNC          O_TRUNC         /* not stored in f_flags */
-#define        FEXLOCK         O_EXLOCK
-#define        FSHLOCK         O_SHLOCK
-#define        FNONBLOCK       O_NONBLOCK
-#endif
-
-
 /*
  * Constants used for fcntl(2)
  */
 /*
  * Constants used for fcntl(2)
  */