~ubuntu-branches/ubuntu/maverick/util-linux/maverick-security

« back to all changes in this revision

Viewing changes to shlibs/blkid/src/superblocks/btrfs.c

Tags: 2.17-0ubuntu1
* Merge from Debian experimental, remaining changes:
  - Since udev is required in Ubuntu, the hwclock.sh init script is
    not called on startup and the hwclockfirst.sh init script is
    removed.
  - Remove /etc/adjtime on upgrade if it was not used.
  - Install custom blkid.conf to use /dev/.blkid.tab since we don't
    expect device names to survive a reboot
  - No lsb_release call in mount.preinst since we'd need Pre-Depends
    (LP: #383697).
  - Do not install initramfs hook, since our initramfs already handles
    including blkid.
  - Mention mountall(8) in fstab(5) manpages, along with its special
    options.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
 
3
 *
 
4
 * This file may be redistributed under the terms of the
 
5
 * GNU Lesser General Public License.
 
6
 */
 
7
#include <stdio.h>
 
8
#include <stdlib.h>
 
9
#include <unistd.h>
 
10
#include <string.h>
 
11
#include <stdint.h>
 
12
 
 
13
#include "superblocks.h"
 
14
 
 
15
struct btrfs_super_block {
 
16
        uint8_t csum[32];
 
17
        uint8_t fsid[16];
 
18
        uint64_t bytenr;
 
19
        uint64_t flags;
 
20
        uint8_t magic[8];
 
21
        uint64_t generation;
 
22
        uint64_t root;
 
23
        uint64_t chunk_root;
 
24
        uint64_t log_root;
 
25
        uint64_t log_root_transid;
 
26
        uint64_t total_bytes;
 
27
        uint64_t bytes_used;
 
28
        uint64_t root_dir_objectid;
 
29
        uint64_t num_devices;
 
30
        uint32_t sectorsize;
 
31
        uint32_t nodesize;
 
32
        uint32_t leafsize;
 
33
        uint32_t stripesize;
 
34
        uint32_t sys_chunk_array_size;
 
35
        uint64_t chunk_root_generation;
 
36
        uint64_t compat_flags;
 
37
        uint64_t compat_ro_flags;
 
38
        uint64_t incompat_flags;
 
39
        uint16_t csum_type;
 
40
        uint8_t root_level;
 
41
        uint8_t chunk_root_level;
 
42
        uint8_t log_root_level;
 
43
        struct btrfs_dev_item {
 
44
                uint64_t devid;
 
45
                uint64_t total_bytes;
 
46
                uint64_t bytes_used;
 
47
                uint32_t io_align;
 
48
                uint32_t io_width;
 
49
                uint32_t sector_size;
 
50
                uint64_t type;
 
51
                uint64_t generation;
 
52
                uint64_t start_offset;
 
53
                uint32_t dev_group;
 
54
                uint8_t seek_speed;
 
55
                uint8_t bandwidth;
 
56
                uint8_t uuid[16];
 
57
                uint8_t fsid[16];
 
58
        } __attribute__ ((__packed__)) dev_item;
 
59
        uint8_t label[256];
 
60
} __attribute__ ((__packed__));
 
61
 
 
62
static int probe_btrfs(blkid_probe pr, const struct blkid_idmag *mag)
 
63
{
 
64
        struct btrfs_super_block *bfs;
 
65
 
 
66
        bfs = blkid_probe_get_sb(pr, mag, struct btrfs_super_block);
 
67
        if (!bfs)
 
68
                return -1;
 
69
 
 
70
        if (*bfs->label)
 
71
                blkid_probe_set_label(pr,
 
72
                                (unsigned char *) bfs->label,
 
73
                                sizeof(bfs->label));
 
74
 
 
75
        blkid_probe_set_uuid(pr, bfs->fsid);
 
76
        blkid_probe_set_uuid_as(pr, bfs->dev_item.uuid, "UUID_SUB");
 
77
 
 
78
        return 0;
 
79
}
 
80
 
 
81
const struct blkid_idinfo btrfs_idinfo =
 
82
{
 
83
        .name           = "btrfs",
 
84
        .usage          = BLKID_USAGE_FILESYSTEM,
 
85
        .probefunc      = probe_btrfs,
 
86
        .magics         =
 
87
        {
 
88
                { .magic = "_BHRfS_M", .len = 8, .kboff = 64, .sboff = 0x40 },
 
89
                { NULL }
 
90
        }
 
91
};
 
92