xref: /original-bsd/sys/ufs/ffs/dinode.h (revision a257ce37)
1449c849fSmckusick /*
276403e9cSbostic  * Copyright (c) 1982, 1989, 1993
376403e9cSbostic  *	The Regents of the University of California.  All rights reserved.
4*a257ce37Sbostic  * (c) UNIX System Laboratories, Inc.
5*a257ce37Sbostic  * All or some portions of this file are derived from material licensed
6*a257ce37Sbostic  * to the University of California by American Telephone and Telegraph
7*a257ce37Sbostic  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8*a257ce37Sbostic  * the permission of UNIX System Laboratories, Inc.
9449c849fSmckusick  *
1088f5dc9aSbostic  * %sccs.include.redist.c%
118177e537Smckusick  *
12*a257ce37Sbostic  *	@(#)dinode.h	8.3 (Berkeley) 01/21/94
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 /*
24f43f6c4aSmckusick  * A dinode contains all the meta-data associated with a UFS file.
25f43f6c4aSmckusick  * This structure defines the on-disk format of a dinode.
26876480d6Sbill  */
273f558a57Smckusic 
282f347998Sbostic #define	NDADDR	12			/* Direct addresses in inode. */
292f347998Sbostic #define	NIADDR	3			/* Indirect addresses in inode. */
30876480d6Sbill 
313f558a57Smckusic struct dinode {
322f347998Sbostic 	u_short		di_mode;	/*   0: IFMT and permissions. */
332f347998Sbostic 	short		di_nlink;	/*   2: File link count. */
34f6d1d0afSmckusick 	union {
352f347998Sbostic 		u_short	oldids[2];	/*   4: Ffs: old user and group ids. */
362f347998Sbostic 		ino_t	inumber;	/*   4: Lfs: inode number. */
37f6d1d0afSmckusick 	} di_u;
382f347998Sbostic 	u_quad_t	di_size;	/*   8: File byte count. */
392f347998Sbostic 	struct timespec	di_atime;	/*  16: Last access time. */
402f347998Sbostic 	struct timespec	di_mtime;	/*  24: Last modified time. */
412f347998Sbostic 	struct timespec	di_ctime;	/*  32: Last inode change time. */
422f347998Sbostic 	daddr_t		di_db[NDADDR];	/*  40: Direct disk blocks. */
432f347998Sbostic 	daddr_t		di_ib[NIADDR];	/*  88: Indirect disk blocks. */
442f347998Sbostic 	u_long		di_flags;	/* 100: Status flags (chflags). */
452f347998Sbostic 	long		di_blocks;	/* 104: Blocks actually held. */
462f347998Sbostic 	long		di_gen;		/* 108: Generation number. */
472f347998Sbostic 	u_long		di_uid;		/* 112: File owner. */
482f347998Sbostic 	u_long		di_gid;		/* 116: File group. */
492f347998Sbostic 	long		di_spare[2];	/* 120: Reserved; currently unused */
503f558a57Smckusic };
513f558a57Smckusic 
5212385100Smckusick /*
5312385100Smckusick  * The di_db fields may be overlaid with other information for
5412385100Smckusick  * file types that do not have associated disk storage. Block
5512385100Smckusick  * and character devices overlay the first data block with their
5612385100Smckusick  * dev_t value. Short symbolic links place their path in the
5712385100Smckusick  * di_db area.
5812385100Smckusick  */
59f6d1d0afSmckusick #define	di_inumber	di_u.inumber
602f347998Sbostic #define	di_ogid		di_u.oldids[1]
612f347998Sbostic #define	di_ouid		di_u.oldids[0]
62ed5dc773Smckusick #define	di_rdev		di_db[0]
6312385100Smckusick #define	di_shortlink	di_db
6488ecb8a2Smckusick #define	MAXSYMLINKLEN	((NDADDR + NIADDR) * sizeof(daddr_t))
653f558a57Smckusic 
662f347998Sbostic /* File modes. */
672f347998Sbostic #define	IEXEC		0000100		/* Executable. */
682f347998Sbostic #define	IWRITE		0000200		/* Writeable. */
692f347998Sbostic #define	IREAD		0000400		/* Readable. */
702f347998Sbostic #define	ISVTX		0001000		/* Sticky bit. */
712f347998Sbostic #define	ISGID		0002000		/* Set-gid. */
722f347998Sbostic #define	ISUID		0004000		/* Set-uid. */
73e10ef072Sroot 
742f347998Sbostic /* File types. */
752f347998Sbostic #define	IFMT		0170000		/* Mask of file type. */
762f347998Sbostic #define	IFIFO		0010000		/* Named pipe (fifo). */
772f347998Sbostic #define	IFCHR		0020000		/* Character device. */
782f347998Sbostic #define	IFDIR		0040000		/* Directory file. */
792f347998Sbostic #define	IFBLK		0060000		/* Block device. */
802f347998Sbostic #define	IFREG		0100000		/* Regular file. */
812f347998Sbostic #define	IFLNK		0120000		/* Symbolic link. */
822f347998Sbostic #define	IFSOCK		0140000		/* UNIX domain socket. */
83