8000 libblkid: Add scoutfs filesystem. · util-linux/util-linux@cdb4a20 · GitHub
[go: up one dir, main page]

Skip to content

Commit cdb4a20

Browse files
committed
libblkid: Add scoutfs filesystem.
The scoutfs filesystem is maintained out-of-tree, but current enough that we want to submit it for inclusion in libblkid - there's a few users out there that would benefit from being able to have lsblk aid in diagnosing and identifying. For more information about scoutfs, visit the github page here: https://github.com/versity/scoutfs Signed-off-by: Auke Kok <auke.kok@versity.com>
1 parent 49a7b29 commit cdb4a20

File tree

5 files changed

+76
-0
lines changed

5 files changed

+76
-0
lines changed

libblkid/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ lib_blkid_sources = '''
9393
src/superblocks/promise_raid.c
9494
src/superblocks/reiserfs.c
9595
src/superblocks/romfs.c
96+
src/superblocks/scoutfs.c
9697
src/superblocks/silicon_raid.c
9798
src/superblocks/squashfs.c
9899
src/superblocks/stratis.c

libblkid/src/Makemodule.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ libblkid_la_SOURCES = \
8383
libblkid/src/superblocks/promise_raid.c \
8484
libblkid/src/superblocks/reiserfs.c \
8585
libblkid/src/superblocks/romfs.c \
86+
libblkid/src/superblocks/scoutfs.c \
8687
libblkid/src/superblocks/silicon_raid.c \
8788
libblkid/src/superblocks/squashfs.c \
8889
libblkid/src/superb 10000 locks/stratis.c \

libblkid/src/superblocks/scoutfs.c

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (C) 2025 Versity, Inc.
3+
*
4+
* This file may be redistributed under the terms of the
5+
* GNU Lesser General Public License.
6+
*/
7+
8+
#include <inttypes.h>
9+
#include "superblocks.h"
10+
11+
#define SCOUTFS_UUID_BYTES 16
12+
13+
struct scoutfs_block_header {
14+
__le32 crc;
15+
__le32 magic;
16+
__le64 fsid;
17+
__le64 seq;
18+
__le64 blkno;
19+
};
20+
21+
#define SCOUTFS_FLAG_IS_META_BDEV 0x01
22+
23+
struct scoutfs_super_block {
24+
struct scoutfs_block_header hdr;
25+
__le64 id;
26+
__le64 fmt_vers;
27+
__le64 flags;
28+
__u8 uuid[SCOUTFS_UUID_BYTES];
29+
/* rest omitted */
30+
};
31+
32+
static int probe_scoutfs_fs(blkid_probe pr, const struct blkid_idmag *mag)
33+
{
34+
const struct scoutfs_super_block *sb;
35+
36+
sb = blkid_probe_get_sb(pr, mag, struct scoutfs_super_block);
37+
if (sb == NULL)
38+
return errno ? -errno : 1;
39+
40+
blkid_probe_sprintf_version(pr, "%lu", le64_to_cpu(sb->fmt_vers));
41+
42+
blkid_probe_set_uuid(pr, sb->uuid);
43+
44+
if (le64_to_cpu(sb->flags) & SCOUTFS_FLAG_IS_META_BDEV)
45+
blkid_probe_sprintf_value(pr, "SCOUTFS_META_DEVICE", "1");
46+
else
47+
blkid_probe_sprintf_value(pr, "SCOUTFS_DATA_DEVICE", "1");
48+
49+
blkid_probe_sprintf_value(pr, "fsid", "%"PRIx64, le64_to_cpu(sb->hdr.fsid));
50+
51+
return 0;
52+
}
53+
/*
54+
* Scoutfs has a single magic value for the data and the meta
55+
* device. A bit in the superblock identifies which is which.
56+
* The magic value reported to statfs() is also different.
57+
*/
58+
const struct blkid_idinfo scoutfs_idinfo =
59+
{
60+
.name = "scoutfs",
61+
.usage = BLKID_USAGE_FILESYSTEM,
62+
.probefunc = probe_scoutfs_fs,
63+
.magics = {
64+
{
65+
.magic = "\x8b\x42\x3c\x10",
66+
.kboff = 64,
67+
.sboff = 4,
68+
.len = 4,
69+
},
70+
{ NULL }
71+
}
72+
};

libblkid/src/superblocks/superblocks.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ static const struct blkid_idinfo *idinfos[] =
158158
&refs_idinfo,
159159
&cramfs_idinfo,
160160
&romfs_idinfo,
161+
&scoutfs_idinfo,
161162
&minix_idinfo,
162163
&gfs_idinfo,
163164
&gfs2_idinfo,

libblkid/src/superblocks/superblocks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ extern const struct blkid_idinfo exfs_idinfo;
4646
extern const struct blkid_idinfo gfs_idinfo;
4747
extern const struct blkid_idinfo gfs2_idinfo;
4848
extern const struct blkid_idinfo romfs_idinfo;
49+
extern const struct blkid_idinfo scoutfs_idinfo;
4950
extern const struct blkid_idinfo ocfs_idinfo;
5051
extern const struct blkid_idinfo ocfs2_idinfo;
5152
extern const struct blkid_idinfo oracleasm_idinfo;

0 commit comments

Comments
 (0)
0