• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/fstools/libblkid-tiny/btrfs.c

  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 errno ? -errno : 1;
 69 
 70         if (*bfs->label)
 71                 blkid_probe_set_label(pr,
 72                                 (unsigned char *) bfs->label,
 73                                 sizeof(bfs->label) - 1);
 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         .minsz          = 1024 * 1024,
 87         .magics         =
 88         {
 89           { .magic = "_BHRfS_M", .len = 8, .sboff = 0x40, .kboff = 64 },
 90           { NULL }
 91         }
 92 };
 93 
 94 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt