From 15fe4400e9e610150d172658555e9e8ff8693192 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 18 Sep 2008 13:23:56 +0200 Subject: [PATCH] blkid: add xfs Signed-off-by: Karel Zak --- libs/blkid/src/probe.c | 1 + libs/blkid/src/probers/Makefile.am | 1 + libs/blkid/src/probers/probers.h | 1 + libs/blkid/src/probers/xfs.c | 69 ++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 libs/blkid/src/probers/xfs.c diff --git a/libs/blkid/src/probe.c b/libs/blkid/src/probe.c index b76eabae..bbcc8be5 100644 --- a/libs/blkid/src/probe.c +++ b/libs/blkid/src/probe.c @@ -53,6 +53,7 @@ static const struct blkid_idinfo *idinfos[] = &ext4_idinfo, &ext3_idinfo, &ext2_idinfo, + &xfs_idinfo, &jfs_idinfo, &jbd_idinfo }; diff --git a/libs/blkid/src/probers/Makefile.am b/libs/blkid/src/probers/Makefile.am index 7f8e04e4..1d36c269 100644 --- a/libs/blkid/src/probers/Makefile.am +++ b/libs/blkid/src/probers/Makefile.am @@ -18,6 +18,7 @@ libprobers_a_SOURCES = probers.h \ via_raid.c \ linux_raid.c \ jfs.c \ + xfs.c \ ext.c all-local: $(lib_LIBRARIES) diff --git a/libs/blkid/src/probers/probers.h b/libs/blkid/src/probers/probers.h index ff3ea3d8..ba4bab7b 100644 --- a/libs/blkid/src/probers/probers.h +++ b/libs/blkid/src/probers/probers.h @@ -34,5 +34,6 @@ extern const struct blkid_idinfo ext3_idinfo; extern const struct blkid_idinfo ext2_idinfo; extern const struct blkid_idinfo jbd_idinfo; extern const struct blkid_idinfo jfs_idinfo; +extern const struct blkid_idinfo xfs_idinfo; #endif /* _BLKID_PROBE_H */ diff --git a/libs/blkid/src/probers/xfs.c b/libs/blkid/src/probers/xfs.c new file mode 100644 index 00000000..47ca31a7 --- /dev/null +++ b/libs/blkid/src/probers/xfs.c @@ -0,0 +1,69 @@ +/* + * Copyright (C) 1999 by Andries Brouwer + * Copyright (C) 1999, 2000, 2003 by Theodore Ts'o + * Copyright (C) 2001 by Andreas Dilger + * Copyright (C) 2004 Kay Sievers + * Copyright (C) 2008 Karel Zak + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "blkidP.h" + +struct xfs_super_block { + unsigned char xs_magic[4]; + uint32_t xs_blocksize; + uint64_t xs_dblocks; + uint64_t xs_rblocks; + uint32_t xs_dummy1[2]; + unsigned char xs_uuid[16]; + uint32_t xs_dummy2[15]; + char xs_fname[12]; + uint32_t xs_dummy3[2]; + uint64_t xs_icount; + uint64_t xs_ifree; + uint64_t xs_fdblocks; +}; + +static int probe_xfs(blkid_probe pr, const struct blkid_idmag *mag) +{ + struct xfs_super_block *xs; + + xs = blkid_probe_get_sb(pr, mag, struct xfs_super_block); + if (!xs) + return -1; + + if (strlen(xs->xs_fname)) + blkid_probe_set_label(pr, xs->xs_fname, sizeof(xs->xs_fname)); + blkid_probe_set_uuid(pr, xs->xs_uuid); + return 0; +} + +const struct blkid_idinfo xfs_idinfo = +{ + .name = "xfs", + .usage = BLKID_USAGE_FILESYSTEM, + .probefunc = probe_xfs, + .magics = + { + { .magic = "XFSB", .len = 4 }, + { NULL } + } +}; + -- 2.39.5