efs_dinode.h revision 1.2.2.2 1 1.2.2.2 ad /* $NetBSD: efs_dinode.h,v 1.2.2.2 2007/07/15 16:15:21 ad Exp $ */
2 1.2.2.2 ad
3 1.2.2.2 ad /*
4 1.2.2.2 ad * Copyright (c) 2006 Stephen M. Rumble <rumble (at) ephemeral.org>
5 1.2.2.2 ad *
6 1.2.2.2 ad * Permission to use, copy, modify, and distribute this software for any
7 1.2.2.2 ad * purpose with or without fee is hereby granted, provided that the above
8 1.2.2.2 ad * copyright notice and this permission notice appear in all copies.
9 1.2.2.2 ad *
10 1.2.2.2 ad * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 1.2.2.2 ad * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 1.2.2.2 ad * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 1.2.2.2 ad * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 1.2.2.2 ad * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 1.2.2.2 ad * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 1.2.2.2 ad * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 1.2.2.2 ad */
18 1.2.2.2 ad
19 1.2.2.2 ad /*
20 1.2.2.2 ad * EFS on-disk inode format.
21 1.2.2.2 ad *
22 1.2.2.2 ad * See IRIX inode(4)
23 1.2.2.2 ad */
24 1.2.2.2 ad
25 1.2.2.2 ad #ifndef _FS_EFS_EFS_DINODE_H_
26 1.2.2.2 ad #define _FS_EFS_EFS_DINODE_H_
27 1.2.2.2 ad
28 1.2.2.2 ad /*
29 1.2.2.2 ad * Historical locations are always good.
30 1.2.2.2 ad */
31 1.2.2.2 ad #define EFS_ROOTINO ((ino_t)2)
32 1.2.2.2 ad
33 1.2.2.2 ad /*
34 1.2.2.2 ad * EFS on-disk inode structure (128 bytes)
35 1.2.2.2 ad *
36 1.2.2.2 ad * [0] - NetBSD native uid_t is uint32_t.
37 1.2.2.2 ad * [1] - NetBSD native gid_t is uint32_t.
38 1.2.2.2 ad * [2] - NetBSD native off_t is int64_t.
39 1.2.2.2 ad * [3] - See notes for di_u below for meanings of di_numextents.
40 1.2.2.2 ad * [4] - Always 0 with EFS. Apparently it could take on other values when
41 1.2.2.2 ad * used in conjunction with AFS.
42 1.2.2.2 ad */
43 1.2.2.2 ad
44 1.2.2.2 ad #define EFS_DIRECTEXTENTS 12
45 1.2.2.2 ad struct efs_dinode {
46 1.2.2.2 ad uint16_t di_mode; /* 0: file type and permissions */
47 1.2.2.2 ad int16_t di_nlink; /* 2: link count (minimum 2) */
48 1.2.2.2 ad uint16_t di_uid; /* 4: user ID [0] */
49 1.2.2.2 ad uint16_t di_gid; /* 6: group ID [1] */
50 1.2.2.2 ad int32_t di_size; /* 8: file size (in bytes) [2] */
51 1.2.2.2 ad uint32_t di_atime; /* 12: file access time */
52 1.2.2.2 ad uint32_t di_mtime; /* 16: file modification time */
53 1.2.2.2 ad uint32_t di_ctime; /* 20: inode modification time */
54 1.2.2.2 ad int32_t di_gen; /* 24: inode generation number */
55 1.2.2.2 ad int16_t di_numextents; /* 28: number of extents in file [3] */
56 1.2.2.2 ad uint8_t di_version; /* 30: inode version [4] */
57 1.2.2.2 ad uint8_t di_spare; /* 31: unused */
58 1.2.2.2 ad
59 1.2.2.2 ad union {
60 1.2.2.2 ad /*
61 1.2.2.2 ad * If di_numextents <= EFS_DIRECTEXTENTS, _di_extents contains
62 1.2.2.2 ad * direct extent descriptors.
63 1.2.2.2 ad *
64 1.2.2.2 ad * else (di_numextents > EFS_DIRECTEXTENTS), _di_extents
65 1.2.2.2 ad * contains indirect extent descriptors.
66 1.2.2.2 ad *
67 1.2.2.2 ad * If indirect extents are being used, extents[0].ex_offset
68 1.2.2.2 ad * contains the number of indirect extents, i.e. the valid
69 1.2.2.2 ad * offsets in 'extents' are:
70 1.2.2.2 ad * extents[0 ... (extents[0].ex_offset - 1)]
71 1.2.2.2 ad * It's not presently known if the ex_offset fields in
72 1.2.2.2 ad * extents[1 ... EFS_DIRECTEXTENTS] have any meaning.
73 1.2.2.2 ad */
74 1.2.2.2 ad struct efs_dextent extents[EFS_DIRECTEXTENTS];
75 1.2.2.2 ad
76 1.2.2.2 ad /*
77 1.2.2.2 ad * If di_numextents == 0 and di_mode indicates a symlink, the
78 1.2.2.2 ad * symlink path is inlined into _di_symlink. Otherwise, the
79 1.2.2.2 ad * symlink exists in extents.
80 1.2.2.2 ad *
81 1.2.2.2 ad * Note that the symlink is stored without nul-termination,
82 1.2.2.2 ad * and di_size reflects this length.
83 1.2.2.2 ad */
84 1.2.2.2 ad char symlink[sizeof(struct efs_dextent) * EFS_DIRECTEXTENTS];
85 1.2.2.2 ad
86 1.2.2.2 ad /*
87 1.2.2.2 ad * If di_numextents == 0 and di_mode indicates a character or
88 1.2.2.2 ad * block special file, the device tag is contained in _di_dev.
89 1.2.2.2 ad *
90 1.2.2.2 ad * Note that IRIX moved from 16bit to 32bit dev_t's at some
91 1.2.2.2 ad * point and a new field was added. It appears that when 32bit
92 1.2.2.2 ad * dev_t's are used, di_odev is set to 0xffff.
93 1.2.2.2 ad */
94 1.2.2.2 ad struct {
95 1.2.2.2 ad uint16_t dev_old;
96 1.2.2.2 ad uint32_t dev_new;
97 1.2.2.2 ad } __packed dev;
98 1.2.2.2 ad } di_u;
99 1.2.2.2 ad } __packed;
100 1.2.2.2 ad
101 1.2.2.2 ad #define di_extents di_u.extents
102 1.2.2.2 ad #define di_symlink di_u.symlink
103 1.2.2.2 ad #define di_odev di_u.dev.dev_old
104 1.2.2.2 ad #define di_ndev di_u.dev.dev_new
105 1.2.2.2 ad
106 1.2.2.2 ad #define EFS_DINODE_SIZE sizeof(struct efs_dinode)
107 1.2.2.2 ad #define EFS_DINODES_PER_BB (EFS_BB_SIZE / EFS_DINODE_SIZE)
108 1.2.2.2 ad
109 1.2.2.2 ad #define EFS_DINODE_ODEV_INVALID (0xffff)
110 1.2.2.2 ad #define EFS_DINODE_ODEV_MAJ(_x) (((_x) >> 8) & 0x7f)
111 1.2.2.2 ad #define EFS_DINODE_ODEV_MIN(_x) (((_x) >> 0) & 0xff)
112 1.2.2.2 ad #define EFS_DINODE_NDEV_MAJ(_x) (((_x) >> 18) & 0x1ff)
113 1.2.2.2 ad #define EFS_DINODE_NDEV_MIN(_x) (((_x) >> 0) & 0x3ffff)
114 1.2.2.2 ad
115 1.2.2.2 ad /* EFS file permissions. */
116 1.2.2.2 ad #define EFS_IEXEC 0000100 /* executable */
117 1.2.2.2 ad #define EFS_IWRITE 0000200 /* writable */
118 1.2.2.2 ad #define EFS_IREAD 0000400 /* readable */
119 1.2.2.2 ad #define EFS_ISVTX 0001000 /* sticky bit */
120 1.2.2.2 ad #define EFS_ISGID 0002000 /* setgid */
121 1.2.2.2 ad #define EFS_ISUID 0004000 /* setuid */
122 1.2.2.2 ad
123 1.2.2.2 ad /* EFS file types. */
124 1.2.2.2 ad #define EFS_IFMT 0170000 /* file type mask */
125 1.2.2.2 ad #define EFS_IFIFO 0010000 /* named pipe */
126 1.2.2.2 ad #define EFS_IFCHR 0020000 /* character device */
127 1.2.2.2 ad #define EFS_IFDIR 0040000 /* directory */
128 1.2.2.2 ad #define EFS_IFBLK 0060000 /* block device */
129 1.2.2.2 ad #define EFS_IFREG 0100000 /* regular file */
130 1.2.2.2 ad #define EFS_IFLNK 0120000 /* symlink */
131 1.2.2.2 ad #define EFS_IFSOCK 0140000 /* UNIX domain socket */
132 1.2.2.2 ad
133 1.2.2.2 ad #endif /* !_FS_EFS_EFS_DINODE_H_ */
134