2 * Copyright (C) 2008 Karel Zak <kzak@redhat.com>
4 * This is written from sratch according to Linux kernel fs/sysv/super.c file.
5 * It seems that sysv probing code in libvolume_id and also in the original
8 * This file may be redistributed under the terms of the
9 * GNU Lesser General Public License.
18 #define XENIX_NICINOD 100
19 #define XENIX_NICFREE 100
21 struct xenix_super_block {
25 uint32_t s_free[XENIX_NICFREE];
27 uint16_t s_inode[XENIX_NICINOD];
42 } __attribute__((packed));
45 #define SYSV_NICINOD 100
46 #define SYSV_NICFREE 50
48 struct sysv_super_block
55 uint32_t s_free[SYSV_NICFREE];
58 uint16_t s_inode[SYSV_NICINOD];
76 static int probe_xenix(blkid_probe pr, const struct blkid_idmag *mag)
78 struct xenix_super_block *sb;
80 sb = blkid_probe_get_sb(pr, mag, struct xenix_super_block);
83 blkid_probe_set_label(pr, sb->s_fname, sizeof(sb->s_fname));
87 #define SYSV_BLOCK_SIZE 1024
89 /* Note that we don't probe for Coherent FS, this FS does not have
90 * magic string. (It requires to probe fname/fpack field..)
92 static int probe_sysv(blkid_probe pr, const struct blkid_idmag *mag)
94 struct sysv_super_block *sb;
95 int blocks[] = {0, 9, 15, 18};
98 for (i = 0; i < ARRAY_SIZE(blocks); i++) {
99 int off = blocks[i] * SYSV_BLOCK_SIZE + SYSV_BLOCK_SIZE/2;
101 sb = (struct sysv_super_block *)
102 blkid_probe_get_buffer(pr,
104 sizeof(struct sysv_super_block));
108 if (sb->s_magic == cpu_to_le32(0xfd187e20) ||
109 sb->s_magic == cpu_to_be32(0xfd187e20)) {
110 blkid_probe_set_label(pr, sb->s_fname, sizeof(sb->s_fname));
117 const struct blkid_idinfo xenix_idinfo =
120 .usage = BLKID_USAGE_FILESYSTEM,
121 .probefunc = probe_xenix,
124 { .magic = "\x2b\x55\x44", .len = 3, .kboff = 1, .sboff = 0x400 },
125 { .magic = "\x44\x55\x2b", .len = 3, .kboff = 1, .sboff = 0x400 },
130 const struct blkid_idinfo sysv_idinfo =
133 .usage = BLKID_USAGE_FILESYSTEM,
134 .probefunc = probe_sysv,
136 /* SYSV is BE and LE and superblock could be on four positions. It's
137 * simpler to probe for the magic string by .probefunc().
139 .magics = BLKID_NONE_MAGIC