file locking and new open
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Wed, 11 Aug 1982 08:53:08 +0000 (00:53 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Wed, 11 Aug 1982 08:53:08 +0000 (00:53 -0800)
SCCS-vsn: sys/sys/file.h 4.12
SCCS-vsn: sys/ufs/ffs/dinode.h 4.14
SCCS-vsn: sys/ufs/ffs/inode.h 4.14
SCCS-vsn: sys/ufs/ufs/dinode.h 4.14
SCCS-vsn: sys/ufs/ufs/inode.h 4.14

usr/src/sys/sys/file.h
usr/src/sys/ufs/ffs/dinode.h
usr/src/sys/ufs/ffs/inode.h
usr/src/sys/ufs/ufs/dinode.h
usr/src/sys/ufs/ufs/inode.h

index 9009857..29e7b51 100644 (file)
@@ -1,5 +1,6 @@
-/*     file.h  4.11    82/07/24        */
+/*     file.h  4.12    82/08/10        */
 
 
+#ifdef KERNEL
 /*
  * Descriptor table entry.
  * One for each kernel object.
 /*
  * Descriptor table entry.
  * One for each kernel object.
@@ -21,14 +22,58 @@ struct      file {
 /* end XXX */
 };
 
 /* end XXX */
 };
 
-#ifdef KERNEL
 struct file *file, *fileNFILE;
 int    nfile;
 struct file *getf();
 struct file *falloc();
 struct file *file, *fileNFILE;
 int    nfile;
 struct file *getf();
 struct file *falloc();
-#endif
 
 /* flags */
 
 /* flags */
-#define        FREAD           0x1             /* descriptor read/receive'able */
-#define        FWRITE          0x2             /* descriptor write/send'able */
-/* note: other flags for f_flag defined in fcntl.h */
+#define        FREAD           0x001           /* descriptor read/receive'able */
+#define        FWRITE          0x002           /* descriptor write/send'able */
+#define        FAPPEND         0x004           /* append on each write */
+/* the following defines the bits that users can set in f_flag */
+#define        FMODES  (FREAD|FWRITE|FAPPEND)
+#endif
+
+/*
+ * User visible desriptor attributes.
+ * These are supplied at open or flock time.
+ * FRDONLY, FWRONLY, and FRDWR are
+ * converted to FREAD and FWRITE on open.
+ */
+#define        FRDONLY         0x000           /* open for reading only */
+#define        FWRONLY         0x001           /* open for writing only */
+#define        FRDWR           0x002           /* open for reading and writing */
+#define        FAPPEND         0x004           /* append on each write */
+#define        FRDLOCK         0x008           /* apply read lock */
+#define        FWRLOCK         0x010           /* apply write lock */
+#define        FUNLOCK         0x100           /* release all locks */
+#define        FCREATE         0x200           /* create file if nonexistant */
+#define        FTRUNCATE       0x400           /* truncate file to size 0 on open */
+#define        FNBLOCK         0x800           /* don't block on open */
+
+/* these are for 3.0 "compatibility" */
+#define        O_RDONLY        FRDONLY         /* open for read */
+#define        O_WRONLY        FWRONLY         /* open for writing */
+#define        O_RDWR          FRDWR           /* open for read & write */
+#define        O_NDELAY        FNBLOCK         /* non-blocking I/O */
+#define        O_APPEND        FAPPEND         /* append */
+#define        O_CREAT         FCREATE         /* open with file create */
+#define        O_TRUNC         FTRUNCATE       /* open with truncation */
+#define        O_EXCL          FWRLOCK         /* exclusive open */
+
+/* flags supplied to access call */
+#define        FACCESS_EXISTS  0x0     /* does file exist */
+#define        FACCESS_EXECUTE 0x1     /* is it executable by caller */
+#define        FACCESS_WRITE   0x2     /* writable by caller */
+#define        FACCESS_READ    0x4     /* readable by caller */
+
+/* flags supplies to lseek call */
+#define        FSEEK_ABSOLUTE  0x0     /* absolute offset */
+#define        FSEEK_RELATIVE  0x1     /* relative to current offset */
+#define        FSEEK_EOF       0x2     /* relative to end of file */
+
+/* file types which may be specified to mknod */
+#define        FTYPE_CDEV      0x2000  /* character special device */
+#define        FTYPE_DIR       0x4000  /* directory */
+#define        FTYPE_BDEV      0x8000  /* block special device */
index 792e5b9..70d1fa7 100644 (file)
@@ -1,6 +1,4 @@
-/*     dinode.h        4.13    82/07/16        */
-
-/*     inode.h 2.1     3/25/82 */
+/*     dinode.h        4.14    82/08/10        */
 
 /*
  * The I node is the focus of all file activity in UNIX.
 
 /*
  * The I node is the focus of all file activity in UNIX.
 
 struct inode {
        struct  inode *i_chain[2];      /* must be first */
 
 struct inode {
        struct  inode *i_chain[2];      /* must be first */
-       char    i_flag;
+       u_short i_flag;
        u_short i_count;        /* reference count */
        dev_t   i_dev;          /* device where inode resides */
        u_short i_count;        /* reference count */
        dev_t   i_dev;          /* device where inode resides */
+       u_short i_rdlockc;      /* count of locked readers on inode */
+       u_short i_wrlockc;      /* count of locked writers on inode */
        ino_t   i_number;       /* i number, 1-to-1 with device address */
        struct  fs *i_fs;       /* file sys associated with this inode */
        struct  dquot *i_dquot; /* quota structure controlling this file */
        ino_t   i_number;       /* i number, 1-to-1 with device address */
        struct  fs *i_fs;       /* file sys associated with this inode */
        struct  dquot *i_dquot; /* quota structure controlling this file */
@@ -98,13 +98,16 @@ struct      inode *namei();
 #endif
 
 /* flags */
 #endif
 
 /* flags */
-#define        ILOCK   01              /* inode is locked */
-#define        IUPD    02              /* file has been modified */
-#define        IACC    04              /* inode access time to be updated */
-#define        IMOUNT  010             /* inode is mounted on */
-#define        IWANT   020             /* some process waiting on lock */
-#define        ITEXT   040             /* inode is pure text prototype */
-#define        ICHG    0100            /* inode has been changed */
+#define        ILOCK           0x1             /* inode is locked */
+#define        IUPD            0x2             /* file has been modified */
+#define        IACC            0x4             /* inode access time to be updated */
+#define        IMOUNT          0x8             /* inode is mounted on */
+#define        IWANT           0x10            /* some process waiting on lock */
+#define        ITEXT           0x20            /* inode is pure text prototype */
+#define        ICHG            0x40            /* inode has been changed */
+#define        IRDLOCK         0x80            /* file is read locked */
+#define        IWRLOCK         0x100           /* file is write locked */
+#define        ILWAIT          0x200           /* someone waiting on file lock */
 
 /* modes */
 #define        IFMT            0170000         /* type of file */
 
 /* modes */
 #define        IFMT            0170000         /* type of file */
index 7ee8098..b3de1ba 100644 (file)
@@ -1,6 +1,4 @@
-/*     inode.h 4.13    82/07/16        */
-
-/*     inode.h 2.1     3/25/82 */
+/*     inode.h 4.14    82/08/10        */
 
 /*
  * The I node is the focus of all file activity in UNIX.
 
 /*
  * The I node is the focus of all file activity in UNIX.
 
 struct inode {
        struct  inode *i_chain[2];      /* must be first */
 
 struct inode {
        struct  inode *i_chain[2];      /* must be first */
-       char    i_flag;
+       u_short i_flag;
        u_short i_count;        /* reference count */
        dev_t   i_dev;          /* device where inode resides */
        u_short i_count;        /* reference count */
        dev_t   i_dev;          /* device where inode resides */
+       u_short i_rdlockc;      /* count of locked readers on inode */
+       u_short i_wrlockc;      /* count of locked writers on inode */
        ino_t   i_number;       /* i number, 1-to-1 with device address */
        struct  fs *i_fs;       /* file sys associated with this inode */
        struct  dquot *i_dquot; /* quota structure controlling this file */
        ino_t   i_number;       /* i number, 1-to-1 with device address */
        struct  fs *i_fs;       /* file sys associated with this inode */
        struct  dquot *i_dquot; /* quota structure controlling this file */
@@ -98,13 +98,16 @@ struct      inode *namei();
 #endif
 
 /* flags */
 #endif
 
 /* flags */
-#define        ILOCK   01              /* inode is locked */
-#define        IUPD    02              /* file has been modified */
-#define        IACC    04              /* inode access time to be updated */
-#define        IMOUNT  010             /* inode is mounted on */
-#define        IWANT   020             /* some process waiting on lock */
-#define        ITEXT   040             /* inode is pure text prototype */
-#define        ICHG    0100            /* inode has been changed */
+#define        ILOCK           0x1             /* inode is locked */
+#define        IUPD            0x2             /* file has been modified */
+#define        IACC            0x4             /* inode access time to be updated */
+#define        IMOUNT          0x8             /* inode is mounted on */
+#define        IWANT           0x10            /* some process waiting on lock */
+#define        ITEXT           0x20            /* inode is pure text prototype */
+#define        ICHG            0x40            /* inode has been changed */
+#define        IRDLOCK         0x80            /* file is read locked */
+#define        IWRLOCK         0x100           /* file is write locked */
+#define        ILWAIT          0x200           /* someone waiting on file lock */
 
 /* modes */
 #define        IFMT            0170000         /* type of file */
 
 /* modes */
 #define        IFMT            0170000         /* type of file */
index 792e5b9..70d1fa7 100644 (file)
@@ -1,6 +1,4 @@
-/*     dinode.h        4.13    82/07/16        */
-
-/*     inode.h 2.1     3/25/82 */
+/*     dinode.h        4.14    82/08/10        */
 
 /*
  * The I node is the focus of all file activity in UNIX.
 
 /*
  * The I node is the focus of all file activity in UNIX.
 
 struct inode {
        struct  inode *i_chain[2];      /* must be first */
 
 struct inode {
        struct  inode *i_chain[2];      /* must be first */
-       char    i_flag;
+       u_short i_flag;
        u_short i_count;        /* reference count */
        dev_t   i_dev;          /* device where inode resides */
        u_short i_count;        /* reference count */
        dev_t   i_dev;          /* device where inode resides */
+       u_short i_rdlockc;      /* count of locked readers on inode */
+       u_short i_wrlockc;      /* count of locked writers on inode */
        ino_t   i_number;       /* i number, 1-to-1 with device address */
        struct  fs *i_fs;       /* file sys associated with this inode */
        struct  dquot *i_dquot; /* quota structure controlling this file */
        ino_t   i_number;       /* i number, 1-to-1 with device address */
        struct  fs *i_fs;       /* file sys associated with this inode */
        struct  dquot *i_dquot; /* quota structure controlling this file */
@@ -98,13 +98,16 @@ struct      inode *namei();
 #endif
 
 /* flags */
 #endif
 
 /* flags */
-#define        ILOCK   01              /* inode is locked */
-#define        IUPD    02              /* file has been modified */
-#define        IACC    04              /* inode access time to be updated */
-#define        IMOUNT  010             /* inode is mounted on */
-#define        IWANT   020             /* some process waiting on lock */
-#define        ITEXT   040             /* inode is pure text prototype */
-#define        ICHG    0100            /* inode has been changed */
+#define        ILOCK           0x1             /* inode is locked */
+#define        IUPD            0x2             /* file has been modified */
+#define        IACC            0x4             /* inode access time to be updated */
+#define        IMOUNT          0x8             /* inode is mounted on */
+#define        IWANT           0x10            /* some process waiting on lock */
+#define        ITEXT           0x20            /* inode is pure text prototype */
+#define        ICHG            0x40            /* inode has been changed */
+#define        IRDLOCK         0x80            /* file is read locked */
+#define        IWRLOCK         0x100           /* file is write locked */
+#define        ILWAIT          0x200           /* someone waiting on file lock */
 
 /* modes */
 #define        IFMT            0170000         /* type of file */
 
 /* modes */
 #define        IFMT            0170000         /* type of file */
index 7ee8098..b3de1ba 100644 (file)
@@ -1,6 +1,4 @@
-/*     inode.h 4.13    82/07/16        */
-
-/*     inode.h 2.1     3/25/82 */
+/*     inode.h 4.14    82/08/10        */
 
 /*
  * The I node is the focus of all file activity in UNIX.
 
 /*
  * The I node is the focus of all file activity in UNIX.
 
 struct inode {
        struct  inode *i_chain[2];      /* must be first */
 
 struct inode {
        struct  inode *i_chain[2];      /* must be first */
-       char    i_flag;
+       u_short i_flag;
        u_short i_count;        /* reference count */
        dev_t   i_dev;          /* device where inode resides */
        u_short i_count;        /* reference count */
        dev_t   i_dev;          /* device where inode resides */
+       u_short i_rdlockc;      /* count of locked readers on inode */
+       u_short i_wrlockc;      /* count of locked writers on inode */
        ino_t   i_number;       /* i number, 1-to-1 with device address */
        struct  fs *i_fs;       /* file sys associated with this inode */
        struct  dquot *i_dquot; /* quota structure controlling this file */
        ino_t   i_number;       /* i number, 1-to-1 with device address */
        struct  fs *i_fs;       /* file sys associated with this inode */
        struct  dquot *i_dquot; /* quota structure controlling this file */
@@ -98,13 +98,16 @@ struct      inode *namei();
 #endif
 
 /* flags */
 #endif
 
 /* flags */
-#define        ILOCK   01              /* inode is locked */
-#define        IUPD    02              /* file has been modified */
-#define        IACC    04              /* inode access time to be updated */
-#define        IMOUNT  010             /* inode is mounted on */
-#define        IWANT   020             /* some process waiting on lock */
-#define        ITEXT   040             /* inode is pure text prototype */
-#define        ICHG    0100            /* inode has been changed */
+#define        ILOCK           0x1             /* inode is locked */
+#define        IUPD            0x2             /* file has been modified */
+#define        IACC            0x4             /* inode access time to be updated */
+#define        IMOUNT          0x8             /* inode is mounted on */
+#define        IWANT           0x10            /* some process waiting on lock */
+#define        ITEXT           0x20            /* inode is pure text prototype */
+#define        ICHG            0x40            /* inode has been changed */
+#define        IRDLOCK         0x80            /* file is read locked */
+#define        IWRLOCK         0x100           /* file is write locked */
+#define        ILWAIT          0x200           /* someone waiting on file lock */
 
 /* modes */
 #define        IFMT            0170000         /* type of file */
 
 /* modes */
 #define        IFMT            0170000         /* type of file */