Whamcloud - gitweb
probe.c (probe_ocfs), probe.h: Add support for the Oracle
authorTheodore Ts'o <tytso@mit.edu>
Fri, 5 Mar 2004 00:59:58 +0000 (19:59 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 5 Mar 2004 00:59:58 +0000 (19:59 -0500)
Cluster Filesystem (ocfs).  Patches courtesy of Rusty
Lynch (rusty@linux.co.intel.com).

lib/blkid/ChangeLog
lib/blkid/probe.c
lib/blkid/probe.h

index ecb60d0..9ae3e6e 100644 (file)
@@ -1,3 +1,9 @@
+2004-03-04  Theodore Ts'o  <tytso@mit.edu>
+
+       * probe.c (probe_ocfs), probe.h: Add support for the Oracle
+               Cluster Filesystem (ocfs).  Patches courtesy of Rusty
+               Lynch (rusty@linux.co.intel.com).
+
 2004-03-02  Theodore Ts'o  <tytso@mit.edu>
 
        * getsize.c (blkid_get_dev_size): Update getsize functions to use
index 5b74c31..7bdab6a 100644 (file)
@@ -312,6 +312,33 @@ static int probe_udf(int fd, blkid_cache cache __BLKID_ATTR((unused)),
        return 1;
 }
 
+static int probe_ocfs(int fd __BLKID_ATTR((unused)), 
+                     blkid_cache cache __BLKID_ATTR((unused)), 
+                     blkid_dev dev,
+                     struct blkid_magic *id __BLKID_ATTR((unused)), 
+                     unsigned char *buf)
+{
+       struct ocfs_volume_header ovh;
+       struct ocfs_volume_label ovl;
+       uint major;
+
+       memcpy(&ovh, buf, sizeof(ovh));
+       memcpy(&ovl, buf+512, sizeof(ovl));
+
+       major = ocfsmajor(ovh);
+       if (major == 1)
+               blkid_set_tag(dev,"SEC_TYPE","ocfs1",sizeof("ocfs1"));
+       else if (major == 2)
+               blkid_set_tag(dev,"SEC_TYPE","ocfs2",sizeof("ocfs2"));
+       else if (major >= 9)
+               blkid_set_tag(dev,"SEC_TYPE","ntocfs",sizeof("ntocfs"));
+       
+       blkid_set_tag(dev, "LABEL", ovl.label, ocfslabellen(ovl));
+       blkid_set_tag(dev, "MOUNT", ovh.mount, ocfsmountlen(ovh));
+       set_uuid(dev, ovl.vol_id);
+       return 0;
+}
+
 /*
  * BLKID_BLK_OFFS is at least as large as the highest bim_kboff defined
  * in the type_array table below + bim_kbalign.
@@ -371,6 +398,7 @@ static struct blkid_magic type_array[] = {
   { "swap",     0, 0x1ff6, 10, "SWAPSPACE2",           0 },
   { "swap",     0, 0x3ff6, 10, "SWAP-SPACE",           0 },
   { "swap",     0, 0x3ff6, 10, "SWAPSPACE2",           0 },
+  { "ocfs",     0,      8,  9,  "OracleCFS",  probe_ocfs },
   {   NULL,     0,      0,  0, NULL,                   NULL }
 };
 
index d418aef..7325bc8 100644 (file)
@@ -209,6 +209,31 @@ struct hfs_super_block {
        __u32   h_blksize;
 };
 
+struct ocfs_volume_header {
+       u_char  minor_version[4];
+       u_char  major_version[4];
+       u_char  signature[128];
+       u_char  mount[128];
+       u_char  mount_len[2];
+};
+
+struct ocfs_volume_label {
+       u_char  disk_lock[48];
+       u_char  label[64];      
+       u_char  label_len[2];
+       u_char  vol_id[16];
+       u_char  vol_id_len[2];
+};
+
+#define ocfsmajor(o) ((uint)o.major_version[0] \
+                   + (((uint) o.major_version[1]) << 8) \
+                   + (((uint) o.major_version[2]) << 16) \
+                   + (((uint) o.major_version[3]) << 24))
+#define ocfslabellen(o)        ((uint)o.label_len[0] + (((uint) o.label_len[1]) << 8))
+#define ocfsmountlen(o)        ((uint)o.mount_len[0] + (((uint) o.mount_len[1])<<8))
+
+#define OCFS_MAGIC "OracleCFS"
+
 #define ISODCL(from, to) (to - from + 1)
 struct iso_volume_descriptor {
        char type[ISODCL(1,1)]; /* 711 */