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