]> err.no Git - util-linux/commitdiff
blkid: add xfs
authorKarel Zak <kzak@redhat.com>
Thu, 18 Sep 2008 11:23:56 +0000 (13:23 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Feb 2009 22:21:45 +0000 (23:21 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libs/blkid/src/probe.c
libs/blkid/src/probers/Makefile.am
libs/blkid/src/probers/probers.h
libs/blkid/src/probers/xfs.c [new file with mode: 0644]

index b76eabae05e5ae1866400926c267cc518428a22a..bbcc8be50ef054c7fb90398baa3313586b887237 100644 (file)
@@ -53,6 +53,7 @@ static const struct blkid_idinfo *idinfos[] =
        &ext4_idinfo,
        &ext3_idinfo,
        &ext2_idinfo,
+       &xfs_idinfo,
        &jfs_idinfo,
        &jbd_idinfo
 };
index 7f8e04e4bb1d24cb3354e795966c29daec020af2..1d36c26942753060e9cb49ed517d4441cacf9065 100644 (file)
@@ -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)
index ff3ea3d845ea469beba7479510f395a3982c8b15..ba4bab7b0a055e7ec092e370f7c939693c0ee85f 100644 (file)
@@ -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 (file)
index 0000000..47ca31a
--- /dev/null
@@ -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 <kay.sievers@vrfy.org>
+ * Copyright (C) 2008 Karel Zak <kzak@redhat.com>
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <ctype.h>
+#include <stdint.h>
+
+#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 }
+       }
+};
+