xref: /original-bsd/sys/ufs/ffs/dinode.h (revision 13deef58)
1 /*
2  * Copyright (c) 1982, 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)dinode.h	7.18 (Berkeley) 06/24/92
8  */
9 
10 /*
11  * The root inode is the root of the file system.  Inode 0 can't be used for
12  * normal purposes and historically bad blocks were linked to inode 1, thus
13  * the root inode is 2.  (Inode 1 is no longer used for this purpose, however
14  * numerous dump tapes make this assumption, so we are stuck with it).
15  */
16 #define	ROOTINO	((ino_t)2)
17 
18 /*
19  * A dinode contains all the meta-data associated with a UFS file.
20  * This structure defines the on-disk format of a dinode.
21  */
22 
23 #define	NDADDR	12		/* direct addresses in inode */
24 #define	NIADDR	3		/* indirect addresses in inode */
25 
26 struct dinode {
27 	u_short		di_mode;	/*   0: mode and type of file */
28 	short		di_nlink;	/*   2: number of links to file */
29 	union {
30 		u_short	oldids[2];	/*   4: ffs: old user and group ids */
31 		ino_t	inumber;	/*   4: lfs: inode number */
32 	} di_u;
33 	u_quad_t	di_size;	/*   8: number of bytes in file */
34 	struct timespec	di_atime;	/*  16: time last accessed */
35 	struct timespec	di_mtime;	/*  24: time last modified */
36 	struct timespec	di_ctime;	/*  32: last time inode changed */
37 	daddr_t		di_db[NDADDR];	/*  40: disk block addresses */
38 	daddr_t		di_ib[NIADDR];	/*  88: indirect blocks */
39 	long		di_flags;	/* 100: status, currently unused */
40 	long		di_blocks;	/* 104: blocks actually held */
41 	long		di_gen;		/* 108: generation number */
42 	u_long		di_uid;		/* 112: owner's user id */
43 	u_long		di_gid;		/* 116: owner's group id */
44 	long		di_spare[2];	/* 120: reserved, currently unused */
45 };
46 
47 /*
48  * The di_db fields may be overlaid with other information for
49  * file types that do not have associated disk storage. Block
50  * and character devices overlay the first data block with their
51  * dev_t value. Short symbolic links place their path in the
52  * di_db area.
53  */
54 #define	di_ouid		di_u.oldids[0]
55 #define	di_ogid		di_u.oldids[1]
56 #define	di_inumber	di_u.inumber
57 #define	di_rdev		di_db[0]
58 #define di_shortlink	di_db
59 #define	MAXSYMLINKLEN	(NDADDR * sizeof(daddr_t))
60 
61 /* file modes */
62 #define	IFMT		0170000		/* mask of file type */
63 #define	IFIFO		0010000		/* named pipe (fifo) */
64 #define	IFCHR		0020000		/* character special device */
65 #define	IFDIR		0040000		/* directory */
66 #define	IFBLK		0060000		/* block special device */
67 #define	IFREG		0100000		/* regular file */
68 #define	IFLNK		0120000		/* symbolic link */
69 #define	IFSOCK		0140000		/* UNIX domain socket */
70 
71 #define	ISUID		04000		/* set user identifier when exec'ing */
72 #define	ISGID		02000		/* set group identifier when exec'ing */
73 #define	ISVTX		01000		/* save execution information on exit */
74 #define	IREAD		0400		/* read permission */
75 #define	IWRITE		0200		/* write permission */
76 #define	IEXEC		0100		/* execute permission */
77