Upload Tizen:Base source
[framework/base/util-linux-ng.git] / shlibs / blkid / src / probers / xfs.c
1 /*
2  * Copyright (C) 1999 by Andries Brouwer
3  * Copyright (C) 1999, 2000, 2003 by Theodore Ts'o
4  * Copyright (C) 2001 by Andreas Dilger
5  * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
6  * Copyright (C) 2008 Karel Zak <kzak@redhat.com>
7  *
8  * This file may be redistributed under the terms of the
9  * GNU Lesser General Public License.
10  */
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <unistd.h>
15 #include <string.h>
16 #include <errno.h>
17 #include <ctype.h>
18 #include <stdint.h>
19
20 #include "blkidP.h"
21
22 struct xfs_super_block {
23         unsigned char   xs_magic[4];
24         uint32_t        xs_blocksize;
25         uint64_t        xs_dblocks;
26         uint64_t        xs_rblocks;
27         uint32_t        xs_dummy1[2];
28         unsigned char   xs_uuid[16];
29         uint32_t        xs_dummy2[15];
30         char            xs_fname[12];
31         uint32_t        xs_dummy3[2];
32         uint64_t        xs_icount;
33         uint64_t        xs_ifree;
34         uint64_t        xs_fdblocks;
35 } __attribute__((packed));
36
37 static int probe_xfs(blkid_probe pr, const struct blkid_idmag *mag)
38 {
39         struct xfs_super_block *xs;
40
41         xs = blkid_probe_get_sb(pr, mag, struct xfs_super_block);
42         if (!xs)
43                 return -1;
44
45         if (strlen(xs->xs_fname))
46                 blkid_probe_set_label(pr, (unsigned char *) xs->xs_fname,
47                                 sizeof(xs->xs_fname));
48         blkid_probe_set_uuid(pr, xs->xs_uuid);
49         return 0;
50 }
51
52 const struct blkid_idinfo xfs_idinfo =
53 {
54         .name           = "xfs",
55         .usage          = BLKID_USAGE_FILESYSTEM,
56         .probefunc      = probe_xfs,
57         .magics         =
58         {
59                 { .magic = "XFSB", .len = 4 },
60                 { NULL }
61         }
62 };
63