home *** CD-ROM | disk | FTP | other *** search
- /*
- * @(#) inode.h 2.3 88/06/21
- *
- * Copyright (C) The Santa Cruz Operation, 1984, 1985, 1986, 1987, 1988.
- * Copyright (C) Microsoft Corporation, 1984, 1985, 1986, 1987, 1988.
- * This Module contains Proprietary Information of
- * The Santa Cruz Operation, Microsoft Corporation
- * and AT&T, and should be treated as Confidential.
- */
-
- /*
- * THIS FILE CONTAINS CODE WHICH IS DESIGNED TO BE
- * PORTABLE BETWEEN DIFFERENT MACHINE ARCHITECTURES
- * AND CONFIGURATIONS. IT SHOULD NOT REQUIRE ANY
- * MODIFICATIONS WHEN ADAPTING XENIX TO NEW HARDWARE.
- */
-
-
- /*
- * The I node is the focus of all
- * file activity in unix. There is a unique
- * inode allocated for each active file,
- * each current directory, each mounted-on
- * file, text file, and the root. An inode is 'named'
- * by its dev/inumber pair. (iget/iget.c)
- * Data, from mode on, is read in
- * from permanent inode on volume.
- */
-
- #define NADDR 13
- #define NSADDR (NADDR*sizeof(daddr_t)/sizeof(short))
-
- /* file dependent part for named files */
-
- struct iisem { /* semaphore */
- int i_scount; /* current semaphore count */
- int i_eflag; /* err flg */
- filep_t i_headw; /* first waiter */
- filep_t i_tailw; /* last waiter */
- };
-
- struct iisd { /* shared data */
- mloc_t i_buf; /* address of kernel copy */
- long i_len; /* limit (size (in bytes) - 1) of segment */
- int i_vnum; /* version number */
- int i_snum; /* serial # for getv, waitv */
- int i_flags; /* LOCKED, etc. */
- short i_daddr; /* swap (disk) address of shared segment */
- char i_ccount; /* number of loaded references */
- #ifdef M_I386
- struct tabent *i_sdpt; /* pointer to shared data page table */
- ushort i_sdlocks; /* # of procs locking this sd seg into core */
- #endif /* M_I386 */
- char i_res; /* reserved -- used for word alignment */
- ushort i_cuid; /* SysV, creator uid */
- ushort i_cgid; /* SysV, creator gid */
- ushort i_cpid; /* SysV, creator pid */
- ushort i_lpid; /* SysV, pid of last operation */
- time_t i_ctime; /* SysV, time of last change */
- time_t i_atime; /* SysV, time of last attach */
- time_t i_dtime; /* SysV, time of last detach */
- };
-
-
- struct iirem { /* DSA */
- unsigned i_vcid; /* location of remote file */
- unsigned i_pte_p; /* ???? */
- int i_typ; /* type of the remote file */
- int i_fid; /* id of the remote file */
- int i_bid; /* bind id on remote sys */
- int i_tid; /* tree connect id */
- char (*i_gchar)(); /* function passed to nfc_nami */
- long i_path; /* path name */
- unsigned i_remres[10]; /* reserved for future use */
- };
-
- struct inode {
- char i_flag;
- cnt_t i_count; /* reference count */
- dev_t i_dev; /* device where inode resides */
- ino_t i_number; /* i number, 1-to-1 with device address */
- ushort i_mode;
- short i_nlink; /* directory entries */
- ushort i_uid; /* owner */
- ushort i_gid; /* group of owner */
- off_t i_size; /* size of file */
- union { /* file type dependent section */
- struct { /* files which have data blocks */
- union {
- daddr_t i_a[NADDR]; /* if normal file/directory */
- short i_f[NSADDR]; /* if fifio's */
- } i_p;
- daddr_t i_l; /* last logical block read (for read-ahead) */
- } i_blks;
- struct { /* name type files */
- long i_type;
- union {
- struct iisem i_sem;
- struct iisd i_sd;
- struct iirem i_rem; /* DSA */
- } i_ndata;
- } i_namef;
- struct {
- dev_t i_rd;
- struct stdata *i_sp;
- time_t i_at;
- time_t i_mt;
- time_t i_ct;
- } i_iod;
- } i_fdep;
- struct locklist *i_locklist; /* locked region list */
-
- long i_id; /* unique id for name cache verification */
- inodep_t i_forw; /* LRU hash chain forward */
- inodep_t i_back; /* LRU hash chain back */
- inodep_t i_freef; /* free list forward */
- inodepp_t i_freeb; /* free list back */
- };
-
- #ifdef M_KERNEL
-
- /*
- * Invalidate an inode. Used by the namei cache to detect stale
- * information. At an absurd rate of 100 calls/second, the inode
- * table invalidation should only occur once every 16 months.
- */
- long nextinodeid; /* unique id generator */
-
- #define cacheinval(ip) \
- (ip)->i_id = ++nextinodeid; \
- if (nextinodeid == 0) \
- cacheinvalall();
-
- #if defined(M_I8086) || defined(M_I286)
- extern struct inode far inode[]; /* The inode table itself */
- #else
- extern struct inode inode[]; /* The inode table itself */
- #endif
-
- #define LOCKI(ip) { \
- while ((ip)->i_flag & ILOCK) { \
- (ip)->i_flag |= IWANT; \
- sleep((caddr_t)(ip), PINOD); \
- } \
- (ip)->i_flag |= ILOCK; \
- }
-
- #define UNLOCKI(ip) { \
- (ip)->i_flag &= ~ILOCK; \
- if ((ip)->i_flag&IWANT) { \
- (ip)->i_flag &= ~IWANT; \
- wakeup((caddr_t)(ip)); \
- } \
- }
-
- #endif /* M_KERNEL */
-
- /* 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 */
-
- /* modes */
- #define IFMT 0170000 /* type of file */
- #define IFDIR 0040000 /* directory */
- #define IFCHR 0020000 /* character special */
- #define IFBLK 0060000 /* block special */
- #define IFREG 0100000 /* regular */
- #define IFMPC 0030000 /* multiplexed char special */
- #define IFMPB 0070000 /* multiplexed block special */
- #define IFIFO 0010000 /* fifo special */
- #define IFNAM 0050000 /* name special */
- #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 i_addr i_fdep.i_blks.i_p.i_a
- #define i_lastr i_fdep.i_blks.i_l
-
- /* fdep fields for device nodes */
- #define i_rdev i_fdep.i_iod.i_rd
- #define i_sptr i_fdep.i_iod.i_sp
- /* for in-core only device nodes (clone opens) */
- #define i_icatime i_fdep.i_iod.i_at
- #define i_icmtime i_fdep.i_iod.i_mt
- #define i_icctime i_fdep.i_iod.i_ct
-
- #define i_faddr i_fdep.i_blks.i_p.i_a
- #define NFADDR 10
- #define PIPSIZ NFADDR*BSIZE
- #define i_frptr i_fdep.i_blks.i_p.i_f[NSADDR-5]
- #define i_fwptr i_fdep.i_blks.i_p.i_f[NSADDR-4]
- #define i_frcnt i_fdep.i_blks.i_p.i_f[NSADDR-3]
- #define i_fwcnt i_fdep.i_blks.i_p.i_f[NSADDR-2]
- #define i_fflag i_fdep.i_blks.i_p.i_f[NSADDR-1]
- #define IFIR 01
- #define IFIW 02
-
- /* types for IFNAM type files */
- #define IFSEM 1L /* semaphore type */
- #define IFSHD 2L /* shared data */
- #define IFREM 3L /* Remote inode */
-