xref: /original-bsd/sys/ufs/ffs/dinode.h (revision 42c7e7a1)
1 /*
2  * Copyright (c) 1982, 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)dinode.h	7.17 (Berkeley) 06/23/92
8  */
9 
10 /*
11  * The root inode is the root of the file system.  Inode 0 can't be used for
12  * normal purposes and historically bad blocks were linked to inode 1, thus
13  * the root inode is 2.  (Inode 1 is no longer used for this purpose, however
14  * numerous dump tapes make this assumption, so we are stuck with it).
15  */
16 #define	ROOTINO	((ino_t)2)
17 
18 /*
19  * A dinode contains all the meta-data associated with a UFS file.
20  * This structure defines the on-disk format of a dinode.
21  */
22 
23 #define	NDADDR	12		/* direct addresses in inode */
24 #define	NIADDR	3		/* indirect addresses in inode */
25 
26 struct dinode {
27 	u_short		di_mode;	/*   0: mode and type of file */
28 	short		di_nlink;	/*   2: number of links to file */
29 	u_short		di_ouid;	/*   4: old owner's user id */
30 	u_short		di_ogid;	/*   6: old owner's group id */
31 	u_quad_t	di_size;	/*   8: number of bytes in file */
32 	struct timespec	di_atime;	/*  16: time last accessed */
33 	struct timespec	di_mtime;	/*  24: time last modified */
34 	struct timespec	di_ctime;	/*  32: last time inode changed */
35 	daddr_t		di_db[NDADDR];	/*  40: disk block addresses */
36 	daddr_t		di_ib[NIADDR];	/*  88: indirect blocks */
37 	long		di_flags;	/* 100: status, currently unused */
38 	long		di_blocks;	/* 104: blocks actually held */
39 	long		di_gen;		/* 108: generation number */
40 	u_long		di_uid;		/* 112: owner's user id */
41 	u_long		di_gid;		/* 116: owner's group id */
42 	long		di_spare[2];	/* 120: reserved, currently unused */
43 };
44 
45 /*
46  * The di_db fields may be overlaid with other information for
47  * file types that do not have associated disk storage. Block
48  * and character devices overlay the first data block with their
49  * dev_t value. Short symbolic links place their path in the
50  * di_db area.
51  */
52 #define	di_rdev		di_db[0]
53 #define di_shortlink	di_db
54 #define	MAXSYMLINKLEN	(NDADDR * sizeof(daddr_t))
55 
56 /* file modes */
57 #define	IFMT		0170000		/* mask of file type */
58 #define	IFIFO		0010000		/* named pipe (fifo) */
59 #define	IFCHR		0020000		/* character special device */
60 #define	IFDIR		0040000		/* directory */
61 #define	IFBLK		0060000		/* block special device */
62 #define	IFREG		0100000		/* regular file */
63 #define	IFLNK		0120000		/* symbolic link */
64 #define	IFSOCK		0140000		/* UNIX domain socket */
65 
66 #define	ISUID		04000		/* set user identifier when exec'ing */
67 #define	ISGID		02000		/* set group identifier when exec'ing */
68 #define	ISVTX		01000		/* save execution information on exit */
69 #define	IREAD		0400		/* read permission */
70 #define	IWRITE		0200		/* write permission */
71 #define	IEXEC		0100		/* execute permission */
72