~ubuntu-branches/ubuntu/trusty/util-linux/trusty-proposed

« back to all changes in this revision

Viewing changes to libblkid/src/superblocks/jfs.c

  • Committer: Package Import Robot
  • Author(s): LaMont Jones
  • Date: 2011-11-03 15:38:23 UTC
  • mto: (4.5.5 sid) (1.6.4)
  • mto: This revision was merged to the branch mainline in revision 85.
  • Revision ID: package-import@ubuntu.com-20111103153823-10sx16jprzxlhkqf
ImportĀ upstreamĀ versionĀ 2.20.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#include <stdio.h>
 
12
#include <stdlib.h>
 
13
#include <unistd.h>
 
14
#include <string.h>
 
15
#include <errno.h>
 
16
#include <ctype.h>
 
17
#include <stdint.h>
 
18
 
 
19
#include "superblocks.h"
 
20
 
 
21
struct jfs_super_block {
 
22
        unsigned char   js_magic[4];
 
23
        uint32_t        js_version;
 
24
        uint64_t        js_size;
 
25
        uint32_t        js_bsize;       /* 4: aggregate block size in bytes */
 
26
        uint16_t        js_l2bsize;     /* 2: log2 of s_bsize */
 
27
        uint16_t        js_l2bfactor;   /* 2: log2(s_bsize/hardware block size) */
 
28
        uint32_t        js_pbsize;      /* 4: hardware/LVM block size in bytes */
 
29
        uint16_t        js_l2pbsize;    /* 2: log2 of s_pbsize */
 
30
        uint16_t        js_pad;         /* 2: padding necessary for alignment */
 
31
        uint32_t        js_dummy2[26];
 
32
        unsigned char   js_uuid[16];
 
33
        unsigned char   js_label[16];
 
34
        unsigned char   js_loguuid[16];
 
35
};
 
36
 
 
37
static int probe_jfs(blkid_probe pr, const struct blkid_idmag *mag)
 
38
{
 
39
        struct jfs_super_block *js;
 
40
 
 
41
        js = blkid_probe_get_sb(pr, mag, struct jfs_super_block);
 
42
        if (!js)
 
43
                return -1;
 
44
        if (le32_to_cpu(js->js_bsize) != (1U << le16_to_cpu(js->js_l2bsize)))
 
45
                return 1;
 
46
        if (le32_to_cpu(js->js_pbsize) != (1U << le16_to_cpu(js->js_l2pbsize)))
 
47
                return 1;
 
48
        if ((le16_to_cpu(js->js_l2bsize) - le16_to_cpu(js->js_l2pbsize)) !=
 
49
            le16_to_cpu(js->js_l2bfactor))
 
50
                return 1;
 
51
 
 
52
        if (strlen((char *) js->js_label))
 
53
                blkid_probe_set_label(pr, js->js_label, sizeof(js->js_label));
 
54
        blkid_probe_set_uuid(pr, js->js_uuid);
 
55
        return 0;
 
56
}
 
57
 
 
58
 
 
59
const struct blkid_idinfo jfs_idinfo =
 
60
{
 
61
        .name           = "jfs",
 
62
        .usage          = BLKID_USAGE_FILESYSTEM,
 
63
        .probefunc      = probe_jfs,
 
64
        .minsz          = 16 * 1024 * 1024,
 
65
        .magics         =
 
66
        {
 
67
                { .magic = "JFS1", .len = 4, .kboff = 32 },
 
68
                { NULL }
 
69
        }
 
70
};
 
71