From 9387c281ef88cd1fba7cb1c9336b5ab00a2d82b4 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 4 Mar 2004 19:59:58 -0500 Subject: [PATCH] probe.c (probe_ocfs), probe.h: Add support for the Oracle Cluster Filesystem (ocfs). Patches courtesy of Rusty Lynch (rusty@linux.co.intel.com). --- lib/blkid/ChangeLog | 6 ++++++ lib/blkid/probe.c | 28 ++++++++++++++++++++++++++++ lib/blkid/probe.h | 25 +++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/lib/blkid/ChangeLog b/lib/blkid/ChangeLog index ecb60d0..9ae3e6e 100644 --- a/lib/blkid/ChangeLog +++ b/lib/blkid/ChangeLog @@ -1,3 +1,9 @@ +2004-03-04 Theodore Ts'o + + * 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 * getsize.c (blkid_get_dev_size): Update getsize functions to use diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index 5b74c31..7bdab6a 100644 --- a/lib/blkid/probe.c +++ b/lib/blkid/probe.c @@ -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 } }; diff --git a/lib/blkid/probe.h b/lib/blkid/probe.h index d418aef..7325bc8 100644 --- a/lib/blkid/probe.h +++ b/lib/blkid/probe.h @@ -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 */ -- 1.8.3.1