xref: /csrg-svn/sys/ufs/ffs/inode.h (revision 224)
1*224Sbill /*	inode.h	3.5	10/14/12	*/
258Sbill 
358Sbill /*
458Sbill  * The I node is the focus of all
558Sbill  * file activity in unix. There is a unique
658Sbill  * inode allocated for each active file,
758Sbill  * each current directory, each mounted-on
858Sbill  * file, text file, and the root. An inode is 'named'
958Sbill  * by its dev/inumber pair. (iget/iget.c)
1058Sbill  * Data, from mode on, is read in
1158Sbill  * from permanent inode on volume.
1258Sbill  */
1358Sbill 
1458Sbill #define	NADDR	13
1558Sbill 
1658Sbill #define	NINDEX		15
1758Sbill struct group
1858Sbill {
1958Sbill 	short	g_state;
2058Sbill 	char	g_index;
2158Sbill 	char	g_rot;
2258Sbill 	struct	group	*g_group;
2358Sbill 	struct	inode	*g_inode;
2458Sbill 	struct	file	*g_file;
2558Sbill 	short	g_rotmask;
2658Sbill 	short	g_datq;
2758Sbill 	struct	chan *g_chans[NINDEX];
2858Sbill };
2958Sbill struct	inode
3058Sbill {
3158Sbill 	char	i_flag;
3258Sbill 	char	i_count;	/* reference count */
3358Sbill 	dev_t	i_dev;		/* device where inode resides */
3458Sbill 	ino_t	i_number;	/* i number, 1-to-1 with device address */
3558Sbill 	unsigned short i_mode;
3658Sbill 	short	i_nlink;	/* directory entries */
3758Sbill 	short	i_uid;		/* owner */
3858Sbill 	short	i_gid;		/* group of owner */
3958Sbill 	off_t	i_size;		/* size of file */
4058Sbill 	union {
4158Sbill 		struct {
42109Sbill 			daddr_t	I_addr[NADDR];	/* if normal file/directory */
43*224Sbill 			daddr_t	I_lastr;	/* last read (for read-ahead) */
44109Sbill 		} i_f;
45109Sbill #define	i_addr	i_f.I_addr
46109Sbill #define	i_lastr	i_f.I_lastr
4758Sbill 		struct {
48109Sbill 			daddr_t	I_rdev;		/* i_addr[0] */
49109Sbill 			struct	group I_group;	/* multiplexor group file */
50109Sbill 		} i_d;
51109Sbill #define	i_rdev	i_d.I_rdev
52109Sbill #define	i_group	i_d.I_group
5358Sbill 	} i_un;
5458Sbill 	short	i_vfdcnt;	/* number of fd's vreading this inode */
5558Sbill 	short	i_hlink;	/* link in hash chain (iget/iput/ifind) */
5658Sbill };
5758Sbill 
5858Sbill #ifdef KERNEL
5958Sbill extern	struct inode inode[];	/* The inode table itself */
6058Sbill 
6158Sbill struct	inode *rootdir;		/* pointer to inode of root directory */
6258Sbill struct	inode *mpxip;		/* mpx virtual inode */
6358Sbill 
6458Sbill struct	inode *ialloc();
6558Sbill struct	inode *ifind();
6658Sbill struct	inode *iget();
6758Sbill struct	inode *owner();
6858Sbill struct	inode *maknode();
6958Sbill struct	inode *namei();
7058Sbill #endif
7158Sbill 
7258Sbill /* flags */
7358Sbill #define	ILOCK	01		/* inode is locked */
7458Sbill #define	IUPD	02		/* file has been modified */
7558Sbill #define	IACC	04		/* inode access time to be updated */
7658Sbill #define	IMOUNT	010		/* inode is mounted on */
7758Sbill #define	IWANT	020		/* some process waiting on lock */
7858Sbill #define	ITEXT	040		/* inode is pure text prototype */
7958Sbill #define	ICHG	0100		/* inode has been changed */
8084Sbill #define	IPIPE	0200		/* inode is a pipe */
8158Sbill 
8258Sbill /* modes */
8358Sbill #define	IFMT	0170000		/* type of file */
8458Sbill #define		IFDIR	0040000	/* directory */
8558Sbill #define		IFCHR	0020000	/* character special */
8658Sbill #define		IFBLK	0060000	/* block special */
8758Sbill #define		IFREG	0100000	/* regular */
8858Sbill #define		IFMPC	0030000	/* multiplexed char special */
8958Sbill #define		IFMPB	0070000	/* multiplexed block special */
9058Sbill #define	ISUID	04000		/* set user id on execution */
9158Sbill #define	ISGID	02000		/* set group id on execution */
9258Sbill #define	ISVTX	01000		/* save swapped text even after use */
9358Sbill #define	IREAD	0400		/* read, write, execute permissions */
9458Sbill #define	IWRITE	0200
9558Sbill #define	IEXEC	0100
96