]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - libdisk/fstype.h
Merge whitespace changes over
[thirdparty/xfsprogs-dev.git] / libdisk / fstype.h
1 /*
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 *
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
32
33 #undef XFS_SUPER_MAGIC
34
35 /*
36 * From mount(8) source by Andries Brouwer. Hacked for XFS by mkp.
37 * Recent sync's to mount source:
38 * - util-linux-2.10o ... 06 Sep 00
39 * - util-linux-2.10r ... 06 Dec 00
40 * - util-linux-2.11g ... 02 Jul 01
41 * - util-linux-2.11u ... 24 Aug 02
42 */
43
44 /* Including <linux/fs.h> became more and more painful.
45 Below a very abbreviated version of some declarations,
46 only designed to be able to check a magic number
47 in case no filesystem type was given. */
48
49 #define MINIX_SUPER_MAGIC 0x137F /* minix v1, 14 char names */
50 #define MINIX_SUPER_MAGIC2 0x138F /* minix v1, 30 char names */
51 #define MINIX2_SUPER_MAGIC 0x2468 /* minix v2, 14 char names */
52 #define MINIX2_SUPER_MAGIC2 0x2478 /* minix v2, 30 char names */
53 struct minix_super_block {
54 u_char s_dummy[16];
55 u_char s_magic[2];
56 };
57 #define minixmagic(s) assemble2le(s.s_magic)
58
59 #define ISODCL(from, to) (to - from + 1)
60 #define ISO_STANDARD_ID "CD001"
61 struct iso_volume_descriptor {
62 char type[ISODCL(1,1)]; /* 711 */
63 char id[ISODCL(2,6)];
64 char version[ISODCL(7,7)];
65 char data[ISODCL(8,2048)];
66 };
67
68 #define HS_STANDARD_ID "CDROM"
69 struct hs_volume_descriptor {
70 char foo[ISODCL ( 1, 8)]; /* 733 */
71 char type[ISODCL ( 9, 9)]; /* 711 */
72 char id[ISODCL ( 10, 14)];
73 char version[ISODCL ( 15, 15)]; /* 711 */
74 char data[ISODCL(16,2048)];
75 };
76
77 #define EXT_SUPER_MAGIC 0x137D
78 struct ext_super_block {
79 u_char s_dummy[56];
80 u_char s_magic[2];
81 };
82 #define extmagic(s) assemble2le(s.s_magic)
83
84 #define EXT2_PRE_02B_MAGIC 0xEF51
85 #define EXT2_SUPER_MAGIC 0xEF53
86 #define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
87 struct ext2_super_block {
88 u_char s_dummy1[56];
89 u_char s_magic[2];
90 u_char s_dummy2[34];
91 u_char s_feature_compat[4];
92 u_char s_feature_incompat[4];
93 u_char s_feature_ro_compat[4];
94 u_char s_uuid[16];
95 u_char s_volume_name[16];
96 u_char s_dummy3[88];
97 u_char s_journal_inum[4]; /* ext3 only */
98 };
99 #define ext2magic(s) assemble2le(s.s_magic)
100
101 struct reiserfs_super_block
102 {
103 u_char s_block_count[4];
104 u_char s_free_blocks[4];
105 u_char s_root_block[4];
106 u_char s_journal_block[4];
107 u_char s_journal_dev[4];
108 u_char s_orig_journal_size[4];
109 u_char s_journal_trans_max[4];
110 u_char s_journal_block_count[4];
111 u_char s_journal_max_batch[4];
112 u_char s_journal_max_commit_age[4];
113 u_char s_journal_max_trans_age[4];
114 u_char s_blocksize[2];
115 u_char s_oid_maxsize[2];
116 u_char s_oid_cursize[2];
117 u_char s_state[2];
118 u_char s_magic[12];
119 };
120 #define REISERFS_SUPER_MAGIC_STRING "ReIsErFs"
121 #define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs"
122 #define REISERFS_DISK_OFFSET_IN_BYTES (64 * 1024)
123 /* the spot for the super in versions 3.5 - 3.5.10 (inclusive) */
124 #define REISERFS_OLD_DISK_OFFSET_IN_BYTES (8 * 1024)
125
126 #define _XIAFS_SUPER_MAGIC 0x012FD16D
127 struct xiafs_super_block {
128 u_char s_boot_segment[512]; /* 1st sector reserved for boot */
129 u_char s_dummy[60];
130 u_char s_magic[4];
131 };
132 #define xiafsmagic(s) assemble4le(s.s_magic)
133
134 /* From jj@sunsite.ms.mff.cuni.cz Mon Mar 23 15:19:05 1998 */
135 #define UFS_SUPER_MAGIC_LE 0x00011954
136 #define UFS_SUPER_MAGIC_BE 0x54190100
137 struct ufs_super_block {
138 u_char s_dummy[0x55c];
139 u_char s_magic[4];
140 };
141 #define ufsmagic(s) assemble4le(s.s_magic)
142
143 /* From Richard.Russon@ait.co.uk Wed Feb 24 08:05:27 1999 */
144 #define NTFS_SUPER_MAGIC "NTFS"
145 struct ntfs_super_block {
146 u_char s_dummy[3];
147 u_char s_magic[4];
148 };
149
150 /* From inspection of a few FAT filesystems - aeb */
151 /* Unfortunately I find almost the same thing on an extended partition;
152 it looks like a primary has some directory entries where the extended
153 has a partition table: IO.SYS, MSDOS.SYS, WINBOOT.SYS */
154 struct fat_super_block {
155 u_char s_dummy[3];
156 u_char s_os[8]; /* "MSDOS5.0" or "MSWIN4.0" or "MSWIN4.1" */
157 /* mtools-3.9.4 writes "MTOOL394" */
158 u_char s_dummy2[32];
159 u_char s_label[11]; /* for DOS? */
160 u_char s_fs[8]; /* "FAT12 " or "FAT16 " or all zero */
161 /* OS/2 BM has "FAT " here. */
162 u_char s_dummy3[9];
163 u_char s_label2[11]; /* for Windows? */
164 u_char s_fs2[8]; /* garbage or "FAT32 " */
165 };
166
167 #define XFS_SUPER_MAGIC "XFSB"
168 struct xfs_super_block {
169 u_char s_magic[4];
170 u_char s_dummy[28];
171 u_char s_uuid[16];
172 u_char s_dummy2[60];
173 u_char s_fname[12];
174 };
175
176 #define CRAMFS_SUPER_MAGIC 0x28cd3d45
177 struct cramfs_super_block {
178 u_char s_magic[4];
179 u_char s_dummy[12];
180 u_char s_id[16];
181 };
182 #define cramfsmagic(s) assemble4le(s.s_magic)
183
184 #define HFS_SUPER_MAGIC 0x4244
185 struct hfs_super_block {
186 u_char s_magic[2];
187 u_char s_dummy[18];
188 u_char s_blksize[4];
189 };
190 #define hfsmagic(s) assemble2le(s.s_magic)
191 #define hfsblksize(s) assemble4le(s.s_blksize)
192
193 #define HPFS_SUPER_MAGIC 0xf995e849
194 struct hpfs_super_block {
195 u_char s_magic[4];
196 u_char s_magic2[4];
197 };
198 #define hpfsmagic(s) assemble4le(s.s_magic)
199
200 struct adfs_super_block {
201 u_char s_dummy[448];
202 u_char s_blksize[1];
203 u_char s_dummy2[62];
204 u_char s_checksum[1];
205 };
206 #define adfsblksize(s) ((uint) s.s_blksize[0])
207
208 /* found in first 4 bytes of block 1 */
209 struct vxfs_super_block {
210 u_char s_magic[4];
211 };
212 #define vxfsmagic(s) assemble4le(s.s_magic)
213 #define VXFS_SUPER_MAGIC 0xa501FCF5
214
215 struct jfs_super_block {
216 char s_magic[4];
217 u_char s_version[4];
218 u_char s_dummy1[93];
219 char s_fpack[11];
220 u_char s_dummy2[24];
221 u_char s_uuid[16];
222 char s_label[16];
223 };
224 #define JFS_SUPER1_OFF 0x8000
225 #define JFS_MAGIC "JFS1"
226
227 struct sysv_super_block {
228 u_char s_dummy1[504];
229 u_char s_magic[4];
230 u_char type[4];
231 };
232 #define sysvmagic(s) assemble4le(s.s_magic)
233 #define SYSV_SUPER_MAGIC 0xfd187e20
234
235 struct mdp_super_block {
236 u_char md_magic[4];
237 };
238 #define MD_SB_MAGIC 0xa92b4efc
239 #define mdsbmagic(s) assemble4le(s.md_magic)
240
241 static inline int
242 assemble2le(unsigned char *p) {
243 return (p[0] | (p[1] << 8));
244 }
245
246 static inline int
247 assemble4le(unsigned char *p) {
248 return (p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24));
249 }