Sophie

Sophie

distrib > Arklinux > devel > x86_64 > by-pkgid > 5b940e974faae500b8be8331a3cc5064 > files > 26

mkinitrd-5.0.17-24ark.src.rpm

--- mkinitrd-5.0.17/nash/linux_fs.h.jfsuuid~	2002-01-14 02:40:14.000000000 +0100
+++ mkinitrd-5.0.17/nash/linux_fs.h	2009-03-06 21:42:27.173350772 +0100
@@ -141,6 +141,34 @@ struct xfs_super_block {
     unsigned char    s_fname[12];
 };
 
+#define JFS_SUPER_MAGIC "JFS1"
+struct jfs_super_block {
+   unsigned char    js_magic[4];
+   uint32_t         js_version;
+   uint64_t         js_size;
+   uint32_t         js_bsize;
+   uint16_t         js_l2bsize;
+   uint16_t         js_l2bfactor;
+   uint32_t         js_pbsize;
+   uint16_t         js_l2pbsize;
+   uint16_t         js_pad;
+   uint32_t         js_dummy[26];
+   unsigned char    js_uuid[16];
+   unsigned char    js_label[16];
+   unsigned char    js_loguuid[16];
+};
+
+struct swap_id_block {
+   uint32_t         sws_version;
+   uint32_t         sws_lastpage;
+   uint32_t         sws_nrbad;
+   unsigned char    sws_uuid[16];
+   char             sws_volume[16];
+   /* There's also sws_pad and sws_badpg following this,
+    * but since we don't need them, we don't need to waste
+    * space reading them */
+};
+
 #define CRAMFS_SUPER_MAGIC 0x28cd3d45
 struct cramfs_super_block {
 	unsigned char    s_magic[4];
--- mkinitrd-5.0.17/nash/mount_by_label.c.jfsuuid~	2005-11-21 23:48:39.000000000 +0100
+++ mkinitrd-5.0.17/nash/mount_by_label.c	2009-03-06 21:45:29.952561999 +0100
@@ -49,6 +49,8 @@ get_label_uuid(const char *device, char 
 	size_t namesize;
 	struct ext2_super_block e2sb;
 	struct xfs_super_block xfsb;
+	struct jfs_super_block jfsb;
+	char swap[0xffff];
 
 	fd = coeOpen(device, O_RDONLY);
 	if (fd < 0)
@@ -72,6 +74,31 @@ get_label_uuid(const char *device, char 
 			memcpy(*label, xfsb.s_fname, namesize);
 		rv = 0;
 	}
+	else if (lseek(fd, 32768, SEEK_SET) == 32768
+	    && read(fd, (char *) &jfsb, sizeof(jfsb)) == sizeof(jfsb)
+	    && (strncmp((char *)jfsb.js_magic, JFS_SUPER_MAGIC, 4) == 0)) {
+		memcpy(uuid, jfsb.js_uuid, sizeof(jfsb.js_uuid));
+		namesize = sizeof(jfsb.js_label);
+		if ((*label = calloc(namesize + 1, 1)) != NULL)
+			memcpy(*label, jfsb.js_label, namesize);
+		rv = 0;
+	}
+	else if (lseek(fd, 0, SEEK_SET) == 0
+	    && read(fd, swap, sizeof(swap)) == sizeof(swap)
+	    && ((strncmp(swap+0xff6, "SWAPSPACE2", 10) == 0) ||
+                (strncmp(swap+0x1ff6, "SWAPSPACE2", 10) == 0) ||
+	        (strncmp(swap+0x3ff6, "SWAPSPACE2", 10) == 0) ||
+	        (strncmp(swap+0x7ff6, "SWAPSPACE2", 10) == 0) ||
+	        (strncmp(swap+0xfff6, "SWAPSPACE2", 10) == 0))
+	    ) {
+		struct swap_id_block *swb=(struct swap_id_block*)swap+0x400;
+		memcpy(uuid, swb->sws_uuid, sizeof(swb->sws_uuid));
+		namesize = sizeof(swb->sws_volume);
+		if ((*label = calloc(namesize + 1, 1)) != NULL)
+			memcpy(*label, swb->sws_volume, namesize);
+		rv = 0;
+	}
+
 
 	close(fd);
 	return rv;