xref: /original-bsd/sys/ufs/ufs/dinode.h (revision 1f3a482a)
1 /*	dinode.h	4.6	81/06/15	*/
2 
3 /*
4  * The I node is the focus of all
5  * file activity in unix. There is a unique
6  * inode allocated for each active file,
7  * each current directory, each mounted-on
8  * file, text file, and the root. An inode is 'named'
9  * by its dev/inumber pair. (iget/iget.c)
10  * Data, from mode on, is read in
11  * from permanent inode on volume.
12  */
13 
14 #define	NADDR	13
15 
16 #define	NINDEX		6
17 struct group
18 {
19 	short	g_state;
20 	char	g_index;
21 	char	g_rot;
22 	struct	group	*g_group;
23 	struct	inode	*g_inode;
24 	struct	file	*g_file;
25 	short	g_rotmask;
26 	short	g_datq;
27 	struct	chan *g_chans[NINDEX];
28 };
29 struct	inode
30 {
31 	char	i_flag;
32 	char	i_count;	/* reference count */
33 	dev_t	i_dev;		/* device where inode resides */
34 	ino_t	i_number;	/* i number, 1-to-1 with device address */
35 	unsigned short i_mode;
36 	short	i_nlink;	/* directory entries */
37 	short	i_uid;		/* owner */
38 	short	i_gid;		/* group of owner */
39 	off_t	i_size;		/* size of file */
40 	union {
41 		struct {
42 			daddr_t	I_addr[NADDR];	/* if normal file/directory */
43 			daddr_t	I_lastr;	/* last read (for read-ahead) */
44 		} i_f;
45 #define	i_addr	i_f.I_addr
46 #define	i_lastr	i_f.I_lastr
47 		struct {
48 			daddr_t	I_rdev;		/* i_addr[0] */
49 			struct	group I_group;	/* multiplexor group file */
50 		} i_d;
51 #define	i_rdev	i_d.I_rdev
52 #define	i_group	i_d.I_group
53 		struct {
54 			daddr_t	I_port0;	/* low 16 bits of portid */
55 			daddr_t	I_port1;	/* high 16 bits of portid */
56 		} i_p;
57 #define	i_port0	i_p.I_port0
58 #define	i_port1	i_p.I_port1
59 	} i_un;
60 	short	i_vfdcnt;	/* number of fd's vreading this inode */
61 	short	i_hlink;	/* link in hash chain (iget/iput/ifind) */
62 };
63 
64 #ifdef KERNEL
65 struct	inode *inode, *inodeNINODE;
66 int	ninode;
67 
68 struct	inode *rootdir;		/* pointer to inode of root directory */
69 struct	inode *mpxip;		/* mpx virtual inode */
70 
71 struct	inode *ialloc();
72 struct	inode *ifind();
73 struct	inode *iget();
74 struct	inode *owner();
75 struct	inode *maknode();
76 struct	inode *namei();
77 #endif
78 
79 /* flags */
80 #define	ILOCK	01		/* inode is locked */
81 #define	IUPD	02		/* file has been modified */
82 #define	IACC	04		/* inode access time to be updated */
83 #define	IMOUNT	010		/* inode is mounted on */
84 #define	IWANT	020		/* some process waiting on lock */
85 #define	ITEXT	040		/* inode is pure text prototype */
86 #define	ICHG	0100		/* inode has been changed */
87 #define	IPIPE	0200		/* inode is a pipe */
88 
89 /* modes */
90 #define	IFMT	0170000		/* type of file */
91 #define		IFDIR	0040000	/* directory */
92 #define		IFCHR	0020000	/* character special */
93 #define		IFBLK	0060000	/* block special */
94 #define		IFREG	0100000	/* regular */
95 #define		IFPORT	0010000	/* named port */
96 #define		IFMPC	0030000	/* multiplexed char special */
97 #define		IFMPB	0070000	/* multiplexed block special */
98 #define	ISUID	04000		/* set user id on execution */
99 #define	ISGID	02000		/* set group id on execution */
100 #define	ISVTX	01000		/* save swapped text even after use */
101 #define	IREAD	0400		/* read, write, execute permissions */
102 #define	IWRITE	0200
103 #define	IEXEC	0100
104