[BACK]Return to inode.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / ufs / ufs

Annotation of src/sys/ufs/ufs/inode.h, Revision 1.27.8.1

1.27.8.1! gehenna     1: /*     $NetBSD: inode.h,v 1.28 2002/06/16 00:13:17 perseant Exp $      */
1.6       mycroft     2:
1.1       mycroft     3: /*
                      4:  * Copyright (c) 1982, 1989, 1993
                      5:  *     The Regents of the University of California.  All rights reserved.
                      6:  * (c) UNIX System Laboratories, Inc.
                      7:  * All or some portions of this file are derived from material licensed
                      8:  * to the University of California by American Telephone and Telegraph
                      9:  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
                     10:  * the permission of UNIX System Laboratories, Inc.
                     11:  *
                     12:  * Redistribution and use in source and binary forms, with or without
                     13:  * modification, are permitted provided that the following conditions
                     14:  * are met:
                     15:  * 1. Redistributions of source code must retain the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer.
                     17:  * 2. Redistributions in binary form must reproduce the above copyright
                     18:  *    notice, this list of conditions and the following disclaimer in the
                     19:  *    documentation and/or other materials provided with the distribution.
                     20:  * 3. All advertising materials mentioning features or use of this software
                     21:  *    must display the following acknowledgement:
                     22:  *     This product includes software developed by the University of
                     23:  *     California, Berkeley and its contributors.
                     24:  * 4. Neither the name of the University nor the names of its contributors
                     25:  *    may be used to endorse or promote products derived from this software
                     26:  *    without specific prior written permission.
                     27:  *
                     28:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     29:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     30:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     31:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     32:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     33:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     34:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     35:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     36:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     37:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     38:  * SUCH DAMAGE.
                     39:  *
1.11      fvdl       40:  *     @(#)inode.h     8.9 (Berkeley) 5/14/95
1.1       mycroft    41:  */
                     42:
1.23      chs        43: #include <sys/vnode.h>
1.1       mycroft    44: #include <ufs/ufs/dinode.h>
1.8       cgd        45: #include <ufs/ufs/dir.h>
1.26      lukem      46: #include <ufs/ufs/quota.h>
1.10      bouyer     47: #include <ufs/ext2fs/ext2fs_dinode.h>
1.25      chs        48: #include <miscfs/genfs/genfs_node.h>
1.10      bouyer     49:
                     50: /*
                     51:  * Per-filesystem inode extensions.
                     52:  */
                     53: struct ext2fs_inode_ext {
1.15      enami      54:        ufs_daddr_t ext2fs_last_lblk;   /* last logical block allocated */
                     55:        ufs_daddr_t ext2fs_last_blk;    /* last block allocated on disk */
1.14      fvdl       56: };
                     57:
1.20      perseant   58: struct lfs_inode_ext {
                     59:        u_int32_t lfs_effnblocks;  /* number of blocks when i/o completes */
1.10      bouyer     60: };
1.1       mycroft    61:
                     62: /*
1.5       mycroft    63:  * The inode is used to describe each active (or recently active) file in the
                     64:  * UFS filesystem. It is composed of two types of information. The first part
                     65:  * is the information that is needed only while the file is active (such as
                     66:  * the identity of the file and linkage to speed its lookup). The second part
1.20      perseant   67:  * is the permanent meta-data associated with the file which is read in
1.5       mycroft    68:  * from the permanent dinode from long term storage when the file becomes
                     69:  * active, and is put back when the file is no longer being used.
1.1       mycroft    70:  */
                     71: struct inode {
1.25      chs        72:        struct genfs_node i_gnode;
1.11      fvdl       73:        LIST_ENTRY(inode) i_hash;/* Hash chain. */
1.15      enami      74:        struct  vnode *i_vnode; /* Vnode associated with this inode. */
                     75:        struct  vnode *i_devvp; /* Vnode for block I/O. */
1.5       mycroft    76:        u_int32_t i_flag;       /* flags, see below */
                     77:        dev_t     i_dev;        /* Device associated with the inode. */
                     78:        ino_t     i_number;     /* The identity of the inode. */
1.4       cgd        79:
1.1       mycroft    80:        union {                 /* Associated filesystem. */
1.5       mycroft    81:                struct  fs *fs;         /* FFS */
                     82:                struct  lfs *lfs;       /* LFS */
1.15      enami      83:                struct  m_ext2fs *e2fs; /* EXT2FS */
1.1       mycroft    84:        } inode_u;
                     85: #define        i_fs    inode_u.fs
                     86: #define        i_lfs   inode_u.lfs
1.15      enami      87: #define        i_e2fs  inode_u.e2fs
1.4       cgd        88:
1.23      chs        89:        struct   buflists i_pcbufhd;    /* softdep pagecache buffer head */
1.5       mycroft    90:        struct   dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */
1.4       cgd        91:        u_quad_t i_modrev;      /* Revision level for NFS lease. */
1.5       mycroft    92:        struct   lockf *i_lockf;/* Head of byte-level lock list. */
1.25      chs        93:
1.5       mycroft    94:        /*
                     95:         * Side effects; used during directory lookup.
                     96:         */
                     97:        int32_t   i_count;      /* Size of free slot in directory. */
                     98:        doff_t    i_endoff;     /* End of useful stuff in directory. */
                     99:        doff_t    i_diroff;     /* Offset in dir, where we found last entry. */
                    100:        doff_t    i_offset;     /* Offset of free space in directory. */
                    101:        ino_t     i_ino;        /* Inode number of found directory. */
                    102:        u_int32_t i_reclen;     /* Size of found directory entry. */
1.20      perseant  103:        int       i_ffs_effnlink;  /* i_nlink when I/O completes */
1.5       mycroft   104:        /*
1.10      bouyer    105:         * Inode extensions
                    106:         */
                    107:        union {
                    108:                /* Other extensions could go here... */
1.15      enami     109:                struct  ext2fs_inode_ext e2fs;
1.20      perseant  110:                struct  lfs_inode_ext lfs;
1.10      bouyer    111:        } inode_ext;
1.15      enami     112: #define        i_e2fs_last_lblk        inode_ext.e2fs.ext2fs_last_lblk
                    113: #define        i_e2fs_last_blk         inode_ext.e2fs.ext2fs_last_blk
1.20      perseant  114: #define i_lfs_effnblks         inode_ext.lfs.lfs_effnblocks
1.10      bouyer    115:        /*
1.5       mycroft   116:         * The on-disk dinode itself.
                    117:         */
1.10      bouyer    118:        union {
                    119:                struct  dinode ffs_din; /* 128 bytes of the on-disk dinode. */
1.16      enami     120:                struct  ext2fs_dinode e2fs_din; /* 128 bytes of the on-disk
                    121:                                                   dinode. */
1.10      bouyer    122:        } i_din;
1.1       mycroft   123: };
                    124:
1.10      bouyer    125: #define        i_ffs_atime             i_din.ffs_din.di_atime
1.15      enami     126: #define        i_ffs_atimensec         i_din.ffs_din.di_atimensec
                    127: #define        i_ffs_blocks            i_din.ffs_din.di_blocks
1.10      bouyer    128: #define        i_ffs_ctime             i_din.ffs_din.di_ctime
1.15      enami     129: #define        i_ffs_ctimensec         i_din.ffs_din.di_ctimensec
1.10      bouyer    130: #define        i_ffs_db                i_din.ffs_din.di_db
                    131: #define        i_ffs_flags             i_din.ffs_din.di_flags
                    132: #define        i_ffs_gen               i_din.ffs_din.di_gen
                    133: #define        i_ffs_gid               i_din.ffs_din.di_gid
                    134: #define        i_ffs_ib                i_din.ffs_din.di_ib
                    135: #define        i_ffs_mode              i_din.ffs_din.di_mode
                    136: #define        i_ffs_mtime             i_din.ffs_din.di_mtime
1.15      enami     137: #define        i_ffs_mtimensec         i_din.ffs_din.di_mtimensec
1.10      bouyer    138: #define        i_ffs_nlink             i_din.ffs_din.di_nlink
                    139: #define        i_ffs_rdev              i_din.ffs_din.di_rdev
1.15      enami     140: #define        i_ffs_shortlink         i_din.ffs_din.di_shortlink
1.10      bouyer    141: #define        i_ffs_size              i_din.ffs_din.di_size
                    142: #define        i_ffs_uid               i_din.ffs_din.di_uid
                    143:
1.15      enami     144: #define        i_e2fs_mode             i_din.e2fs_din.e2di_mode
                    145: #define        i_e2fs_uid              i_din.e2fs_din.e2di_uid
                    146: #define        i_e2fs_size             i_din.e2fs_din.e2di_size
                    147: #define        i_e2fs_atime            i_din.e2fs_din.e2di_atime
                    148: #define        i_e2fs_ctime            i_din.e2fs_din.e2di_ctime
                    149: #define        i_e2fs_mtime            i_din.e2fs_din.e2di_mtime
                    150: #define        i_e2fs_dtime            i_din.e2fs_din.e2di_dtime
                    151: #define        i_e2fs_gid              i_din.e2fs_din.e2di_gid
                    152: #define        i_e2fs_nlink            i_din.e2fs_din.e2di_nlink
                    153: #define        i_e2fs_nblock           i_din.e2fs_din.e2di_nblock
                    154: #define        i_e2fs_flags            i_din.e2fs_din.e2di_flags
                    155: #define        i_e2fs_blocks           i_din.e2fs_din.e2di_blocks
                    156: #define        i_e2fs_gen              i_din.e2fs_din.e2di_gen
                    157: #define        i_e2fs_facl             i_din.e2fs_din.e2di_facl
                    158: #define        i_e2fs_dacl             i_din.e2fs_din.e2di_dacl
                    159: #define        i_e2fs_faddr            i_din.e2fs_din.e2di_faddr
                    160: #define        i_e2fs_nfrag            i_din.e2fs_din.e2di_nfrag
                    161: #define        i_e2fs_fsize            i_din.e2fs_din.e2di_fsize
1.16      enami     162: #define        i_e2fs_rdev             i_din.e2fs_din.e2di_rdev
1.1       mycroft   163:
1.5       mycroft   164: /* These flags are kept in i_flag. */
                    165: #define        IN_ACCESS       0x0001          /* Access time update request. */
                    166: #define        IN_CHANGE       0x0002          /* Inode change time update request. */
1.11      fvdl      167: #define        IN_UPDATE       0x0004          /* Modification time update request. */
                    168: #define        IN_MODIFIED     0x0008          /* Inode has been modified. */
1.18      mycroft   169: #define        IN_ACCESSED     0x0010          /* Inode has been accessed. */
                    170: #define        IN_RENAME       0x0020          /* Inode is being renamed. */
                    171: #define        IN_SHLOCK       0x0040          /* File has shared lock. */
                    172: #define        IN_EXLOCK       0x0080          /* File has exclusive lock. */
                    173: #define        IN_CLEANING     0x0100          /* LFS: file is being cleaned */
                    174: #define        IN_ADIROP       0x0200          /* LFS: dirop in progress */
1.27      fvdl      175: #define IN_SPACECOUNTED        0x0400          /* Blocks to be freed in free count. */
1.5       mycroft   176:
1.24      mrg       177: #if defined(_KERNEL)
1.1       mycroft   178: /*
                    179:  * Structure used to pass around logical block paths generated by
                    180:  * ufs_getlbns and used by truncate and bmap code.
                    181:  */
                    182: struct indir {
1.8       cgd       183:        ufs_daddr_t in_lbn;             /* Logical block number. */
1.1       mycroft   184:        int     in_off;                 /* Offset in buffer. */
                    185:        int     in_exists;              /* Flag if the block exists. */
                    186: };
                    187:
                    188: /* Convert between inode pointers and vnode pointers. */
1.8       cgd       189: #define        VTOI(vp)        ((struct inode *)(vp)->v_data)
                    190: #define        ITOV(ip)        ((ip)->i_vnode)
1.1       mycroft   191:
1.10      bouyer    192: #define        FFS_ITIMES(ip, acc, mod, cre) {                                 \
                    193:        if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) {       \
                    194:                if ((ip)->i_flag & IN_ACCESS) {                         \
1.15      enami     195:                        (ip)->i_ffs_atime = (acc)->tv_sec;              \
1.10      bouyer    196:                        (ip)->i_ffs_atimensec = (acc)->tv_nsec;         \
1.18      mycroft   197:                        (ip)->i_flag |= IN_ACCESSED;                    \
1.10      bouyer    198:                }                                                       \
                    199:                if ((ip)->i_flag & IN_UPDATE) {                         \
1.15      enami     200:                        (ip)->i_ffs_mtime = (mod)->tv_sec;              \
1.10      bouyer    201:                        (ip)->i_ffs_mtimensec = (mod)->tv_nsec;         \
                    202:                        (ip)->i_modrev++;                               \
1.18      mycroft   203:                        (ip)->i_flag |= IN_MODIFIED;                    \
1.10      bouyer    204:                }                                                       \
                    205:                if ((ip)->i_flag & IN_CHANGE) {                         \
1.15      enami     206:                        (ip)->i_ffs_ctime = (cre)->tv_sec;              \
1.10      bouyer    207:                        (ip)->i_ffs_ctimensec = (cre)->tv_nsec;         \
1.18      mycroft   208:                        (ip)->i_flag |= IN_MODIFIED;                    \
1.10      bouyer    209:                }                                                       \
                    210:                (ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE);   \
                    211:        }                                                               \
                    212: }
                    213:
1.15      enami     214: #define        EXT2FS_ITIMES(ip, acc, mod, cre) {                              \
1.1       mycroft   215:        if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) {       \
1.9       mycroft   216:                if ((ip)->i_flag & IN_ACCESS) {                         \
1.15      enami     217:                        (ip)->i_e2fs_atime = (acc)->tv_sec;             \
1.19      mycroft   218:                        (ip)->i_flag |= IN_ACCESSED;                    \
1.9       mycroft   219:                }                                                       \
1.1       mycroft   220:                if ((ip)->i_flag & IN_UPDATE) {                         \
1.15      enami     221:                        (ip)->i_e2fs_mtime = (mod)->tv_sec;             \
1.1       mycroft   222:                        (ip)->i_modrev++;                               \
1.19      mycroft   223:                        (ip)->i_flag |= IN_MODIFIED;                    \
1.1       mycroft   224:                }                                                       \
1.9       mycroft   225:                if ((ip)->i_flag & IN_CHANGE) {                         \
1.15      enami     226:                        (ip)->i_e2fs_ctime = (cre)->tv_sec;             \
1.19      mycroft   227:                        (ip)->i_flag |= IN_MODIFIED;                    \
1.9       mycroft   228:                }                                                       \
1.1       mycroft   229:                (ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE);   \
                    230:        }                                                               \
1.10      bouyer    231: }
                    232:
1.15      enami     233: #define        ITIMES(ip, acc, mod, cre) {                     \
                    234:        if (IS_EXT2_VNODE((ip)->i_vnode))               \
                    235:                EXT2FS_ITIMES(ip, acc, mod, cre)        \
                    236:        else                                            \
                    237:                FFS_ITIMES(ip, acc, mod, cre)           \
1.1       mycroft   238: }
1.14      fvdl      239:
                    240: /* Determine if soft dependencies are being done */
1.15      enami     241: #define        DOINGSOFTDEP(vp)        ((vp)->v_mount->mnt_flag & MNT_SOFTDEP)
1.1       mycroft   242:
                    243: /* This overlays the fid structure (see mount.h). */
                    244: struct ufid {
1.5       mycroft   245:        u_int16_t ufid_len;     /* Length of structure. */
                    246:        u_int16_t ufid_pad;     /* Force 32-bit alignment. */
                    247:        ino_t     ufid_ino;     /* File number (ino). */
                    248:        int32_t   ufid_gen;     /* Generation number. */
1.1       mycroft   249: };
1.7       jtc       250: #endif /* _KERNEL */

CVSweb <webmaster@jp.NetBSD.org>