s/PORTAL/SOCK/
[unix-history] / usr / src / sys / ufs / ffs / inode.h
index a3a5be2..e231e1c 100644 (file)
@@ -1,6 +1,4 @@
-/*     inode.h 4.12    82/06/29        */
-
-/*     inode.h 2.1     3/25/82 */
+/*     inode.h 4.18    82/10/31        */
 
 /*
  * 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;
-       char    i_count;        /* reference count */
+       u_short i_flag;
+       u_short i_count;        /* reference count */
        dev_t   i_dev;          /* device where inode resides */
        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 */
        ino_t   i_number;       /* i number, 1-to-1 with device address */
-       long    i_hlink;        /* link in hash chain (iget/iput/ifind) */
        struct  fs *i_fs;       /* file sys associated with this inode */
        struct  fs *i_fs;       /* file sys associated with this inode */
+       struct  dquot *i_dquot; /* quota structure controlling this file */
        union {
                daddr_t if_lastr;       /* last read (read-ahead) */
                struct  socket *is_socket;
        union {
                daddr_t if_lastr;       /* last read (read-ahead) */
                struct  socket *is_socket;
@@ -83,14 +83,13 @@ struct dinode {
 #define        di_rdev         di_ic.ic_db[0]
 
 #ifdef KERNEL
 #define        di_rdev         di_ic.ic_db[0]
 
 #ifdef KERNEL
-extern struct inode *inode;            /* The inode table itself */
-extern struct inode *inodeNINODE;      /* The end of the inode table */
-extern int ninode;                     /* number of slots in the table */
+struct inode *inode;           /* the inode table itself */
+struct inode *inodeNINODE;     /* the end of the inode table */
+int    ninode;                 /* number of slots in the table */
 
 struct inode *rootdir;                 /* pointer to inode of root directory */
 
 struct inode *ialloc();
 
 struct inode *rootdir;                 /* pointer to inode of root directory */
 
 struct inode *ialloc();
-struct inode *ifind();
 struct inode *iget();
 struct inode *owner();
 struct inode *maknode();
 struct inode *iget();
 struct inode *owner();
 struct inode *maknode();
@@ -98,13 +97,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        ILOCKED         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 */
@@ -113,10 +115,32 @@ struct    inode *namei();
 #define        IFBLK           0060000         /* block special */
 #define        IFREG           0100000         /* regular */
 #define        IFLNK           0120000         /* symbolic link */
 #define        IFBLK           0060000         /* block special */
 #define        IFREG           0100000         /* regular */
 #define        IFLNK           0120000         /* symbolic link */
-#define        IFPORTAL        0140000         /* portal */
+#define        IFSOCK          0140000         /* socket */
+
 #define        ISUID           04000           /* set user id on execution */
 #define        ISGID           02000           /* set group id on execution */
 #define        ISVTX           01000           /* save swapped text even after use */
 #define        IREAD           0400            /* read, write, execute permissions */
 #define        IWRITE          0200
 #define        IEXEC           0100
 #define        ISUID           04000           /* set user id on execution */
 #define        ISGID           02000           /* set group id on execution */
 #define        ISVTX           01000           /* save swapped text even after use */
 #define        IREAD           0400            /* read, write, execute permissions */
 #define        IWRITE          0200
 #define        IEXEC           0100
+
+#define        ILOCK(ip) { \
+       while ((ip)->i_flag & ILOCKED) { \
+               (ip)->i_flag |= IWANT; \
+               sleep((caddr_t)(ip), PINOD); \
+       } \
+       (ip)->i_flag |= ILOCKED; \
+}
+
+#define        IUNLOCK(ip) { \
+       (ip)->i_flag &= ~ILOCKED; \
+       if ((ip)->i_flag&IWANT) { \
+               (ip)->i_flag &= ~IWANT; \
+               wakeup((caddr_t)(ip)); \
+       } \
+}
+
+#define        IUPDAT(ip, t1, t2, waitfor) { \
+       if (ip->i_flag&(IUPD|IACC|ICHG)) \
+               iupdat(ip, t1, t2, waitfor); \
+}