[klibc] [patch] add iso9660 detection to fstype

David Härdeman david at hardeman.nu
Wed Sep 13 15:31:20 PDT 2006


The attached patch adds iso9660 detection support to fstype.

Signed-off-by: David Härdeman <david at hardeman.nu>

-- 

 fstype.c     |   17 +++++++++++++++++
 iso9660_sb.h |   24 ++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

-------------- next part --------------
diff -Nru klibc/usr/kinit/fstype/fstype.c klibc-hack/usr/kinit/fstype/fstype.c
--- klibc/usr/kinit/fstype/fstype.c	2006-09-14 00:19:41.000000000 +0200
+++ klibc-hack/usr/kinit/fstype/fstype.c	2006-09-14 00:10:01.000000000 +0200
@@ -31,6 +31,7 @@
 #include "xfs_sb.h"
 #include "luks_fs.h"
 #include "lvm2_sb.h"
+#include "iso9660_sb.h"
 
 /*
  * Slightly cleaned up version of jfs_superblock to
@@ -221,6 +222,21 @@
 	return 0;
 }
 
+static int iso_image(const void *buf, unsigned long long *blocks)
+{
+	const struct iso_volume_descriptor *isovd =
+	    (const struct iso_volume_descriptor *)buf;
+	const struct iso_hs_volume_descriptor *isohsvd =
+	    (const struct iso_hs_volume_descriptor *)buf;
+
+	if (!memcmp(isovd->id, ISO_MAGIC, ISO_MAGIC_L) ||
+	    !memcmp(isohsvd->id, ISO_HS_MAGIC, ISO_HS_MAGIC_L)) {
+		*blocks = 0;
+		return 1;
+	}
+	return 0;
+}
+
 struct imagetype {
 	off_t block;
 	const char name[12];
@@ -250,6 +266,7 @@
 	{8, "reiserfs", reiserfs_image},
 	{64, "reiserfs", reiserfs_image},
 	{32, "jfs", jfs_image},
+	{32, "iso9660", iso_image},
 	{0, "luks", luks_image},
 	{0, "lvm2", lvm2_image},
 	{1, "lvm2", lvm2_image},
diff -Nru klibc/usr/kinit/fstype/iso9660_sb.h klibc-hack/usr/kinit/fstype/iso9660_sb.h
--- klibc/usr/kinit/fstype/iso9660_sb.h	1970-01-01 01:00:00.000000000 +0100
+++ klibc-hack/usr/kinit/fstype/iso9660_sb.h	2006-09-14 00:03:28.000000000 +0200
@@ -0,0 +1,24 @@
+#ifndef __ISO9660_SB_H
+#define __ISO9660_SB_H
+
+#define ISO_MAGIC_L	5
+#define ISO_MAGIC	"CD001"
+#define ISO_HS_MAGIC_L	5
+#define ISO_HS_MAGIC	"CDROM"
+
+/* ISO9660 Volume Descriptor */
+struct iso_volume_descriptor {
+	__u8 type;
+	char id[ISO_MAGIC_L];
+	__u8 version;
+};
+
+/* High Sierra Volume Descriptor */
+struct iso_hs_volume_descriptor {
+	char foo[8];
+	__u8 type;
+	char id[ISO_HS_MAGIC_L];
+	__u8 version;
+};
+
+#endif


More information about the klibc mailing list