Inode

From Hackepedia
Jump to: navigation, search

The inode is the node of the index of files on a filesystem. In UFS1 the inode size is 128 bytes, and in UFS2 it is 256 bytes. The inode is what's considered to be filesystem metadata, it points to real data of a file.


The inode contains the following fields (from /usr/include/ufs/ufs/dinode.h):

struct  ufs1_dinode {
       u_int16_t       di_mode;        /*   0: IFMT, permissions; see below. */
       int16_t         di_nlink;       /*   2: File link count. */
       union {
               u_int16_t oldids[2];    /*   4: Ffs: old user and group ids. */
               u_int32_t inumber;      /*   4: Lfs: inode number. */
       } di_u;
       u_int64_t       di_size;        /*   8: File byte count. */
       int32_t         di_atime;       /*  16: Last access time. */
       int32_t         di_atimensec;   /*  20: Last access time. */
       int32_t         di_mtime;       /*  24: Last modified time. */
       int32_t         di_mtimensec;   /*  28: Last modified time. */
       int32_t         di_ctime;       /*  32: Last inode change time. */
       int32_t         di_ctimensec;   /*  36: Last inode change time. */
       ufs1_daddr_t    di_db[NDADDR];  /*  40: Direct disk blocks. */
       ufs1_daddr_t    di_ib[NIADDR];  /*  88: Indirect disk blocks. */
       u_int32_t       di_flags;       /* 100: Status flags (chflags). */
       int32_t         di_blocks;      /* 104: Blocks actually held. */
       int32_t         di_gen;         /* 108: Generation number. */
       u_int32_t       di_uid;         /* 112: File owner. */
       u_int32_t       di_gid;         /* 116: File group. */
       int32_t         di_spare[2];    /* 120: Reserved; currently unused */
};


For further reading see permissions, atime, mtime, ctime.