xref: /original-bsd/sys/ufs/ffs/dinode.h (revision 502feadc)
1 /*
2  * Copyright (c) 1982, 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that the above copyright notice and this paragraph are
7  * duplicated in all such forms and that any documentation,
8  * advertising materials, and other materials related to such
9  * distribution and use acknowledge that the software was developed
10  * by the University of California, Berkeley.  The name of the
11  * University may not be used to endorse or promote products derived
12  * from this software without specific prior written permission.
13  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  *	@(#)dinode.h	7.8 (Berkeley) 05/15/90
18  */
19 
20 /*
21  * This structure defines the on-disk format of an inode.
22  */
23 
24 #define	NDADDR	12		/* direct addresses in inode */
25 #define	NIADDR	3		/* indirect addresses in inode */
26 
27 struct dinode {
28 	u_short	di_mode;	/*  0: mode and type of file */
29 	short	di_nlink;	/*  2: number of links to file */
30 	uid_t	di_uid;		/*  4: owner's user id */
31 	gid_t	di_gid;		/*  6: owner's group id */
32 	u_quad	di_qsize;	/*  8: number of bytes in file */
33 	time_t	di_atime;	/* 16: time last accessed */
34 	long	di_atspare;
35 	time_t	di_mtime;	/* 24: time last modified */
36 	long	di_mtspare;
37 	time_t	di_ctime;	/* 32: last time inode changed */
38 	long	di_ctspare;
39 	daddr_t	di_db[NDADDR];	/* 40: disk block addresses */
40 	daddr_t	di_ib[NIADDR];	/* 88: indirect blocks */
41 	long	di_flags;	/* 100: status, currently unused */
42 	long	di_blocks;	/* 104: blocks actually held */
43 	long	di_gen;		/* 108: generation number */
44 	long	di_spare[4];	/* 112: reserved, currently unused */
45 };
46 
47 #if BYTE_ORDER == LITTLE_ENDIAN || defined(tahoe) /* ugh! -- must be fixed */
48 #define	di_size		di_qsize.val[0]
49 #else /* BYTE_ORDER == BIG_ENDIAN */
50 #define	di_size		di_qsize.val[1]
51 #endif
52 #define	di_rdev		di_db[0]
53 
54 /* file modes */
55 #define	IFMT		0170000		/* type of file */
56 #define	IFIFO		0010000		/* named pipe (fifo) */
57 #define	IFCHR		0020000		/* character special */
58 #define	IFDIR		0040000		/* directory */
59 #define	IFBLK		0060000		/* block special */
60 #define	IFREG		0100000		/* regular */
61 #define	IFLNK		0120000		/* symbolic link */
62 #define	IFSOCK		0140000		/* socket */
63 
64 #define	ISUID		04000		/* set user id on execution */
65 #define	ISGID		02000		/* set group id on execution */
66 #define	ISVTX		01000		/* save swapped text even after use */
67 #define	IREAD		0400		/* read, write, execute permissions */
68 #define	IWRITE		0200
69 #define	IEXEC		0100
70