Whamcloud - gitweb
blkid: Add support for HFS+ detection
authorTheodore Ts'o <tytso@mit.edu>
Sun, 27 Jan 2008 05:21:07 +0000 (00:21 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 27 Jan 2008 05:21:07 +0000 (00:21 -0500)
From SLES 10 patch: e2fsprogs-blkid_probe_hfsplus.patch

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

index 9bde794..492a36a 100644 (file)
@@ -881,6 +881,19 @@ static int probe_gfs2(struct blkid_probe *probe,
        return 1;
 }
 
+static int probe_hfsplus(struct blkid_probe *probe,
+                        struct blkid_magic *id __BLKID_ATTR((unused)),
+                        unsigned char *buf)
+{
+       struct hfs_mdb *sbd = (struct hfs_mdb *)buf;
+
+       /* Check for a HFS+ volume embedded in a HFS volume */
+       if (memcmp(sbd->embed_sig, "H+", 2) == 0)
+               return 0;
+
+       return 1;
+}
+
 /*
  * BLKID_BLK_OFFS is at least as large as the highest bim_kboff defined
  * in the type_array table below + bim_kbalign.
@@ -940,6 +953,8 @@ static struct blkid_magic type_array[] = {
   { "iso9660", 32,      1,  5, "CD001",                probe_iso9660 },
   { "iso9660", 32,      9,  5, "CDROM",                probe_iso9660 },
   { "jfs",     32,      0,  4, "JFS1",                 probe_jfs },
+  { "hfsplus",  1,      0,  2, "BD",                   probe_hfsplus },
+  { "hfsplus",  1,      0,  2, "H+",                   0 },
   { "hfs",      1,      0,  2, "BD",                   0 },
   { "ufs",      8,  0x55c,  4, "T\031\001\000",        0 },
   { "hpfs",     8,      0,  4, "I\350\225\371",        0 },
index 2cbd617..acfe119 100644 (file)
@@ -490,6 +490,48 @@ struct file_attribute {
 #define MFT_RECORD_ATTR_OBJECT_ID              0x40
 #define MFT_RECORD_ATTR_END                    0xffffffffu
 
+/* HFS / HFS+ */
+struct hfs_finder_info {
+        __u32        boot_folder;
+        __u32        start_app;
+        __u32        open_folder;
+        __u32        os9_folder;
+        __u32        reserved;
+        __u32        osx_folder;
+        __u8         id[8];
+} __attribute__((packed));
+
+struct hfs_mdb {
+        __u8         signature[2];
+        __u32        cr_date;
+        __u32        ls_Mod;
+        __u16        atrb;
+        __u16        nm_fls;
+        __u16        vbm_st;
+        __u16        alloc_ptr;
+        __u16        nm_al_blks;
+        __u32        al_blk_size;
+        __u32        clp_size;
+        __u16        al_bl_st;
+        __u32        nxt_cnid;
+        __u16        free_bks;
+        __u8         label_len;
+        __u8         label[27];
+        __u32        vol_bkup;
+        __u16        vol_seq_num;
+        __u32        wr_cnt;
+        __u32        xt_clump_size;
+        __u32        ct_clump_size;
+        __u16        num_root_dirs;
+        __u32        file_count;
+        __u32        dir_count;
+        struct hfs_finder_info finder_info;
+        __u8         embed_sig[2];
+        __u16        embed_startblock;
+        __u16        embed_blockcount;
+} __attribute__((packed));
+
+
 /*
  * Byte swap functions
  */