Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / platform / pc32 / boot / dosboot / dinode.h
1 /*\r
2  * Copyright (c) 1982, 1989 The Regents of the University of California.\r
3  * All rights reserved.\r
4  *\r
5  * Redistribution and use in source and binary forms, with or without\r
6  * modification, are permitted provided that the following conditions\r
7  * are met:\r
8  * 1. Redistributions of source code must retain the above copyright\r
9  *    notice, this list of conditions and the following disclaimer.\r
10  * 2. Redistributions in binary form must reproduce the above copyright\r
11  *    notice, this list of conditions and the following disclaimer in the\r
12  *    documentation and/or other materials provided with the distribution.\r
13  * 3. All advertising materials mentioning features or use of this software\r
14  *    must display the following acknowledgement:\r
15  *      This product includes software developed by the University of\r
16  *      California, Berkeley and its contributors.\r
17  * 4. Neither the name of the University nor the names of its contributors\r
18  *    may be used to endorse or promote products derived from this software\r
19  *    without specific prior written permission.\r
20  *\r
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
31  * SUCH DAMAGE.\r
32  *\r
33  *      from: @(#)dinode.h      7.10 (Berkeley) 5/8/91\r
34  * $FreeBSD: src/sys/i386/boot/dosboot/dinode.h,v 1.5 1999/08/28 00:43:21 peter Exp $\r
35  */\r
36 \r
37 #ifndef _UFS_DINODE_H_\r
38 #define _UFS_DINODE_H_ 1\r
39 \r
40 /*\r
41  * A dinode contains all the meta-data associated with a UFS file.\r
42  * This structure defines the on-disk format of a dinode.\r
43  */\r
44 \r
45 #define NDADDR  12              /* direct addresses in inode */\r
46 #define NIADDR  3               /* indirect addresses in inode */\r
47 \r
48 #define MAXFASTLINK     (((NDADDR+NIADDR) * sizeof(daddr_t)) - 1)\r
49 \r
50 struct dinode {\r
51         u_short di_mode;        /*  0: mode and type of file */\r
52         short   di_nlink;       /*  2: number of links to file */\r
53         uid_t   di_uid;         /*  4: owner's user id */\r
54         gid_t   di_gid;         /*  6: owner's group id */\r
55         union {\r
56 /*              u_quad_t v;*/\r
57                 u_long val[2];\r
58         }       di_qsize;       /*  8: number of bytes in file */\r
59         time_t  di_atime;       /* 16: time last accessed */\r
60         long    di_atspare;\r
61         time_t  di_mtime;       /* 24: time last modified */\r
62         long    di_mtspare;\r
63         time_t  di_ctime;       /* 32: last time inode changed */\r
64         long    di_ctspare;\r
65         union {\r
66                 struct {\r
67                         daddr_t di_udb[NDADDR]; /* 40: disk block addresses */\r
68                         daddr_t di_uib[NIADDR]; /* 88: indirect blocks */\r
69                 } di_addr;\r
70                 char di_usymlink[MAXFASTLINK+1];\r
71         } di_un;\r
72         long    di_flags;       /* 100: status, currently unused */\r
73         long    di_blocks;      /* 104: blocks actually held */\r
74         long    di_gen;         /* 108: generation number */\r
75 #define DI_SPARE_SZ     4               /* 112: spare for 4 longs */\r
76         u_long  di_spare[DI_SPARE_SZ];  /* reserved (unused) */\r
77 };\r
78 \r
79 #define di_db           di_un.di_addr.di_udb\r
80 #define di_ib           di_un.di_addr.di_uib\r
81 #define di_symlink      di_un.di_usymlink\r
82 \r
83 #if BYTE_ORDER == LITTLE_ENDIAN || defined(tahoe) /* ugh! -- must be fixed */\r
84 #define di_size         di_qsize.val[0]\r
85 #else /* BYTE_ORDER == BIG_ENDIAN */\r
86 #define di_size         di_qsize.val[1]\r
87 #endif\r
88 #define di_rdev         di_db[0]\r
89 \r
90 /* file modes */\r
91 #define IFMT            0170000         /* mask of file type */\r
92 #define IFIFO           0010000         /* named pipe (fifo) */\r
93 #define IFCHR           0020000         /* character special device */\r
94 #define IFDIR           0040000         /* directory */\r
95 #define IFBLK           0060000         /* block special device */\r
96 #define IFREG           0100000         /* regular file */\r
97 #define IFLNK           0120000         /* symbolic link */\r
98 #define IFSOCK          0140000         /* UNIX domain socket */\r
99 \r
100 #define ISUID           04000           /* set user identifier when exec'ing */\r
101 #define ISGID           02000           /* set group identifier when exec'ing */\r
102 #define ISVTX           01000           /* save execution information on exit */\r
103 #define IREAD           0400            /* read permission */\r
104 #define IWRITE          0200            /* write permission */\r
105 #define IEXEC           0100            /* execute permission */\r
106 \r
107 #define DFASTLINK(di) \\r
108         ((((di).di_mode & IFMT) == IFLNK) && \\r
109          ((di).di_size <= MAXFASTLINK) && \\r
110          ((di).di_size == (di).di_spare[0]))\r
111 #endif /* _UFS_DINODE_H_ */\r