[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mandrake-cooker
Subject:    [Cooker] [util-linux] Reiser4 filesystem patch
From:       Abel Cheung <abel.mdk () gmail ! com>
Date:       2005-05-31 22:14:45
Message-ID: 5d4103bf05053115145714fabe () mail ! gmail ! com
[Download RAW message or body]

Hi,

I have written reiser4 support for util-linux (attached), would
anybody try if it is stable to go upstream or not? AFAIK only
a handful of people can upload util-linux package...

Besides, does anybody know if util-linux upstream maintainer
is still alive or not? All my mails seem to be ignored.

Abel

PS It's more like cut and pasted code from reiserfs 3.x.

["util-linux-reiser4-detect.patch" (text/x-patch)]

--- util-linux-2.12q/fdisk/cfdisk.c.reiser4	2004-12-23 02:06:01.000000000 +0800
+++ util-linux-2.12q/fdisk/cfdisk.c	2005-05-05 18:17:02.095953208 +0800
@@ -53,6 +53,8 @@
  *  ext3 and ReiserFS recognition.
  * Sun Oct 12 17:43:43 CEST 2003 <flavio.stanchina@tin.it>
  *  JFS recognition; ReiserFS label recognition.
+ * Thu May  5 18:15:02 HKT 2005 Abel Cheung <abel@oaka.org>
+ *  Reiser4 label recognition.
  *
  ****************************************************************************/
 
@@ -383,6 +385,8 @@ partition_type_text(int i) {
 	      return _("Linux JFS");
 	 else if (!strcmp(p_info[i].fstype, "reiserfs"))
 	      return _("Linux ReiserFS");
+	 else if (!strcmp(p_info[i].fstype, "reiser4"))
+	      return _("Linux Reiser4");
 	 else
 	      return _("Linux");
     } else if (p_info[i].id == OS2_OR_NTFS) {
@@ -608,6 +612,14 @@ struct reiserfs_super_block {
 };
 #define REISERFSLABELSZ sizeof(reiserfsb.s_label)
 
+#define REISER4_SUPER_MAGIC_STRING "ReIsEr4"
+struct reiser4_super_block {
+	u_char		s_magic[16];
+	u_char		s_dummy[20];
+	u_char		s_label[16];
+};
+#define REISER4LABELSZ sizeof(reiser4sb.s_label)
+
 static int
 has_reiserfs_magic_string(const struct reiserfs_super_block *rs, int *is_3_6) {
 	if (!strncmp(rs->s_magic, REISERFS_SUPER_MAGIC_STRING,
@@ -642,6 +654,7 @@ get_linux_label(int i) {
 
 #define REISERFS_DISK_OFFSET_IN_BYTES (64 * 1024)
 	struct reiserfs_super_block reiserfsb;
+	struct reiser4_super_block reiser4sb;
 	int reiserfs_is_3_6;
 
 #define JFS_SUPER1_OFF	0x8000
@@ -730,6 +743,20 @@ get_linux_label(int i) {
 		strncpy(p_info[i].fstype, "reiserfs", FSTYPESZ);
 		return;
 	}
+
+	/* reiser4? */
+	offset = (p_info[i].first_sector + p_info[i].offset) * SECTOR_SIZE
+		+ REISERFS_DISK_OFFSET_IN_BYTES;
+	if (ext2_llseek(fd, offset, SEEK_SET) == offset
+	    && read(fd, &reiser4sb, 1024) == 1024) {
+		label = reiser4sb.s_label;
+		for(j=0; j<REISER4LABELSZ && j<LABELSZ &&
+			    isprint(label[j]); j++)
+			p_info[i].volume_label[j] = label[j];
+		p_info[i].volume_label[j] = 0;
+		strncpy(p_info[i].fstype, "reiser4", FSTYPESZ);
+		return;
+	}
 }
 
 static void
--- util-linux-2.12q/mount/fstab.5.reiser4	2004-09-28 22:13:42.000000000 +0800
+++ util-linux-2.12q/mount/fstab.5	2005-05-04 23:27:02.251412840 +0800
@@ -118,6 +118,7 @@ of filesystem types, such as
 .IR ntfs ,
 .IR proc ,
 .IR qnx4 ,
+.IR reiser4 ,
 .IR reiserfs ,
 .IR romfs ,
 .IR smbfs ,
--- util-linux-2.12q/mount/linux_fs.h.reiser4	2004-12-22 01:04:08.000000000 +0800
+++ util-linux-2.12q/mount/linux_fs.h	2005-05-05 17:55:08.351395264 +0800
@@ -105,6 +105,15 @@ struct reiserfs_super_block
 
 extern int reiserfs_magic_version(const char *magic);
 
+#define REISER4_SUPER_MAGIC_STRING "ReIsEr4"
+struct reiser4_super_block {
+	u_char		s_magic[16];
+	u_char		s_format[2];
+	u_char		s_blksize[2];
+	u_char		s_uuid[16];
+	u_char		s_label[16];
+};
+
 #define _XIAFS_SUPER_MAGIC 0x012FD16D
 struct xiafs_super_block {
     u_char     s_boot_segment[512];     /*  1st sector reserved for boot */
--- util-linux-2.12q/mount/mount.8.reiser4	2004-12-20 06:30:14.000000000 +0800
+++ util-linux-2.12q/mount/mount.8	2005-05-05 16:29:19.150860528 +0800
@@ -387,6 +387,7 @@ currently supported include:
 .IR proc ,
 .IR qnx4 ,
 .IR ramfs ,
+.IR reiser4 ,
 .IR reiserfs ,
 .IR romfs ,
 .IR smbfs ,
@@ -1407,6 +1408,10 @@ Ramfs is a memory based filesystem. Moun
 and it is gone. Present since Linux 2.3.99pre4.
 There are no mount options.
 
+.SH "Mount options for reiser4"
+Reiser4 is next generation of reiserfs 3.x (see below). Its mount options
+are undocumented so far. They will be updated when available.
+
 .SH "Mount options for reiserfs"
 Reiserfs is a journaling filesystem.
 The reiserfs mount options are more fully described at
--- util-linux-2.12q/mount/get_label_uuid.c.reiser4	2004-12-22 02:55:39.000000000 +0800
+++ util-linux-2.12q/mount/get_label_uuid.c	2005-05-05 17:43:38.333961656 +0800
@@ -59,6 +59,9 @@ reiserfs_magic_version(const char *magic
 	if (!strncmp(magic, REISER3FS_SUPER_MAGIC_STRING, 
 		     strlen(REISER3FS_SUPER_MAGIC_STRING)))
 		rc = 3;
+	if (!strncmp(magic, REISER4_SUPER_MAGIC_STRING, 
+		     strlen(REISER4_SUPER_MAGIC_STRING)))
+		rc = 4;
 	return rc;
 }
 
@@ -97,7 +100,7 @@ is_v1_swap_partition(int fd, char **labe
 
 /*
  * Get both label and uuid.
- * For now, only ext2, ext3, xfs, ocfs, ocfs2, reiserfs, swap are supported
+ * For now, only ext2, ext3, xfs, ocfs, ocfs2, reiser4, reiserfs, swap are supported
  *
  * Return 0 on success.
  */
@@ -111,6 +114,7 @@ get_label_uuid(const char *device, char 
 	struct ocfs_volume_label olbl;
 	struct ocfs2_super_block osb;
 	struct reiserfs_super_block reiserfssb;
+	struct reiser4_super_block reiser4sb;
 	int blksize;
 	int rv = 0;
 
@@ -198,6 +202,16 @@ get_label_uuid(const char *device, char 
 		goto done;
 	}
 
+	if (lseek(fd, REISERFS_DISK_OFFSET_IN_BYTES, SEEK_SET)
+	    == REISERFS_DISK_OFFSET_IN_BYTES
+	    && read(fd, (char *) &reiser4sb, sizeof(reiser4sb))
+	    == sizeof(reiser4sb)) {
+		store_uuid(uuid, reiser4sb.s_uuid);
+		store_label(label, reiser4sb.s_label,
+			    sizeof(reiser4sb.s_label));
+		goto done;
+	}
+
 	for (blksize = OCFS2_MIN_BLOCKSIZE;
 	     blksize <= OCFS2_MAX_BLOCKSIZE;
 	     blksize <<= 1) {
--- util-linux-2.12q/mount/mount_guess_fstype.c.reiser4	2004-11-08 23:21:33.000000000 +0800
+++ util-linux-2.12q/mount/mount_guess_fstype.c	2005-05-05 18:10:03.537583752 +0800
@@ -98,12 +98,13 @@ swapped(unsigned short a) {
     Added sysv - Tim Launchbury
     Added udf - Bryce Nesbitt
     Added ocfs, ocfs2 - Manish Singh - http://oss.oracle.com/projects/ocfs2/
+    Added reiser4 - Abel Cheung <abel@oaka.org>
 */
 static char
 *magic_known[] = {
 	"adfs", "bfs", "cramfs", "efs", "ext", "ext2", "ext3",
 	"hfs", "hpfs", "iso9660", "jfs", "minix", "ntfs", "ocfs", "ocfs2",
-	"qnx4", "reiserfs", "romfs", "swap", "sysv", "udf", "ufs",
+	"qnx4", "reiser4", "reiserfs", "romfs", "swap", "sysv", "udf", "ufs",
 	"vxfs", "xfs", "xiafs"
 };
 
@@ -229,6 +230,7 @@ do_guess_fstype(const char *device) {
 	struct hs_volume_descriptor hs;
     } isosb;
     struct reiserfs_super_block reiserfssb;	/* block 64 or 8 */
+    struct reiser4_super_block reiser4sb;	/* block 64 */
     struct jfs_super_block jfssb;		/* block 32 */
     struct hfs_super_block hfssb;
     struct hpfs_super_block hpfssb;
@@ -444,6 +446,17 @@ do_guess_fstype(const char *device) {
     }
 
     if (!type) {
+	/* block 64 */
+	if (lseek(fd, REISERFS_DISK_OFFSET_IN_BYTES, SEEK_SET) !=
+		REISERFS_DISK_OFFSET_IN_BYTES
+	    || read(fd, (char *) &reiser4sb, sizeof(reiser4sb)) !=
+		sizeof(reiser4sb))
+	    goto io_error;
+	if (reiserfs_magic_version(reiser4sb.s_magic))
+	    type = "reiser4";
+    }
+
+    if (!type) {
 	    int blksize, blkoff;
 
 	    for (blksize = OCFS2_MIN_BLOCKSIZE;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic