Skip to contentSkip to conversation

Adding ocfs support to blkid

PATCH In review Rusty Lynch 4 participants 10 messages Feb 4, 2004 – Mar 6, 2004 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Adding ocfs support to blkid

The following patch adds ocfs support to blkid.

    --rusty

# This is a BitKeeper generated patch for the following project:
# Project Name: Ext2 filesystem utilities
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:

#	           ChangeSet	1.1327  -> 1.1328 
#	   lib/blkid/probe.c	1.15    -> 1.16   
#	   lib/blkid/probe.h	1.9     -> 1.10   

#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/02/03 [email protected] 1.1328
# Adding support for the Oracle Cluster File System (ocfs) # --------------------------------------------
#

lib/blkid/probe.c +31 -0
diff -Nru a/lib/blkid/probe.c b/lib/blkid/probe.c
@@ -312,6 +312,36 @@
 	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;
+	
+	if (lseek(fd, 0, SEEK_SET) != 0)
+		return -1;
+
+	if (read(fd, (char *) &ovh, sizeof(ovh)) != sizeof(ovh))
+		return -1;
+
+	if (strncmp(ovh.signature, OCFS_MAGIC, sizeof(OCFS_MAGIC)) != 0)
+		return -1;
+
+	if (lseek(fd, 512, SEEK_SET) != 512)
+		return -1;
+
+	if (read(fd, (char *) &ovl, sizeof(ovl)) != sizeof(ovl)) 
+		return -1;
+
+	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 +401,7 @@
   { "swap",	 0, 0x1ff6, 10, "SWAPSPACE2",		0 },
   { "swap",	 0, 0x3ff6, 10, "SWAP-SPACE",		0 },
   { "swap",	 0, 0x3ff6, 10, "SWAPSPACE2",		0 },
+  { "ocfs2",	 0,	 8,  9,	 "OracleCFS",  probe_ocfs },
   {   NULL,	 0,	 0,  0, NULL,			NULL }
 };
 
lib/blkid/probe.h +21 -0
diff -Nru a/lib/blkid/probe.h b/lib/blkid/probe.h
@@ -209,6 +209,27 @@
 	__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 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 lore raw

PATCH 1/1 Adding ocfs support to blkid

Could we call it "ocfs" instead of "ocfs2" below? We will likely be bumping up the version number in the header for ocfs version 2 when it's released.

	--Mark
Quoted 97 lines · Rusty Lynch

The following patch adds ocfs support to blkid.

    --rusty

# This is a BitKeeper generated patch for the following project:
# Project Name: Ext2 filesystem utilities
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:

#	           ChangeSet	1.1327  -> 1.1328 
#	   lib/blkid/probe.c	1.15    -> 1.16   
#	   lib/blkid/probe.h	1.9     -> 1.10   

#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/02/03 [email protected] 1.1328
# Adding support for the Oracle Cluster File System (ocfs) # --------------------------------------------
#
diff -Nru a/lib/blkid/probe.c b/lib/blkid/probe.c

lib/blkid/probe.c +31 -0
@@ -312,6 +312,36 @@
 	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;
+	
+	if (lseek(fd, 0, SEEK_SET) != 0)
+		return -1;
+
+	if (read(fd, (char *) &ovh, sizeof(ovh)) != sizeof(ovh))
+		return -1;
+
+	if (strncmp(ovh.signature, OCFS_MAGIC, sizeof(OCFS_MAGIC)) != 0)
+		return -1;
+
+	if (lseek(fd, 512, SEEK_SET) != 512)
+		return -1;
+
+	if (read(fd, (char *) &ovl, sizeof(ovl)) != sizeof(ovl)) 
+		return -1;
+
+	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 +401,7 @@
   { "swap",	 0, 0x1ff6, 10, "SWAPSPACE2",		0 },
   { "swap",	 0, 0x3ff6, 10, "SWAP-SPACE",		0 },
   { "swap",	 0, 0x3ff6, 10, "SWAPSPACE2",		0 },
+  { "ocfs2",	 0,	 8,  9,	 "OracleCFS",  probe_ocfs },
   {   NULL,	 0,	 0,  0, NULL,			NULL }
 };
 

diff -Nru a/lib/blkid/probe.h b/lib/blkid/probe.h

lib/blkid/probe.h +21 -0
@@ -209,6 +209,27 @@
 	__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 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 */
Quoted 4 lines

_______________________________________________
Ocfs2-devel mailing list
[email protected]
http://oss.oracle.com/mailman/listinfo/ocfs2-devel

--
Mark Fasheh
Software Developer, Oracle Corp
[email protected]

#2 lore raw

PATCH 1/1 Adding ocfs support to blkid

Quoted 2 lines · Mark Fasheh

Could we call it "ocfs" instead of "ocfs2" below? We will likely be bumping up the version number in the header for ocfs version 2 when it's released.

Yeah, call it "ocfs" and set SEC_TYPE to "ocfs1", "ocfs2", and "ntocfs" for version 1, version 2, and windows ocfs, respectively. For ocfs1 the major version is 1, ocfs2 is 2, and ntocfs it's >= 9.

-Manish

Quoted 110 lines · Rusty Lynch
Quoted 97 lines

The following patch adds ocfs support to blkid.

    --rusty

# This is a BitKeeper generated patch for the following project:
# Project Name: Ext2 filesystem utilities
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:

#	           ChangeSet	1.1327  -> 1.1328 
#	   lib/blkid/probe.c	1.15    -> 1.16   
#	   lib/blkid/probe.h	1.9     -> 1.10   

#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/02/03 [email protected] 1.1328
# Adding support for the Oracle Cluster File System (ocfs) # --------------------------------------------
#
diff -Nru a/lib/blkid/probe.c b/lib/blkid/probe.c

lib/blkid/probe.c +31 -0
@@ -312,6 +312,36 @@
 	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;
+	
+	if (lseek(fd, 0, SEEK_SET) != 0)
+		return -1;
+
+	if (read(fd, (char *) &ovh, sizeof(ovh)) != sizeof(ovh))
+		return -1;
+
+	if (strncmp(ovh.signature, OCFS_MAGIC, sizeof(OCFS_MAGIC)) != 0)
+		return -1;
+
+	if (lseek(fd, 512, SEEK_SET) != 512)
+		return -1;
+
+	if (read(fd, (char *) &ovl, sizeof(ovl)) != sizeof(ovl)) 
+		return -1;
+
+	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 +401,7 @@
   { "swap",	 0, 0x1ff6, 10, "SWAPSPACE2",		0 },
   { "swap",	 0, 0x3ff6, 10, "SWAP-SPACE",		0 },
   { "swap",	 0, 0x3ff6, 10, "SWAPSPACE2",		0 },
+  { "ocfs2",	 0,	 8,  9,	 "OracleCFS",  probe_ocfs },
   {   NULL,	 0,	 0,  0, NULL,			NULL }
 };
 

diff -Nru a/lib/blkid/probe.h b/lib/blkid/probe.h

lib/blkid/probe.h +21 -0
@@ -209,6 +209,27 @@
 	__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 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 */
Quoted 4 lines

_______________________________________________
Ocfs2-devel mailing list
[email protected]
http://oss.oracle.com/mailman/listinfo/ocfs2-devel

--
Mark Fasheh
Software Developer, Oracle Corp
[email protected]
_______________________________________________
Ocfs2-devel mailing list
[email protected]
http://oss.oracle.com/mailman/listinfo/ocfs2-devel

#3 lore raw

PATCH 1/1 Adding ocfs support to blkid

Quoted 7 lines · Manish Singh
Quoted 2 lines · Mark Fasheh

Could we call it "ocfs" instead of "ocfs2" below? We will likely be bumping up the version number in the header for ocfs version 2 when it's released.

Yeah, call it "ocfs" and set SEC_TYPE to "ocfs1", "ocfs2", and "ntocfs" for version 1, version 2, and windows ocfs, respectively. For ocfs1 the major version is 1, ocfs2 is 2, and ntocfs it's >= 9.

The current ocfs2 code has major=1 and minor=2... is the increase of the major number just not done yet, or did you mean to switch off the minor?

    --rusty 
#4 lore raw

PATCH 1/1 Adding ocfs support to blkid

Yeah, basically we haven't gotten around to it yet ;) Minor will still be there - for ocfs2 it will be major=2, minor=0

	--Mark
Quoted 5 lines · Rusty Lynch
Quoted 4 lines · Manish Singh
Quoted 2 lines · Mark Fasheh

Could we call it "ocfs" instead of "ocfs2" below? We will likely be bumping up the version number in the header for ocfs version 2 when it's released.

Quoted 8 lines
Quoted 3 lines

Yeah, call it "ocfs" and set SEC_TYPE to "ocfs1", "ocfs2", and "ntocfs" for version 1, version 2, and windows ocfs, respectively. For ocfs1 the major version is 1, ocfs2 is 2, and ntocfs it's >= 9.

The current ocfs2 code has major=1 and minor=2... is the increase of the major number just not done yet, or did you mean to switch off the minor?

    --rusty 

--
Mark Fasheh
Software Developer, Oracle Corp
[email protected]

#5 lore raw

PATCH 1/1 Adding ocfs support to blkid

In reply to Manish Singh
Quoted 7 lines · Manish Singh
Quoted 2 lines · Mark Fasheh

Could we call it "ocfs" instead of "ocfs2" below? We will likely be bumping up the version number in the header for ocfs version 2 when it's released.

Yeah, call it "ocfs" and set SEC_TYPE to "ocfs1", "ocfs2", and "ntocfs" for version 1, version 2, and windows ocfs, respectively. For ocfs1 the major version is 1, ocfs2 is 2, and ntocfs it's >= 9.

Ok, here is a version that adds SEC_TYPE as is described above. An example output is:

[rusty@penguin e2fsprogs]$ sudo ./misc/blkid -c /dev/null /dev/sda1
/dev/sda1: SEC_TYPE="ocfs1" LABEL="FirwireDisk" MOUNT="/oracle" UUID="b88f9d35-d2f5-ffc2-350d-f627cfeb7242" TYPE="ocfs"

Here is the patch...

# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2004/02/04 16:18:29-08:00 [email protected]
# Adding SEC_TYPE for ocfs
#

# lib/blkid/probe.h
#   2004/02/04 16:18:29-08:00 [email protected] +4 -0
#   Adding SEC_TYPE for ocfs
# 
# lib/blkid/probe.c
#   2004/02/04 16:18:29-08:00 [email protected] +10 -1
#   Adding SEC_TYPE for ocfs
# 
# ChangeSet
#   2004/02/04 11:15:08-08:00 [email protected] 
#   Changing name of file system from ocfs2 to ocfs
# 
# lib/blkid/probe.c
#   2004/02/04 11:15:07-08:00 [email protected] +1 -1
#   Changing name of file system from ocfs2 to ocfs
# 
# ChangeSet
#   2004/02/04 00:14:40-08:00 [email protected] 
#   Adding support for the Oracle cluster file system (ocfs)
# 
# BitKeeper/etc/logging_ok
#   2004/02/04 00:14:40-08:00 [email protected] +2 -1
#   Logging to [email protected] accepted
# 
# lib/blkid/probe.h
#   2004/02/04 00:14:24-08:00 [email protected] +21 -0
#   Adding support for the Oracle cluster file system (ocfs)
# 
# lib/blkid/probe.c
#   2004/02/04 00:14:24-08:00 [email protected] +31 -0
#   Adding support for the Oracle cluster file system (ocfs)
# 
diff -Nru a/lib/blkid/probe.c b/lib/blkid/probe.c
--- a/lib/blkid/probe.c	Wed Feb  4 16:19:40 2004
+++ b/lib/blkid/probe.c	Wed Feb  4 16:19:40 2004
@@ -312,6 +312,45 @@
 	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;
+
+ if (lseek(fd, 0, SEEK_SET) != 0)
+ return -1;
+
+ if (read(fd, (char *) &ovh, sizeof(ovh)) != sizeof(ovh))
+ return -1;
+
+ if (strncmp(ovh.signature, OCFS_MAGIC, sizeof(OCFS_MAGIC)) != 0)
+ return -1;
+
+ if (lseek(fd, 512, SEEK_SET) != 512)
+ return -1;
+
+ if (read(fd, (char *) &ovl, sizeof(ovl)) != sizeof(ovl))
+ return -1;
+
+ 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 +410,7 @@
{ "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 }
};

lib/blkid/probe.h +25 -0
diff -Nru a/lib/blkid/probe.h b/lib/blkid/probe.h
@@ -209,6 +209,31 @@
 	__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 */
#6 lore raw

PATCH 1/1 Adding ocfs support to blkid

In reply to Mark Fasheh
Quoted 3 lines · Mark Fasheh

Could we call it "ocfs" instead of "ocfs2" below? We will likely be bumping up the version number in the header for ocfs version 2 when it's released.

	--Mark

Here is a new version of the patch that works for "ocfs" instead of "ocfs2".

    --rusty

# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2004/02/04 11:15:08-08:00 [email protected]
# Changing name of file system from ocfs2 to ocfs
#

# lib/blkid/probe.c
#   2004/02/04 11:15:07-08:00 [email protected] +1 -1
#   Changing name of file system from ocfs2 to ocfs
# 
# ChangeSet
#   2004/02/04 00:14:40-08:00 [email protected] 
#   Adding support for the Oracle cluster file system (ocfs)
# 
# BitKeeper/etc/logging_ok
#   2004/02/04 00:14:40-08:00 [email protected] +2 -1
#   Logging to [email protected] accepted
# 
# lib/blkid/probe.h
#   2004/02/04 00:14:24-08:00 [email protected] +21 -0
#   Adding support for the Oracle cluster file system (ocfs)
# 
# lib/blkid/probe.c
#   2004/02/04 00:14:24-08:00 [email protected] +31 -0
#   Adding support for the Oracle cluster file system (ocfs)
# 
diff -Nru a/lib/blkid/probe.c b/lib/blkid/probe.c
--- a/lib/blkid/probe.c	Wed Feb  4 11:33:23 2004
+++ b/lib/blkid/probe.c	Wed Feb  4 11:33:23 2004
@@ -312,6 +312,36 @@
 	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;
+
+ if (lseek(fd, 0, SEEK_SET) != 0)
+ return -1;
+
+ if (read(fd, (char *) &ovh, sizeof(ovh)) != sizeof(ovh))
+ return -1;
+
+ if (strncmp(ovh.signature, OCFS_MAGIC, sizeof(OCFS_MAGIC)) != 0)
+ return -1;
+
+ if (lseek(fd, 512, SEEK_SET) != 512)
+ return -1;
+
+ if (read(fd, (char *) &ovl, sizeof(ovl)) != sizeof(ovl))
+ return -1;
+
+ 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 +401,7 @@
{ "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 }
};

lib/blkid/probe.h +21 -0
diff -Nru a/lib/blkid/probe.h b/lib/blkid/probe.h
@@ -209,6 +209,27 @@
 	__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 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 */
#7 lore raw
In reply to Rusty Lynch
Quoted 1 line · Rusty Lynch

The following patch adds ocfs support to blkid.

If I'm reading your probe function implementation correctly, you don't actually need to reread the OCFS volume header and label, since the first 1k of the filesystem is passed to the probe function in the buf parameter. This is done deliberately because the blkid library tries very hard to read each part of the filesystem only once.

(There is cache management that goes on in blkid_very_devname() which tries to avoid calling llseek/read needlessly, and that's why we pass the cached buffer to the probe functions.)

- Ted

#8 lore raw
Quoted 9 lines · Theodore Ts'o
Quoted 1 line · Rusty Lynch

The following patch adds ocfs support to blkid.

If I'm reading your probe function implementation correctly, you don't actually need to reread the OCFS volume header and label, since the first 1k of the filesystem is passed to the probe function in the buf parameter. This is done deliberately because the blkid library tries very hard to read each part of the filesystem only once.

Quoted 5 lines

(There is cache management that goes on in blkid_very_devname() which tries to avoid calling llseek/read needlessly, and that's why we pass the cached buffer to the probe functions.)

- Ted

Yea, the first 1k off the disk is all I need. Here is a version that utilizes the passed in buffer and also contains changes for all previous feedback.

    --rusty

# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet

#   2004/02/04 17:40:55-08:00 [email protected] 
#   There was no need to read off the file descriptor since the 'buf'
#   already holds all the data we need (first 1k off disk.)  Changed
#   ocfs probe to utilize the passed in 'buf'.
# 
# lib/blkid/probe.c
#   2004/02/04 17:40:55-08:00 [email protected] +2 -14
#   There was no need to read off the file descriptor since the 'buf'
#   already holds all the data we need (first 1k off disk.)  Changed
#   ocfs probe to utilize the passed in 'buf'.
# 
# ChangeSet
#   2004/02/04 16:18:29-08:00 [email protected] 
#   Adding SEC_TYPE for ocfs
# 
# lib/blkid/probe.h
#   2004/02/04 16:18:29-08:00 [email protected] +4 -0
#   Adding SEC_TYPE for ocfs
# 
# lib/blkid/probe.c
#   2004/02/04 16:18:29-08:00 [email protected] +10 -1
#   Adding SEC_TYPE for ocfs
# 
# ChangeSet
#   2004/02/04 11:15:08-08:00 [email protected] 
#   Changing name of file system from ocfs2 to ocfs
# 
# lib/blkid/probe.c
#   2004/02/04 11:15:07-08:00 [email protected] +1 -1
#   Changing name of file system from ocfs2 to ocfs
# 
# ChangeSet
#   2004/02/04 00:14:40-08:00 [email protected] 
#   Adding support for the Oracle cluster file system (ocfs)
# 
# BitKeeper/etc/logging_ok
#   2004/02/04 00:14:40-08:00 [email protected] +2 -1
#   Logging to [email protected] accepted
# 
# lib/blkid/probe.h
#   2004/02/04 00:14:24-08:00 [email protected] +21 -0
#   Adding support for the Oracle cluster file system (ocfs)
# 
# lib/blkid/probe.c
#   2004/02/04 00:14:24-08:00 [email protected] +31 -0
#   Adding support for the Oracle cluster file system (ocfs)
# 
diff -Nru a/lib/blkid/probe.c b/lib/blkid/probe.c
--- a/lib/blkid/probe.c	Wed Feb  4 17:41:04 2004
+++ b/lib/blkid/probe.c	Wed Feb  4 17:41:04 2004
@@ -312,6 +312,33 @@
 	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 @@
{ "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 }
};

lib/blkid/probe.h +25 -0
diff -Nru a/lib/blkid/probe.h b/lib/blkid/probe.h
@@ -209,6 +209,31 @@
 	__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 */
#9 lore raw
Quoted 3 lines · Rusty Lynch

Yea, the first 1k off the disk is all I need. Here is a version that utilizes the passed in buffer and also contains changes for all previous feedback.

Hi Rusty,

My apologies for the delay in getting back to you. I had a trip to Japan, and when I got back, I was so backlogged that applying this patch fell off my TODO list. It's been committed to the tree now.

- Ted