]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
blkid: add support to recognize f2fs to blkid
authorJeff Sharkey <jsharkey@android.com>
Mon, 14 Mar 2016 20:48:13 +0000 (16:48 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 14 Mar 2016 22:39:13 +0000 (18:39 -0400)
We can now identify f2fs filesystems and extract the UUID.

Addresses-Google-Bug: #20275581

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/blkid/probe.c
lib/blkid/probe.h

index 268124855c861bb561e39d82fbb12a82f10c03bb..77d0899aaf6eed9e7d31c8a771ec793e8b29c8ca 100644 (file)
@@ -1391,6 +1391,18 @@ static int probe_btrfs(struct blkid_probe *probe,
        set_uuid(probe->dev, bs->fsid, 0);
        return 0;
 }
+
+static int probe_f2fs(struct blkid_probe *probe,
+            struct blkid_magic *id,
+            unsigned char *buf)
+{
+    struct f2fs_super_block *bs;
+
+    bs = (struct f2fs_super_block *)buf;
+    set_uuid(probe->dev, bs->uuid, 0);
+    return 0;
+}
+
 /*
  * Various filesystem magics that we can check for.  Note that kboff and
  * sboff are in kilobytes and bytes respectively.  All magics are in
@@ -1499,6 +1511,7 @@ static struct blkid_magic type_array[] = {
   { "lvm2pv",   1,  0x018,  8, "LVM2 001",             probe_lvm2 },
   { "lvm2pv",   1,  0x218,  8, "LVM2 001",             probe_lvm2 },
   { "btrfs",    64,  0x40,  8, "_BHRfS_M",             probe_btrfs },
+  { "f2fs",     1,      0,  4, "\x10\x20\xf5\xf2",     probe_f2fs },
   {   NULL,     0,      0,  0, NULL,                   NULL }
 };
 
index d6809e10b57982548ceb3424e07d815aeb162510..9d026952f1dd1d6d0a50d8e4b20a39f2ec45ba67 100644 (file)
@@ -727,6 +727,42 @@ struct btrfs_super_block {
        __u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
 } __attribute__ ((__packed__));
 
+#define F2FS_MAX_EXTENSION      64  /* # of extension entries */
+
+struct f2fs_super_block {
+    __u32 magic;           /* Magic Number */
+    __u16 major_ver;       /* Major Version */
+    __u16 minor_ver;       /* Minor Version */
+    __u32 log_sectorsize;      /* log2 sector size in bytes */
+    __u32 log_sectors_per_block;   /* log2 # of sectors per block */
+    __u32 log_blocksize;       /* log2 block size in bytes */
+    __u32 log_blocks_per_seg;  /* log2 # of blocks per segment */
+    __u32 segs_per_sec;        /* # of segments per section */
+    __u32 secs_per_zone;       /* # of sections per zone */
+    __u32 checksum_offset;     /* checksum offset inside super block */
+    __u64 block_count;     /* total # of user blocks */
+    __u32 section_count;       /* total # of sections */
+    __u32 segment_count;       /* total # of segments */
+    __u32 segment_count_ckpt;  /* # of segments for checkpoint */
+    __u32 segment_count_sit;   /* # of segments for SIT */
+    __u32 segment_count_nat;   /* # of segments for NAT */
+    __u32 segment_count_ssa;   /* # of segments for SSA */
+    __u32 segment_count_main;  /* # of segments for main area */
+    __u32 segment0_blkaddr;    /* start block address of segment 0 */
+    __u32 cp_blkaddr;      /* start block address of checkpoint */
+    __u32 sit_blkaddr;     /* start block address of SIT */
+    __u32 nat_blkaddr;     /* start block address of NAT */
+    __u32 ssa_blkaddr;     /* start block address of SSA */
+    __u32 main_blkaddr;        /* start block address of main area */
+    __u32 root_ino;        /* root inode number */
+    __u32 node_ino;        /* node inode number */
+    __u32 meta_ino;        /* meta inode number */
+    __u8 uuid[16];          /* 128-bit uuid for volume */
+    __u16 volume_name[512];    /* volume name */
+    __u32 extension_count;     /* # of extensions below */
+    __u8 extension_list[F2FS_MAX_EXTENSION][8]; /* extension array */
+} __attribute__((__packed__));
+
 /*
  * Byte swap functions
  */