dinode.h revision 1541
11541Srgrimes/*
21541Srgrimes * Copyright (c) 1982, 1989, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes * (c) UNIX System Laboratories, Inc.
51541Srgrimes * All or some portions of this file are derived from material licensed
61541Srgrimes * to the University of California by American Telephone and Telegraph
71541Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with
81541Srgrimes * the permission of UNIX System Laboratories, Inc.
91541Srgrimes *
101541Srgrimes * Redistribution and use in source and binary forms, with or without
111541Srgrimes * modification, are permitted provided that the following conditions
121541Srgrimes * are met:
131541Srgrimes * 1. Redistributions of source code must retain the above copyright
141541Srgrimes *    notice, this list of conditions and the following disclaimer.
151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
161541Srgrimes *    notice, this list of conditions and the following disclaimer in the
171541Srgrimes *    documentation and/or other materials provided with the distribution.
181541Srgrimes * 3. All advertising materials mentioning features or use of this software
191541Srgrimes *    must display the following acknowledgement:
201541Srgrimes *	This product includes software developed by the University of
211541Srgrimes *	California, Berkeley and its contributors.
221541Srgrimes * 4. Neither the name of the University nor the names of its contributors
231541Srgrimes *    may be used to endorse or promote products derived from this software
241541Srgrimes *    without specific prior written permission.
251541Srgrimes *
261541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
271541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
281541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
291541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
301541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
311541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
321541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
331541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
341541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
351541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
361541Srgrimes * SUCH DAMAGE.
371541Srgrimes *
381541Srgrimes *	@(#)dinode.h	8.3 (Berkeley) 1/21/94
391541Srgrimes */
401541Srgrimes
411541Srgrimes/*
421541Srgrimes * The root inode is the root of the file system.  Inode 0 can't be used for
431541Srgrimes * normal purposes and historically bad blocks were linked to inode 1, thus
441541Srgrimes * the root inode is 2.  (Inode 1 is no longer used for this purpose, however
451541Srgrimes * numerous dump tapes make this assumption, so we are stuck with it).
461541Srgrimes */
471541Srgrimes#define	ROOTINO	((ino_t)2)
481541Srgrimes
491541Srgrimes/*
501541Srgrimes * A dinode contains all the meta-data associated with a UFS file.
511541Srgrimes * This structure defines the on-disk format of a dinode.
521541Srgrimes */
531541Srgrimes
541541Srgrimes#define	NDADDR	12			/* Direct addresses in inode. */
551541Srgrimes#define	NIADDR	3			/* Indirect addresses in inode. */
561541Srgrimes
571541Srgrimesstruct dinode {
581541Srgrimes	u_short		di_mode;	/*   0: IFMT and permissions. */
591541Srgrimes	short		di_nlink;	/*   2: File link count. */
601541Srgrimes	union {
611541Srgrimes		u_short	oldids[2];	/*   4: Ffs: old user and group ids. */
621541Srgrimes		ino_t	inumber;	/*   4: Lfs: inode number. */
631541Srgrimes	} di_u;
641541Srgrimes	u_quad_t	di_size;	/*   8: File byte count. */
651541Srgrimes	struct timespec	di_atime;	/*  16: Last access time. */
661541Srgrimes	struct timespec	di_mtime;	/*  24: Last modified time. */
671541Srgrimes	struct timespec	di_ctime;	/*  32: Last inode change time. */
681541Srgrimes	daddr_t		di_db[NDADDR];	/*  40: Direct disk blocks. */
691541Srgrimes	daddr_t		di_ib[NIADDR];	/*  88: Indirect disk blocks. */
701541Srgrimes	u_long		di_flags;	/* 100: Status flags (chflags). */
711541Srgrimes	long		di_blocks;	/* 104: Blocks actually held. */
721541Srgrimes	long		di_gen;		/* 108: Generation number. */
731541Srgrimes	u_long		di_uid;		/* 112: File owner. */
741541Srgrimes	u_long		di_gid;		/* 116: File group. */
751541Srgrimes	long		di_spare[2];	/* 120: Reserved; currently unused */
761541Srgrimes};
771541Srgrimes
781541Srgrimes/*
791541Srgrimes * The di_db fields may be overlaid with other information for
801541Srgrimes * file types that do not have associated disk storage. Block
811541Srgrimes * and character devices overlay the first data block with their
821541Srgrimes * dev_t value. Short symbolic links place their path in the
831541Srgrimes * di_db area.
841541Srgrimes */
851541Srgrimes#define	di_inumber	di_u.inumber
861541Srgrimes#define	di_ogid		di_u.oldids[1]
871541Srgrimes#define	di_ouid		di_u.oldids[0]
881541Srgrimes#define	di_rdev		di_db[0]
891541Srgrimes#define	di_shortlink	di_db
901541Srgrimes#define	MAXSYMLINKLEN	((NDADDR + NIADDR) * sizeof(daddr_t))
911541Srgrimes
921541Srgrimes/* File modes. */
931541Srgrimes#define	IEXEC		0000100		/* Executable. */
941541Srgrimes#define	IWRITE		0000200		/* Writeable. */
951541Srgrimes#define	IREAD		0000400		/* Readable. */
961541Srgrimes#define	ISVTX		0001000		/* Sticky bit. */
971541Srgrimes#define	ISGID		0002000		/* Set-gid. */
981541Srgrimes#define	ISUID		0004000		/* Set-uid. */
991541Srgrimes
1001541Srgrimes/* File types. */
1011541Srgrimes#define	IFMT		0170000		/* Mask of file type. */
1021541Srgrimes#define	IFIFO		0010000		/* Named pipe (fifo). */
1031541Srgrimes#define	IFCHR		0020000		/* Character device. */
1041541Srgrimes#define	IFDIR		0040000		/* Directory file. */
1051541Srgrimes#define	IFBLK		0060000		/* Block device. */
1061541Srgrimes#define	IFREG		0100000		/* Regular file. */
1071541Srgrimes#define	IFLNK		0120000		/* Symbolic link. */
1081541Srgrimes#define	IFSOCK		0140000		/* UNIX domain socket. */
109