]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - libdisk/fstype.h
Merge whitespace changes over
[thirdparty/xfsprogs-dev.git] / libdisk / fstype.h
CommitLineData
f937adac 1/*
0d3e0b37 2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
dfc130f3 3 *
f937adac
NS
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.
dfc130f3 7 *
f937adac
NS
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.
dfc130f3 11 *
f937adac
NS
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.
dfc130f3 18 *
f937adac
NS
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.
dfc130f3 22 *
f937adac
NS
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
dfc130f3
RC
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
f937adac
NS
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
ebf3db3a 41 * - util-linux-2.11u ... 24 Aug 02
f937adac
NS
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
ebf3db3a
ES
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 */
f937adac
NS
53struct minix_super_block {
54 u_char s_dummy[16];
55 u_char s_magic[2];
56};
ebf3db3a 57#define minixmagic(s) assemble2le(s.s_magic)
f937adac
NS
58
59#define ISODCL(from, to) (to - from + 1)
60#define ISO_STANDARD_ID "CD001"
61struct 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"
69struct 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
78struct ext_super_block {
79 u_char s_dummy[56];
80 u_char s_magic[2];
81};
ebf3db3a 82#define extmagic(s) assemble2le(s.s_magic)
f937adac
NS
83
84#define EXT2_PRE_02B_MAGIC 0xEF51
85#define EXT2_SUPER_MAGIC 0xEF53
86#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
87struct ext2_super_block {
dfc130f3
RC
88 u_char s_dummy1[56];
89 u_char s_magic[2];
f937adac
NS
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];
dfc130f3 95 u_char s_volume_name[16];
f937adac
NS
96 u_char s_dummy3[88];
97 u_char s_journal_inum[4]; /* ext3 only */
98};
ebf3db3a 99#define ext2magic(s) assemble2le(s.s_magic)
f937adac
NS
100
101struct 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
127struct 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};
ebf3db3a 132#define xiafsmagic(s) assemble4le(s.s_magic)
f937adac
NS
133
134/* From jj@sunsite.ms.mff.cuni.cz Mon Mar 23 15:19:05 1998 */
ebf3db3a
ES
135#define UFS_SUPER_MAGIC_LE 0x00011954
136#define UFS_SUPER_MAGIC_BE 0x54190100
f937adac
NS
137struct ufs_super_block {
138 u_char s_dummy[0x55c];
139 u_char s_magic[4];
140};
ebf3db3a 141#define ufsmagic(s) assemble4le(s.s_magic)
f937adac
NS
142
143/* From Richard.Russon@ait.co.uk Wed Feb 24 08:05:27 1999 */
144#define NTFS_SUPER_MAGIC "NTFS"
145struct 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 */
154struct 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 */
dfc130f3 161 /* OS/2 BM has "FAT " here. */
f937adac
NS
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"
168struct 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
177struct cramfs_super_block {
178 u_char s_magic[4];
179 u_char s_dummy[12];
180 u_char s_id[16];
181};
ebf3db3a 182#define cramfsmagic(s) assemble4le(s.s_magic)
f937adac
NS
183
184#define HFS_SUPER_MAGIC 0x4244
185struct hfs_super_block {
186 u_char s_magic[2];
187 u_char s_dummy[18];
188 u_char s_blksize[4];
189};
ebf3db3a
ES
190#define hfsmagic(s) assemble2le(s.s_magic)
191#define hfsblksize(s) assemble4le(s.s_blksize)
f937adac
NS
192
193#define HPFS_SUPER_MAGIC 0xf995e849
194struct hpfs_super_block {
195 u_char s_magic[4];
196 u_char s_magic2[4];
197};
ebf3db3a 198#define hpfsmagic(s) assemble4le(s.s_magic)
f937adac
NS
199
200struct 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])
ebf3db3a
ES
207
208/* found in first 4 bytes of block 1 */
209struct 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
215struct 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
227struct 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
235struct 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
241static inline int
242assemble2le(unsigned char *p) {
243 return (p[0] | (p[1] << 8));
244}
245
246static inline int
247assemble4le(unsigned char *p) {
248 return (p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24));
249}