2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
33 #undef XFS_SUPER_MAGIC
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
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. */
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
{
57 #define minixmagic(s) assemble2le(s.s_magic)
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 */
64 char version
[ISODCL(7,7)];
65 char data
[ISODCL(8,2048)];
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)];
77 #define EXT_SUPER_MAGIC 0x137D
78 struct ext_super_block
{
82 #define extmagic(s) assemble2le(s.s_magic)
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
{
91 u_char s_feature_compat
[4];
92 u_char s_feature_incompat
[4];
93 u_char s_feature_ro_compat
[4];
95 u_char s_volume_name
[16];
97 u_char s_journal_inum
[4]; /* ext3 only */
99 #define ext2magic(s) assemble2le(s.s_magic)
101 struct reiserfs_super_block
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];
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)
126 #define _XIAFS_SUPER_MAGIC 0x012FD16D
127 struct xiafs_super_block
{
128 u_char s_boot_segment
[512]; /* 1st sector reserved for boot */
132 #define xiafsmagic(s) assemble4le(s.s_magic)
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];
141 #define ufsmagic(s) assemble4le(s.s_magic)
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
{
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
{
156 u_char s_os
[8]; /* "MSDOS5.0" or "MSWIN4.0" or "MSWIN4.1" */
157 /* mtools-3.9.4 writes "MTOOL394" */
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. */
163 u_char s_label2
[11]; /* for Windows? */
164 u_char s_fs2
[8]; /* garbage or "FAT32 " */
167 #define XFS_SUPER_MAGIC "XFSB"
168 struct xfs_super_block
{
176 #define CRAMFS_SUPER_MAGIC 0x28cd3d45
177 struct cramfs_super_block
{
182 #define cramfsmagic(s) assemble4le(s.s_magic)
184 #define HFS_SUPER_MAGIC 0x4244
185 struct hfs_super_block
{
190 #define hfsmagic(s) assemble2le(s.s_magic)
191 #define hfsblksize(s) assemble4le(s.s_blksize)
193 #define HPFS_SUPER_MAGIC 0xf995e849
194 struct hpfs_super_block
{
198 #define hpfsmagic(s) assemble4le(s.s_magic)
200 struct adfs_super_block
{
204 u_char s_checksum
[1];
206 #define adfsblksize(s) ((uint) s.s_blksize[0])
208 /* found in first 4 bytes of block 1 */
209 struct vxfs_super_block
{
212 #define vxfsmagic(s) assemble4le(s.s_magic)
213 #define VXFS_SUPER_MAGIC 0xa501FCF5
215 struct jfs_super_block
{
224 #define JFS_SUPER1_OFF 0x8000
225 #define JFS_MAGIC "JFS1"
227 struct sysv_super_block
{
228 u_char s_dummy1
[504];
232 #define sysvmagic(s) assemble4le(s.s_magic)
233 #define SYSV_SUPER_MAGIC 0xfd187e20
235 struct mdp_super_block
{
238 #define MD_SB_MAGIC 0xa92b4efc
239 #define mdsbmagic(s) assemble4le(s.md_magic)
242 assemble2le(unsigned char *p
) {
243 return (p
[0] | (p
[1] << 8));
247 assemble4le(unsigned char *p
) {
248 return (p
[0] | (p
[1] << 8) | (p
[2] << 16) | (p
[3] << 24));