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.
17
#include "superblocks.h"
19
#define XENIX_NICINOD 100
20
#define XENIX_NICFREE 100
22
struct xenix_super_block {
26
uint32_t s_free[XENIX_NICFREE];
28
uint16_t s_inode[XENIX_NICINOD];
43
} __attribute__((packed));
46
#define SYSV_NICINOD 100
47
#define SYSV_NICFREE 50
49
struct sysv_super_block
56
uint32_t s_free[SYSV_NICFREE];
59
uint16_t s_inode[SYSV_NICINOD];
77
static int probe_xenix(blkid_probe pr, const struct blkid_idmag *mag)
79
struct xenix_super_block *sb;
81
sb = blkid_probe_get_sb(pr, mag, struct xenix_super_block);
84
blkid_probe_set_label(pr, sb->s_fname, sizeof(sb->s_fname));
88
#define SYSV_BLOCK_SIZE 1024
90
/* Note that we don't probe for Coherent FS, this FS does not have
91
* magic string. (It requires to probe fname/fpack field..)
93
static int probe_sysv(blkid_probe pr, const struct blkid_idmag *mag)
95
struct sysv_super_block *sb;
96
int blocks[] = {0, 9, 15, 18};
99
for (i = 0; i < ARRAY_SIZE(blocks); i++) {
100
int off = blocks[i] * SYSV_BLOCK_SIZE + SYSV_BLOCK_SIZE/2;
102
sb = (struct sysv_super_block *)
103
blkid_probe_get_buffer(pr,
105
sizeof(struct sysv_super_block));
109
if (sb->s_magic == cpu_to_le32(0xfd187e20) ||
110
sb->s_magic == cpu_to_be32(0xfd187e20)) {
112
if (blkid_probe_set_label(pr, sb->s_fname,
113
sizeof(sb->s_fname)))
116
if (blkid_probe_set_magic(pr,
117
off + offsetof(struct sysv_super_block,
120
(unsigned char *) &sb->s_magic))
129
const struct blkid_idinfo xenix_idinfo =
132
.usage = BLKID_USAGE_FILESYSTEM,
133
.probefunc = probe_xenix,
136
{ .magic = "\x2b\x55\x44", .len = 3, .kboff = 1, .sboff = 0x400 },
137
{ .magic = "\x44\x55\x2b", .len = 3, .kboff = 1, .sboff = 0x400 },
142
const struct blkid_idinfo sysv_idinfo =
145
.usage = BLKID_USAGE_FILESYSTEM,
146
.probefunc = probe_sysv,
148
/* SYSV is BE and LE and superblock could be on four positions. It's
149
* simpler to probe for the magic string by .probefunc().
151
.magics = BLKID_NONE_MAGIC