xref: /csrg-svn/sys/ufs/ffs/dinode.h (revision 65774)
123419Smckusick /*
263376Sbostic  * Copyright (c) 1982, 1989, 1993
363376Sbostic  *	The Regents of the University of California.  All rights reserved.
4*65774Sbostic  * (c) UNIX System Laboratories, Inc.
5*65774Sbostic  * All or some portions of this file are derived from material licensed
6*65774Sbostic  * to the University of California by American Telephone and Telegraph
7*65774Sbostic  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8*65774Sbostic  * the permission of UNIX System Laboratories, Inc.
923419Smckusick  *
1044536Sbostic  * %sccs.include.redist.c%
1137714Smckusick  *
12*65774Sbostic  *	@(#)dinode.h	8.3 (Berkeley) 01/21/94
1323419Smckusick  */
1458Sbill 
1558Sbill /*
1651616Sbostic  * The root inode is the root of the file system.  Inode 0 can't be used for
1751616Sbostic  * normal purposes and historically bad blocks were linked to inode 1, thus
1851616Sbostic  * the root inode is 2.  (Inode 1 is no longer used for this purpose, however
1951616Sbostic  * numerous dump tapes make this assumption, so we are stuck with it).
2051616Sbostic  */
2151616Sbostic #define	ROOTINO	((ino_t)2)
2251616Sbostic 
2351616Sbostic /*
2449449Smckusick  * A dinode contains all the meta-data associated with a UFS file.
2549449Smckusick  * This structure defines the on-disk format of a dinode.
2658Sbill  */
2758Sbill 
2864513Sbostic #define	NDADDR	12			/* Direct addresses in inode. */
2964513Sbostic #define	NIADDR	3			/* Indirect addresses in inode. */
306565Smckusic 
316565Smckusic struct dinode {
3264513Sbostic 	u_short		di_mode;	/*   0: IFMT and permissions. */
3364513Sbostic 	short		di_nlink;	/*   2: File link count. */
3454373Smckusick 	union {
3564513Sbostic 		u_short	oldids[2];	/*   4: Ffs: old user and group ids. */
3664513Sbostic 		ino_t	inumber;	/*   4: Lfs: inode number. */
3754373Smckusick 	} di_u;
3864513Sbostic 	u_quad_t	di_size;	/*   8: File byte count. */
3964513Sbostic 	struct timespec	di_atime;	/*  16: Last access time. */
4064513Sbostic 	struct timespec	di_mtime;	/*  24: Last modified time. */
4164513Sbostic 	struct timespec	di_ctime;	/*  32: Last inode change time. */
4264513Sbostic 	daddr_t		di_db[NDADDR];	/*  40: Direct disk blocks. */
4364513Sbostic 	daddr_t		di_ib[NIADDR];	/*  88: Indirect disk blocks. */
4464513Sbostic 	u_long		di_flags;	/* 100: Status flags (chflags). */
4564513Sbostic 	long		di_blocks;	/* 104: Blocks actually held. */
4664513Sbostic 	long		di_gen;		/* 108: Generation number. */
4764513Sbostic 	u_long		di_uid;		/* 112: File owner. */
4864513Sbostic 	u_long		di_gid;		/* 116: File group. */
4964513Sbostic 	long		di_spare[2];	/* 120: Reserved; currently unused */
506565Smckusic };
516565Smckusic 
5254301Smckusick /*
5354301Smckusick  * The di_db fields may be overlaid with other information for
5454301Smckusick  * file types that do not have associated disk storage. Block
5554301Smckusick  * and character devices overlay the first data block with their
5654301Smckusick  * dev_t value. Short symbolic links place their path in the
5754301Smckusick  * di_db area.
5854301Smckusick  */
5964513Sbostic #define	di_inumber	di_u.inumber
6064513Sbostic #define	di_ogid		di_u.oldids[1]
6154373Smckusick #define	di_ouid		di_u.oldids[0]
6239386Smckusick #define	di_rdev		di_db[0]
6364513Sbostic #define	di_shortlink	di_db
6456668Smckusick #define	MAXSYMLINKLEN	((NDADDR + NIADDR) * sizeof(daddr_t))
656565Smckusic 
6664513Sbostic /* File modes. */
6764513Sbostic #define	IEXEC		0000100		/* Executable. */
6864513Sbostic #define	IWRITE		0000200		/* Writeable. */
6964513Sbostic #define	IREAD		0000400		/* Readable. */
7064513Sbostic #define	ISVTX		0001000		/* Sticky bit. */
7164513Sbostic #define	ISGID		0002000		/* Set-gid. */
7264513Sbostic #define	ISUID		0004000		/* Set-uid. */
738990Sroot 
7464513Sbostic /* File types. */
7564513Sbostic #define	IFMT		0170000		/* Mask of file type. */
7664513Sbostic #define	IFIFO		0010000		/* Named pipe (fifo). */
7764513Sbostic #define	IFCHR		0020000		/* Character device. */
7864513Sbostic #define	IFDIR		0040000		/* Directory file. */
7964513Sbostic #define	IFBLK		0060000		/* Block device. */
8064513Sbostic #define	IFREG		0100000		/* Regular file. */
8164513Sbostic #define	IFLNK		0120000		/* Symbolic link. */
8264513Sbostic #define	IFSOCK		0140000		/* UNIX domain socket. */
83