xref: /illumos-gate/usr/src/boot/include/ufs/ufs/dinode.h (revision 199767f8)
1*199767f8SToomas Soome /*-
2*199767f8SToomas Soome  * Copyright (c) 2002 Networks Associates Technology, Inc.
3*199767f8SToomas Soome  * All rights reserved.
4*199767f8SToomas Soome  *
5*199767f8SToomas Soome  * This software was developed for the FreeBSD Project by Marshall
6*199767f8SToomas Soome  * Kirk McKusick and Network Associates Laboratories, the Security
7*199767f8SToomas Soome  * Research Division of Network Associates, Inc. under DARPA/SPAWAR
8*199767f8SToomas Soome  * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS
9*199767f8SToomas Soome  * research program
10*199767f8SToomas Soome  *
11*199767f8SToomas Soome  * Redistribution and use in source and binary forms, with or without
12*199767f8SToomas Soome  * modification, are permitted provided that the following conditions
13*199767f8SToomas Soome  * are met:
14*199767f8SToomas Soome  * 1. Redistributions of source code must retain the above copyright
15*199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer.
16*199767f8SToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
17*199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer in the
18*199767f8SToomas Soome  *    documentation and/or other materials provided with the distribution.
19*199767f8SToomas Soome  *
20*199767f8SToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21*199767f8SToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22*199767f8SToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23*199767f8SToomas Soome  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24*199767f8SToomas Soome  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25*199767f8SToomas Soome  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26*199767f8SToomas Soome  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27*199767f8SToomas Soome  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28*199767f8SToomas Soome  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29*199767f8SToomas Soome  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30*199767f8SToomas Soome  * SUCH DAMAGE.
31*199767f8SToomas Soome  *
32*199767f8SToomas Soome  * Copyright (c) 1982, 1989, 1993
33*199767f8SToomas Soome  *	The Regents of the University of California.  All rights reserved.
34*199767f8SToomas Soome  * (c) UNIX System Laboratories, Inc.
35*199767f8SToomas Soome  * All or some portions of this file are derived from material licensed
36*199767f8SToomas Soome  * to the University of California by American Telephone and Telegraph
37*199767f8SToomas Soome  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
38*199767f8SToomas Soome  * the permission of UNIX System Laboratories, Inc.
39*199767f8SToomas Soome  *
40*199767f8SToomas Soome  * Redistribution and use in source and binary forms, with or without
41*199767f8SToomas Soome  * modification, are permitted provided that the following conditions
42*199767f8SToomas Soome  * are met:
43*199767f8SToomas Soome  * 1. Redistributions of source code must retain the above copyright
44*199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer.
45*199767f8SToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
46*199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer in the
47*199767f8SToomas Soome  *    documentation and/or other materials provided with the distribution.
48*199767f8SToomas Soome  * 3. The names of the authors may not be used to endorse or promote
49*199767f8SToomas Soome  *    products derived from this software without specific prior written
50*199767f8SToomas Soome  *    permission.
51*199767f8SToomas Soome  *
52*199767f8SToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
53*199767f8SToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54*199767f8SToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55*199767f8SToomas Soome  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
56*199767f8SToomas Soome  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57*199767f8SToomas Soome  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58*199767f8SToomas Soome  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59*199767f8SToomas Soome  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60*199767f8SToomas Soome  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61*199767f8SToomas Soome  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62*199767f8SToomas Soome  * SUCH DAMAGE.
63*199767f8SToomas Soome  *
64*199767f8SToomas Soome  *	@(#)dinode.h	8.3 (Berkeley) 1/21/94
65*199767f8SToomas Soome  * $FreeBSD$
66*199767f8SToomas Soome  */
67*199767f8SToomas Soome 
68*199767f8SToomas Soome #ifndef _UFS_UFS_DINODE_H_
69*199767f8SToomas Soome #define	_UFS_UFS_DINODE_H_
70*199767f8SToomas Soome 
71*199767f8SToomas Soome /*
72*199767f8SToomas Soome  * The root inode is the root of the filesystem.  Inode 0 can't be used for
73*199767f8SToomas Soome  * normal purposes and historically bad blocks were linked to inode 1, thus
74*199767f8SToomas Soome  * the root inode is 2.  (Inode 1 is no longer used for this purpose, however
75*199767f8SToomas Soome  * numerous dump tapes make this assumption, so we are stuck with it).
76*199767f8SToomas Soome  */
77*199767f8SToomas Soome #define	ROOTINO	((ino_t)2)
78*199767f8SToomas Soome 
79*199767f8SToomas Soome /*
80*199767f8SToomas Soome  * The Whiteout inode# is a dummy non-zero inode number which will
81*199767f8SToomas Soome  * never be allocated to a real file.  It is used as a place holder
82*199767f8SToomas Soome  * in the directory entry which has been tagged as a DT_WHT entry.
83*199767f8SToomas Soome  * See the comments about ROOTINO above.
84*199767f8SToomas Soome  */
85*199767f8SToomas Soome #define	WINO	((ino_t)1)
86*199767f8SToomas Soome 
87*199767f8SToomas Soome /*
88*199767f8SToomas Soome  * The size of physical and logical block numbers and time fields in UFS.
89*199767f8SToomas Soome  */
90*199767f8SToomas Soome typedef	int32_t	ufs1_daddr_t;
91*199767f8SToomas Soome typedef	int64_t	ufs2_daddr_t;
92*199767f8SToomas Soome typedef int64_t ufs_lbn_t;
93*199767f8SToomas Soome typedef int64_t ufs_time_t;
94*199767f8SToomas Soome 
95*199767f8SToomas Soome /* File permissions. */
96*199767f8SToomas Soome #define	IEXEC		0000100		/* Executable. */
97*199767f8SToomas Soome #define	IWRITE		0000200		/* Writeable. */
98*199767f8SToomas Soome #define	IREAD		0000400		/* Readable. */
99*199767f8SToomas Soome #define	ISVTX		0001000		/* Sticky bit. */
100*199767f8SToomas Soome #define	ISGID		0002000		/* Set-gid. */
101*199767f8SToomas Soome #define	ISUID		0004000		/* Set-uid. */
102*199767f8SToomas Soome 
103*199767f8SToomas Soome /* File types. */
104*199767f8SToomas Soome #define	IFMT		0170000		/* Mask of file type. */
105*199767f8SToomas Soome #define	IFIFO		0010000		/* Named pipe (fifo). */
106*199767f8SToomas Soome #define	IFCHR		0020000		/* Character device. */
107*199767f8SToomas Soome #define	IFDIR		0040000		/* Directory file. */
108*199767f8SToomas Soome #define	IFBLK		0060000		/* Block device. */
109*199767f8SToomas Soome #define	IFREG		0100000		/* Regular file. */
110*199767f8SToomas Soome #define	IFLNK		0120000		/* Symbolic link. */
111*199767f8SToomas Soome #define	IFSOCK		0140000		/* UNIX domain socket. */
112*199767f8SToomas Soome #define	IFWHT		0160000		/* Whiteout. */
113*199767f8SToomas Soome 
114*199767f8SToomas Soome /*
115*199767f8SToomas Soome  * A dinode contains all the meta-data associated with a UFS2 file.
116*199767f8SToomas Soome  * This structure defines the on-disk format of a dinode. Since
117*199767f8SToomas Soome  * this structure describes an on-disk structure, all its fields
118*199767f8SToomas Soome  * are defined by types with precise widths.
119*199767f8SToomas Soome  */
120*199767f8SToomas Soome 
121*199767f8SToomas Soome #define	NXADDR	2			/* External addresses in inode. */
122*199767f8SToomas Soome #define	NDADDR	12			/* Direct addresses in inode. */
123*199767f8SToomas Soome #define	NIADDR	3			/* Indirect addresses in inode. */
124*199767f8SToomas Soome 
125*199767f8SToomas Soome struct ufs2_dinode {
126*199767f8SToomas Soome 	u_int16_t	di_mode;	/*   0: IFMT, permissions; see below. */
127*199767f8SToomas Soome 	int16_t		di_nlink;	/*   2: File link count. */
128*199767f8SToomas Soome 	u_int32_t	di_uid;		/*   4: File owner. */
129*199767f8SToomas Soome 	u_int32_t	di_gid;		/*   8: File group. */
130*199767f8SToomas Soome 	u_int32_t	di_blksize;	/*  12: Inode blocksize. */
131*199767f8SToomas Soome 	u_int64_t	di_size;	/*  16: File byte count. */
132*199767f8SToomas Soome 	u_int64_t	di_blocks;	/*  24: Blocks actually held. */
133*199767f8SToomas Soome 	ufs_time_t	di_atime;	/*  32: Last access time. */
134*199767f8SToomas Soome 	ufs_time_t	di_mtime;	/*  40: Last modified time. */
135*199767f8SToomas Soome 	ufs_time_t	di_ctime;	/*  48: Last inode change time. */
136*199767f8SToomas Soome 	ufs_time_t	di_birthtime;	/*  56: Inode creation time. */
137*199767f8SToomas Soome 	int32_t		di_mtimensec;	/*  64: Last modified time. */
138*199767f8SToomas Soome 	int32_t		di_atimensec;	/*  68: Last access time. */
139*199767f8SToomas Soome 	int32_t		di_ctimensec;	/*  72: Last inode change time. */
140*199767f8SToomas Soome 	int32_t		di_birthnsec;	/*  76: Inode creation time. */
141*199767f8SToomas Soome 	u_int32_t	di_gen;		/*  80: Generation number. */
142*199767f8SToomas Soome 	u_int32_t	di_kernflags;	/*  84: Kernel flags. */
143*199767f8SToomas Soome 	u_int32_t	di_flags;	/*  88: Status flags (chflags). */
144*199767f8SToomas Soome 	u_int32_t	di_extsize;	/*  92: External attributes size. */
145*199767f8SToomas Soome 	ufs2_daddr_t	di_extb[NXADDR];/*  96: External attributes block. */
146*199767f8SToomas Soome 	ufs2_daddr_t	di_db[NDADDR];	/* 112: Direct disk blocks. */
147*199767f8SToomas Soome 	ufs2_daddr_t	di_ib[NIADDR];	/* 208: Indirect disk blocks. */
148*199767f8SToomas Soome 	u_int64_t	di_modrev;	/* 232: i_modrev for NFSv4 */
149*199767f8SToomas Soome 	uint32_t	di_freelink;	/* 240: SUJ: Next unlinked inode. */
150*199767f8SToomas Soome 	uint32_t	di_spare[3];	/* 244: Reserved; currently unused */
151*199767f8SToomas Soome };
152*199767f8SToomas Soome 
153*199767f8SToomas Soome /*
154*199767f8SToomas Soome  * The di_db fields may be overlaid with other information for
155*199767f8SToomas Soome  * file types that do not have associated disk storage. Block
156*199767f8SToomas Soome  * and character devices overlay the first data block with their
157*199767f8SToomas Soome  * dev_t value. Short symbolic links place their path in the
158*199767f8SToomas Soome  * di_db area.
159*199767f8SToomas Soome  */
160*199767f8SToomas Soome #define	di_rdev di_db[0]
161*199767f8SToomas Soome 
162*199767f8SToomas Soome /*
163*199767f8SToomas Soome  * A UFS1 dinode contains all the meta-data associated with a UFS1 file.
164*199767f8SToomas Soome  * This structure defines the on-disk format of a UFS1 dinode. Since
165*199767f8SToomas Soome  * this structure describes an on-disk structure, all its fields
166*199767f8SToomas Soome  * are defined by types with precise widths.
167*199767f8SToomas Soome  */
168*199767f8SToomas Soome struct ufs1_dinode {
169*199767f8SToomas Soome 	u_int16_t	di_mode;	/*   0: IFMT, permissions; see below. */
170*199767f8SToomas Soome 	int16_t		di_nlink;	/*   2: File link count. */
171*199767f8SToomas Soome 	u_int16_t	di_suid;	/*   4: File owner. */
172*199767f8SToomas Soome 	u_int16_t	di_sgid;	/*   6: File group. */
173*199767f8SToomas Soome 	u_int64_t	di_size;	/*   8: File byte count. */
174*199767f8SToomas Soome 	int32_t		di_atime;	/*  16: Last access time. */
175*199767f8SToomas Soome 	int32_t		di_atimensec;	/*  20: Last access time. */
176*199767f8SToomas Soome 	int32_t		di_mtime;	/*  24: Last modified time. */
177*199767f8SToomas Soome 	int32_t		di_mtimensec;	/*  28: Last modified time. */
178*199767f8SToomas Soome 	int32_t		di_ctime;	/*  32: Last inode change time. */
179*199767f8SToomas Soome 	int32_t		di_ctimensec;	/*  36: Last inode change time. */
180*199767f8SToomas Soome 	ufs1_daddr_t	di_db[NDADDR];	/*  40: Direct disk blocks. */
181*199767f8SToomas Soome 	ufs1_daddr_t	di_ib[NIADDR];	/*  88: Indirect disk blocks. */
182*199767f8SToomas Soome 	u_int32_t	di_flags;	/* 100: Status flags (chflags). */
183*199767f8SToomas Soome 	u_int32_t	di_blocks;	/* 104: Blocks actually held. */
184*199767f8SToomas Soome 	u_int32_t	di_gen;		/* 108: Generation number. */
185*199767f8SToomas Soome 	u_int32_t	di_shadow;	/* 112: shadow inode */
186*199767f8SToomas Soome 	u_int32_t	di_uid;		/* 116: long EFT version of uid */
187*199767f8SToomas Soome 	u_int32_t	di_gid;		/* 120: long EFT version of gid */
188*199767f8SToomas Soome 	u_int32_t	di_oeftflag;	/* 124: extended attr directory ino, 0 = none */
189*199767f8SToomas Soome };
190*199767f8SToomas Soome 
191*199767f8SToomas Soome #endif /* _UFS_UFS_DINODE_H_ */
192