xref: /original-bsd/sys/ufs/ufs/inode.h (revision fbed46ce)
1 /*	inode.h	4.11	82/04/19	*/
2 
3 /*	inode.h	2.1	3/25/82	*/
4 
5 /*
6  * The I node is the focus of all file activity in UNIX.
7  * There is a unique inode allocated for each active file,
8  * each current directory, each mounted-on file, text file, and the root.
9  * An inode is 'named' by its dev/inumber pair. (iget/iget.c)
10  * Data in icommon is read in from permanent inode on volume.
11  */
12 
13 #define	NDADDR	8		/* direct addresses in inode */
14 #define	NIADDR	2		/* indirect addresses in inode */
15 
16 struct inode {
17 	char	i_flag;
18 	char	i_count;	/* reference count */
19 	dev_t	i_dev;		/* device where inode resides */
20 	ino_t	i_number;	/* i number, 1-to-1 with device address */
21 	long	i_hlink;	/* link in hash chain (iget/iput/ifind) */
22 	struct	fs *i_fs;	/* file sys associated with this inode */
23 	union {
24 		daddr_t	if_lastr;	/* last read (read-ahead) */
25 		struct	socket *is_socket;
26 	} i_un;
27 	struct 	icommon
28 	{
29 		u_short	ic_mode;	/*  0: mode and type of file */
30 		short	ic_nlink;	/*  2: number of links to file */
31 		short	ic_uid;		/*  4: owner's user id */
32 		short	ic_gid;		/*  6: owner's group id */
33 		off_t	ic_size;	/*  8: number of bytes in file */
34 		daddr_t	ic_db[NDADDR];	/* 12: disk block addresses */
35 		daddr_t	ic_ib[NIADDR];	/* 44: indirect blocks */
36 		time_t	ic_atime;	/* 52: time last accessed */
37 		time_t	ic_mtime;	/* 56: time last modified */
38 		time_t	ic_ctime;	/* 60: time created */
39 	} i_ic;
40 };
41 
42 struct dinode {
43 	union {
44 		struct	icommon di_icom;
45 		char	di_size[64];
46 	} di_un;
47 };
48 
49 #define	i_mode		i_ic.ic_mode
50 #define	i_nlink		i_ic.ic_nlink
51 #define	i_uid		i_ic.ic_uid
52 #define	i_gid		i_ic.ic_gid
53 #define	i_size		i_ic.ic_size
54 #define	i_db		i_ic.ic_db
55 #define	i_ib		i_ic.ic_ib
56 #define	i_atime		i_ic.ic_atime
57 #define	i_mtime		i_ic.ic_mtime
58 #define	i_ctime		i_ic.ic_ctime
59 #define	i_rdev		i_ic.ic_db[0]
60 #define	i_lastr		i_un.if_lastr
61 #define	i_socket	is_socket
62 
63 #define di_ic		di_un.di_icom
64 #define	di_mode		di_ic.ic_mode
65 #define	di_nlink	di_ic.ic_nlink
66 #define	di_uid		di_ic.ic_uid
67 #define	di_gid		di_ic.ic_gid
68 #define	di_size		di_ic.ic_size
69 #define	di_db		di_ic.ic_db
70 #define	di_ib		di_ic.ic_ib
71 #define	di_atime	di_ic.ic_atime
72 #define	di_mtime	di_ic.ic_mtime
73 #define	di_ctime	di_ic.ic_ctime
74 #define	di_rdev		di_ic.ic_db[0]
75 
76 #ifdef KERNEL
77 extern	struct inode *inode;		/* The inode table itself */
78 extern	struct inode *inodeNINODE;	/* The end of the inode table */
79 extern	int ninode;			/* number of slots in the table */
80 
81 struct	inode *rootdir;			/* pointer to inode of root directory */
82 
83 struct	inode *ialloc();
84 struct	inode *ifind();
85 struct	inode *iget();
86 struct	inode *owner();
87 struct	inode *maknode();
88 struct	inode *namei();
89 #endif
90 
91 /* flags */
92 #define	ILOCK	01		/* inode is locked */
93 #define	IUPD	02		/* file has been modified */
94 #define	IACC	04		/* inode access time to be updated */
95 #define	IMOUNT	010		/* inode is mounted on */
96 #define	IWANT	020		/* some process waiting on lock */
97 #define	ITEXT	040		/* inode is pure text prototype */
98 #define	ICHG	0100		/* inode has been changed */
99 
100 /* modes */
101 #define	IFMT		0170000		/* type of file */
102 #define	IFCHR		0020000		/* character special */
103 #define	IFDIR		0040000		/* directory */
104 #define	IFBLK		0060000		/* block special */
105 #define	IFREG		0100000		/* regular */
106 #define	IFLNK		0120000		/* symbolic link */
107 #define	IFPORTAL	0140000		/* portal */
108 #define	ISUID		04000		/* set user id on execution */
109 #define	ISGID		02000		/* set group id on execution */
110 #define	ISVTX		01000		/* save swapped text even after use */
111 #define	IREAD		0400		/* read, write, execute permissions */
112 #define	IWRITE		0200
113 #define	IEXEC		0100
114