home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / ufs / inode.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-22  |  9.5 KB  |  261 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:    inode.h,v $
  29.  * Revision 2.1  92/04/21  17:18:14  rwd
  30.  * BSDSS
  31.  * 
  32.  *
  33.  */
  34.  
  35. /*
  36.  * Copyright (c) 1982, 1989 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.  *    @(#)inode.h    7.17 (Berkeley) 5/8/91
  68.  */
  69.  
  70. #include <ufs/dinode.h>
  71.  
  72. /*
  73.  * The inode is used to describe each active (or recently active)
  74.  * file in the UFS filesystem. It is composed of two types of
  75.  * information. The first part is the information that is needed
  76.  * only while the file is active (such as the identity of the file
  77.  * and linkage to speed its lookup). The second part is the 
  78.  * permannent meta-data associated with the file which is read
  79.  * in from the permanent dinode from long term storage when the
  80.  * file becomes active, and is put back when the file is no longer
  81.  * being used.
  82.  */
  83. struct inode {
  84.     struct    inode *i_chain[2]; /* hash chain, MUST be first */
  85.     struct    vnode *i_vnode;    /* vnode associated with this inode */
  86.     struct    vnode *i_devvp;    /* vnode for block I/O */
  87.     u_long    i_flag;        /* see below */
  88.     dev_t    i_dev;        /* device where inode resides */
  89.     ino_t    i_number;    /* the identity of the inode */
  90.     struct    fs *i_fs;    /* filesystem associated with this inode */
  91.     struct    dquot *i_dquot[MAXQUOTAS]; /* pointer to dquot structures */
  92.     struct    lockf *i_lockf;    /* head of byte-level lock list */
  93.     long    i_diroff;    /* offset in dir, where we found last entry */
  94.     off_t    i_endoff;    /* end of useful stuff in directory */
  95.     long    i_spare0;
  96.     long    i_spare1;
  97.     struct    dinode i_din;    /* the on-disk dinode */
  98. };
  99.  
  100. #define    i_mode        i_din.di_mode
  101. #define    i_nlink        i_din.di_nlink
  102. #define    i_uid        i_din.di_uid
  103. #define    i_gid        i_din.di_gid
  104. #if BYTE_ORDER == LITTLE_ENDIAN || defined(tahoe) /* ugh! -- must be fixed */
  105. #define    i_size        i_din.di_qsize.val[0]
  106. #else /* BYTE_ORDER == BIG_ENDIAN */
  107. #define    i_size        i_din.di_qsize.val[1]
  108. #endif
  109. #define    i_db        i_din.di_db
  110. #define    i_ib        i_din.di_ib
  111. #define    i_atime        i_din.di_atime
  112. #define    i_mtime        i_din.di_mtime
  113. #define    i_ctime        i_din.di_ctime
  114. #define i_blocks    i_din.di_blocks
  115. #define    i_rdev        i_din.di_db[0]
  116. #define i_flags        i_din.di_flags
  117. #define i_gen        i_din.di_gen
  118. #define    i_forw        i_chain[0]
  119. #define    i_back        i_chain[1]
  120.  
  121. /* flags */
  122. #define    ILOCKED        0x0001        /* inode is locked */
  123. #define    IWANT        0x0002        /* some process waiting on lock */
  124. #define    IRENAME        0x0004        /* inode is being renamed */
  125. #define    IUPD        0x0010        /* file has been modified */
  126. #define    IACC        0x0020        /* inode access time to be updated */
  127. #define    ICHG        0x0040        /* inode has been changed */
  128. #define    IMOD        0x0080        /* inode has been modified */
  129. #define    ISHLOCK        0x0100        /* file has shared lock */
  130. #define    IEXLOCK        0x0200        /* file has exclusive lock */
  131. #define    ILWAIT        0x0400        /* someone waiting on file lock */
  132.  
  133. #ifdef KERNEL
  134. /*
  135.  * Convert between inode pointers and vnode pointers
  136.  */
  137. #define VTOI(vp)    ((struct inode *)(vp)->v_data)
  138. #define ITOV(ip)    ((ip)->i_vnode)
  139.  
  140. /*
  141.  * Convert between vnode types and inode formats
  142.  */
  143. extern enum vtype    iftovt_tab[];
  144. extern int        vttoif_tab[];
  145. #define IFTOVT(mode)    (iftovt_tab[((mode) & IFMT) >> 12])
  146. #define VTTOIF(indx)    (vttoif_tab[(int)(indx)])
  147.  
  148. #define MAKEIMODE(indx, mode)    (int)(VTTOIF(indx) | (mode))
  149.  
  150. u_long    nextgennumber;        /* next generation number to assign */
  151.  
  152. extern ino_t    dirpref();
  153.  
  154. /*
  155.  * Lock and unlock inodes.
  156.  */
  157. #ifdef notdef
  158. #define    ILOCK(ip) { \
  159.     while ((ip)->i_flag & ILOCKED) { \
  160.         (ip)->i_flag |= IWANT; \
  161.         (void) sleep((caddr_t)(ip), PINOD); \
  162.     } \
  163.     (ip)->i_flag |= ILOCKED; \
  164. }
  165.  
  166. #define    IUNLOCK(ip) { \
  167.     (ip)->i_flag &= ~ILOCKED; \
  168.     if ((ip)->i_flag&IWANT) { \
  169.         (ip)->i_flag &= ~IWANT; \
  170.         wakeup((caddr_t)(ip)); \
  171.     } \
  172. }
  173. #else
  174. #define ILOCK(ip)    ilock(ip)
  175. #define IUNLOCK(ip)    iunlock(ip)
  176. #endif
  177.  
  178. #define    IUPDAT(ip, t1, t2, waitfor) { \
  179.     if (ip->i_flag&(IUPD|IACC|ICHG|IMOD)) \
  180.         (void) iupdat(ip, t1, t2, waitfor); \
  181. }
  182.  
  183. #define    ITIMES(ip, t1, t2) { \
  184.     if ((ip)->i_flag&(IUPD|IACC|ICHG)) { \
  185.         (ip)->i_flag |= IMOD; \
  186.         if ((ip)->i_flag&IACC) \
  187.             (ip)->i_atime = (t1)->tv_sec; \
  188.         if ((ip)->i_flag&IUPD) \
  189.             (ip)->i_mtime = (t2)->tv_sec; \
  190.         if ((ip)->i_flag&ICHG) \
  191.             (ip)->i_ctime = time.tv_sec; \
  192.         (ip)->i_flag &= ~(IACC|IUPD|ICHG); \
  193.     } \
  194. }
  195.  
  196. /*
  197.  * This overlays the fid sturcture (see mount.h)
  198.  */
  199. struct ufid {
  200.     u_short    ufid_len;    /* length of structure */
  201.     u_short    ufid_pad;    /* force long alignment */
  202.     ino_t    ufid_ino;    /* file number (ino) */
  203.     long    ufid_gen;    /* generation number */
  204. };
  205.  
  206. /*
  207.  * Prototypes for UFS vnode operations
  208.  */
  209. int ufs_lookup __P((struct vnode *vp, struct nameidata *ndp, struct proc *p));
  210. int ufs_create __P((struct nameidata *ndp, struct vattr *vap, struct proc *p));
  211. int ufs_mknod __P((struct nameidata *ndp, struct vattr *vap, struct ucred *cred,
  212.     struct proc *p));
  213. int ufs_open __P((struct vnode *vp, int mode, struct ucred *cred,
  214.     struct proc *p));
  215. int ufs_close __P((struct vnode *vp, int fflag, struct ucred *cred,
  216.     struct proc *p));
  217. int ufs_access __P((struct vnode *vp, int mode, struct ucred *cred,
  218.     struct proc *p));
  219. int ufs_getattr __P((struct vnode *vp, struct vattr *vap, struct ucred *cred,
  220.     struct proc *p));
  221. int ufs_setattr __P((struct vnode *vp, struct vattr *vap, struct ucred *cred,
  222.     struct proc *p));
  223. int ufs_read __P((struct vnode *vp, struct uio *uio, int ioflag,
  224.     struct ucred *cred));
  225. int ufs_write __P((struct vnode *vp, struct uio *uio, int ioflag,
  226.     struct ucred *cred));
  227. int ufs_ioctl __P((struct vnode *vp, int command, caddr_t data, int fflag,
  228.     struct ucred *cred, struct proc *p));
  229. int ufs_select __P((struct vnode *vp, int which, int fflags, struct ucred *cred,
  230.     struct proc *p));
  231. int ufs_mmap __P((struct vnode *vp, int fflags, struct ucred *cred,
  232.     struct proc *p));
  233. int ufs_fsync __P((struct vnode *vp, int fflags, struct ucred *cred,
  234.     int waitfor, struct proc *p));
  235. int ufs_seek __P((struct vnode *vp, off_t oldoff, off_t newoff,
  236.     struct ucred *cred));
  237. int ufs_remove __P((struct nameidata *ndp, struct proc *p));
  238. int ufs_link __P((struct vnode *vp, struct nameidata *ndp, struct proc *p));
  239. int ufs_rename __P((struct nameidata *fndp, struct nameidata *tdnp,
  240.     struct proc *p));
  241. int ufs_mkdir __P((struct nameidata *ndp, struct vattr *vap, struct proc *p));
  242. int ufs_rmdir __P((struct nameidata *ndp, struct proc *p));
  243. int ufs_symlink __P((struct nameidata *ndp, struct vattr *vap, char *target,
  244.     struct proc *p));
  245. int ufs_readdir __P((struct vnode *vp, struct uio *uio, struct ucred *cred,
  246.     int *eofflagp));
  247. int ufs_readlink __P((struct vnode *vp, struct uio *uio, struct ucred *cred));
  248. int ufs_abortop __P((struct nameidata *ndp));
  249. int ufs_inactive __P((struct vnode *vp, struct proc *p));
  250. int ufs_reclaim __P((struct vnode *vp));
  251. int ufs_lock __P((struct vnode *vp));
  252. int ufs_unlock __P((struct vnode *vp));
  253. int ufs_bmap __P((struct vnode *vp, daddr_t bn, struct vnode **vpp,
  254.     daddr_t *bnp));
  255. int ufs_strategy __P((struct buf *bp));
  256. int ufs_print __P((struct vnode *vp));
  257. int ufs_islocked __P((struct vnode *vp));
  258. int ufs_advlock __P((struct vnode *vp, caddr_t id, int op, struct flock *fl,
  259.     int flags));
  260. #endif /* KERNEL */
  261.