123419Smckusick /* 237714Smckusick * Copyright (c) 1982, 1989 The Regents of the University of California. 337714Smckusick * All rights reserved. 423419Smckusick * 544536Sbostic * %sccs.include.redist.c% 637714Smckusick * 7*54301Smckusick * @(#)dinode.h 7.17 (Berkeley) 06/23/92 823419Smckusick */ 958Sbill 1058Sbill /* 1151616Sbostic * The root inode is the root of the file system. Inode 0 can't be used for 1251616Sbostic * normal purposes and historically bad blocks were linked to inode 1, thus 1351616Sbostic * the root inode is 2. (Inode 1 is no longer used for this purpose, however 1451616Sbostic * numerous dump tapes make this assumption, so we are stuck with it). 1551616Sbostic */ 1651616Sbostic #define ROOTINO ((ino_t)2) 1751616Sbostic 1851616Sbostic /* 1949449Smckusick * A dinode contains all the meta-data associated with a UFS file. 2049449Smckusick * This structure defines the on-disk format of a dinode. 2158Sbill */ 2258Sbill 239182Ssam #define NDADDR 12 /* direct addresses in inode */ 249182Ssam #define NIADDR 3 /* indirect addresses in inode */ 256565Smckusic 266565Smckusic struct dinode { 2753473Smckusick u_short di_mode; /* 0: mode and type of file */ 2853473Smckusick short di_nlink; /* 2: number of links to file */ 2953473Smckusick u_short di_ouid; /* 4: old owner's user id */ 3053473Smckusick u_short di_ogid; /* 6: old owner's group id */ 3154126Smckusick u_quad_t di_size; /* 8: number of bytes in file */ 3254063Smckusick struct timespec di_atime; /* 16: time last accessed */ 3354063Smckusick struct timespec di_mtime; /* 24: time last modified */ 3454063Smckusick struct timespec di_ctime; /* 32: last time inode changed */ 3553473Smckusick daddr_t di_db[NDADDR]; /* 40: disk block addresses */ 3653473Smckusick daddr_t di_ib[NIADDR]; /* 88: indirect blocks */ 3753473Smckusick long di_flags; /* 100: status, currently unused */ 3853473Smckusick long di_blocks; /* 104: blocks actually held */ 3953473Smckusick long di_gen; /* 108: generation number */ 4053473Smckusick u_long di_uid; /* 112: owner's user id */ 4153473Smckusick u_long di_gid; /* 116: owner's group id */ 4253473Smckusick long di_spare[2]; /* 120: reserved, currently unused */ 436565Smckusic }; 446565Smckusic 45*54301Smckusick /* 46*54301Smckusick * The di_db fields may be overlaid with other information for 47*54301Smckusick * file types that do not have associated disk storage. Block 48*54301Smckusick * and character devices overlay the first data block with their 49*54301Smckusick * dev_t value. Short symbolic links place their path in the 50*54301Smckusick * di_db area. 51*54301Smckusick */ 5239386Smckusick #define di_rdev di_db[0] 53*54301Smckusick #define di_shortlink di_db 54*54301Smckusick #define MAXSYMLINKLEN (NDADDR * sizeof(daddr_t)) 556565Smckusic 5639386Smckusick /* file modes */ 5749449Smckusick #define IFMT 0170000 /* mask of file type */ 5840288Smckusick #define IFIFO 0010000 /* named pipe (fifo) */ 5949449Smckusick #define IFCHR 0020000 /* character special device */ 606565Smckusic #define IFDIR 0040000 /* directory */ 6149449Smckusick #define IFBLK 0060000 /* block special device */ 6249449Smckusick #define IFREG 0100000 /* regular file */ 636565Smckusic #define IFLNK 0120000 /* symbolic link */ 6449449Smckusick #define IFSOCK 0140000 /* UNIX domain socket */ 658990Sroot 6649449Smckusick #define ISUID 04000 /* set user identifier when exec'ing */ 6749449Smckusick #define ISGID 02000 /* set group identifier when exec'ing */ 6849449Smckusick #define ISVTX 01000 /* save execution information on exit */ 6949449Smckusick #define IREAD 0400 /* read permission */ 7049449Smckusick #define IWRITE 0200 /* write permission */ 7149449Smckusick #define IEXEC 0100 /* execute permission */ 72