xref: /original-bsd/sys/ufs/ufs/dinode.h (revision 58070cba)
1449c849fSmckusick /*
276403e9cSbostic  * Copyright (c) 1982, 1989, 1993
376403e9cSbostic  *	The Regents of the University of California.  All rights reserved.
4a257ce37Sbostic  * (c) UNIX System Laboratories, Inc.
5a257ce37Sbostic  * All or some portions of this file are derived from material licensed
6a257ce37Sbostic  * to the University of California by American Telephone and Telegraph
7a257ce37Sbostic  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8a257ce37Sbostic  * the permission of UNIX System Laboratories, Inc.
9449c849fSmckusick  *
1088f5dc9aSbostic  * %sccs.include.redist.c%
118177e537Smckusick  *
12*58070cbaSmckusick  *	@(#)dinode.h	8.9 (Berkeley) 03/29/95
13449c849fSmckusick  */
14876480d6Sbill 
15876480d6Sbill /*
16bdbadaa0Sbostic  * The root inode is the root of the file system.  Inode 0 can't be used for
17bdbadaa0Sbostic  * normal purposes and historically bad blocks were linked to inode 1, thus
18bdbadaa0Sbostic  * the root inode is 2.  (Inode 1 is no longer used for this purpose, however
19bdbadaa0Sbostic  * numerous dump tapes make this assumption, so we are stuck with it).
20bdbadaa0Sbostic  */
21bdbadaa0Sbostic #define	ROOTINO	((ino_t)2)
22bdbadaa0Sbostic 
23bdbadaa0Sbostic /*
240261928aSpendry  * The Whiteout inode# is a dummy non-zero inode number which will
250261928aSpendry  * never be allocated to a real file.  It is used as a place holder
260261928aSpendry  * in the directory entry which has been tagged as a DT_W entry.
270261928aSpendry  * See the comments about ROOTINO above.
280261928aSpendry  */
290261928aSpendry #define	WINO	((ino_t)1)
300261928aSpendry 
310261928aSpendry /*
32f43f6c4aSmckusick  * A dinode contains all the meta-data associated with a UFS file.
33153c4484Smckusick  * This structure defines the on-disk format of a dinode. Since
34153c4484Smckusick  * this structure describes an on-disk structure, all its fields
35153c4484Smckusick  * are defined by types with precise widths.
36876480d6Sbill  */
373f558a57Smckusic 
38153c4484Smckusick typedef int32_t ufs_daddr_t;
392f347998Sbostic #define	NDADDR	12			/* Direct addresses in inode. */
402f347998Sbostic #define	NIADDR	3			/* Indirect addresses in inode. */
41876480d6Sbill 
423f558a57Smckusic struct dinode {
43c1c54f2aSmckusick 	u_int16_t	di_mode;	/*   0: IFMT, permissions; see below. */
44c1c54f2aSmckusick 	int16_t		di_nlink;	/*   2: File link count. */
45f6d1d0afSmckusick 	union {
46c1c54f2aSmckusick 		u_int16_t oldids[2];	/*   4: Ffs: old user and group ids. */
47153c4484Smckusick 		int32_t	  inumber;	/*   4: Lfs: inode number. */
48f6d1d0afSmckusick 	} di_u;
49478369f5Smckusick 	u_int64_t	di_size;	/*   8: File byte count. */
50153c4484Smckusick 	int32_t		di_atime;	/*  16: Last access time. */
51153c4484Smckusick 	int32_t		di_atimensec;	/*  20: Last access time. */
52153c4484Smckusick 	int32_t		di_mtime;	/*  24: Last modified time. */
53153c4484Smckusick 	int32_t		di_mtimensec;	/*  28: Last modified time. */
54153c4484Smckusick 	int32_t		di_ctime;	/*  32: Last inode change time. */
55153c4484Smckusick 	int32_t		di_ctimensec;	/*  36: Last inode change time. */
56153c4484Smckusick 	ufs_daddr_t	di_db[NDADDR];	/*  40: Direct disk blocks. */
57153c4484Smckusick 	ufs_daddr_t	di_ib[NIADDR];	/*  88: Indirect disk blocks. */
58c1c54f2aSmckusick 	u_int32_t	di_flags;	/* 100: Status flags (chflags). */
59*58070cbaSmckusick 	u_int32_t	di_blocks;	/* 104: Blocks actually held. */
60c1c54f2aSmckusick 	int32_t		di_gen;		/* 108: Generation number. */
61c1c54f2aSmckusick 	u_int32_t	di_uid;		/* 112: File owner. */
62c1c54f2aSmckusick 	u_int32_t	di_gid;		/* 116: File group. */
63c1c54f2aSmckusick 	int32_t		di_spare[2];	/* 120: Reserved; currently unused */
643f558a57Smckusic };
653f558a57Smckusic 
6612385100Smckusick /*
6712385100Smckusick  * The di_db fields may be overlaid with other information for
6812385100Smckusick  * file types that do not have associated disk storage. Block
6912385100Smckusick  * and character devices overlay the first data block with their
7012385100Smckusick  * dev_t value. Short symbolic links place their path in the
7112385100Smckusick  * di_db area.
7212385100Smckusick  */
73f6d1d0afSmckusick #define	di_inumber	di_u.inumber
742f347998Sbostic #define	di_ogid		di_u.oldids[1]
752f347998Sbostic #define	di_ouid		di_u.oldids[0]
76ed5dc773Smckusick #define	di_rdev		di_db[0]
7712385100Smckusick #define	di_shortlink	di_db
78153c4484Smckusick #define	MAXSYMLINKLEN	((NDADDR + NIADDR) * sizeof(ufs_daddr_t))
793f558a57Smckusic 
80c1c54f2aSmckusick /* File permissions. */
812f347998Sbostic #define	IEXEC		0000100		/* Executable. */
822f347998Sbostic #define	IWRITE		0000200		/* Writeable. */
832f347998Sbostic #define	IREAD		0000400		/* Readable. */
842f347998Sbostic #define	ISVTX		0001000		/* Sticky bit. */
852f347998Sbostic #define	ISGID		0002000		/* Set-gid. */
862f347998Sbostic #define	ISUID		0004000		/* Set-uid. */
87e10ef072Sroot 
882f347998Sbostic /* File types. */
892f347998Sbostic #define	IFMT		0170000		/* Mask of file type. */
902f347998Sbostic #define	IFIFO		0010000		/* Named pipe (fifo). */
912f347998Sbostic #define	IFCHR		0020000		/* Character device. */
922f347998Sbostic #define	IFDIR		0040000		/* Directory file. */
932f347998Sbostic #define	IFBLK		0060000		/* Block device. */
942f347998Sbostic #define	IFREG		0100000		/* Regular file. */
952f347998Sbostic #define	IFLNK		0120000		/* Symbolic link. */
962f347998Sbostic #define	IFSOCK		0140000		/* UNIX domain socket. */
977f61976cSmckusick #define	IFWHT		0160000		/* Whiteout. */
98