Minix 3 filesystem support

From: Segin
Date: Sun Jan 08 2006 - 21:49:13 EST


The attached email contains diffs for making the Minix version 3 filesystem work with Linux.

Please note that I do not subscribe to the mailing list.

Also, please send all replies about this patch which would normally be emailed to me to the newsgroup comp.os.minix. I did not write this patch, I am just making it available to the Linux kernel mailing list.

The patch author's email address is <danarag@xxxxxxxxx>
--- Begin Message --- I have half succeeded. Read Only by now. I am working on the patch.
Here it is:

diff -ur linux-2.6.14.5/fs/minix/inode.c
modified_linux-2.6.14.5/fs/minix/inode.c
--- linux-2.6.14.5/fs/minix/inode.c 2005-12-27 01:26:33.000000000 +0100
+++ modified_linux-2.6.14.5/fs/minix/inode.c 2006-01-05
14:57:25.000000000 +0100
@@ -7,6 +7,7 @@
* Minix V2 fs support.
*
* Modified for 680x0 by Andreas Schwab
+ * Wrongly updated to version V3 by Daniel. January 5 2006
*/

#include <linux/module.h>
@@ -24,7 +25,6 @@

static void minix_delete_inode(struct inode *inode)
{
- truncate_inode_pages(&inode->i_data, 0);
inode->i_size = 0;
minix_truncate(inode);
minix_free_inode(inode);
@@ -35,7 +35,7 @@
int i;
struct minix_sb_info *sbi = minix_sb(sb);

- if (!(sb->s_flags & MS_RDONLY)) {
+ if (!(sb->s_flags & MS_RDONLY) && (sbi->s_version != MINIX_V3)) {
sbi->s_ms->s_state = sbi->s_mount_state;
mark_buffer_dirty(sbi->s_sbh);
}
@@ -118,19 +118,22 @@
return 0;
/* Mounting a rw partition read-only. */
ms->s_state = sbi->s_mount_state;
- mark_buffer_dirty(sbi->s_sbh);
+ if (sbi->s_version != MINIX_V3)
+ mark_buffer_dirty(sbi->s_sbh);
} else {
/* Mount a partition which is read-only, read-write. */
sbi->s_mount_state = ms->s_state;
ms->s_state &= ~MINIX_VALID_FS;
- mark_buffer_dirty(sbi->s_sbh);
+ if (sbi->s_version != MINIX_V3)
+ mark_buffer_dirty(sbi->s_sbh);
+
+ if (!(sbi->s_mount_state & MINIX_VALID_FS) && (sbi->s_version !=
MINIX_V3))
+ printk ("MINIX-fs warning: remounting unchecked V%i fs, "
+ "running fsck is recommended.\n", sbi->s_version);
+ else if ((sbi->s_mount_state & MINIX_ERROR_FS) && (sbi->s_version !=
MINIX_V3))
+ printk ("MINIX-fs warning: remounting V%i fs with errors, "
+ "running fsck is recommended.\n", sbi->s_version);

- if (!(sbi->s_mount_state & MINIX_VALID_FS))
- printk ("MINIX-fs warning: remounting unchecked fs, "
- "running fsck is recommended.\n");
- else if ((sbi->s_mount_state & MINIX_ERROR_FS))
- printk ("MINIX-fs warning: remounting fs with errors, "
- "running fsck is recommended.\n");
}
return 0;
}
@@ -197,6 +200,23 @@
sbi->s_dirsize = 32;
sbi->s_namelen = 30;
sbi->s_link_max = MINIX2_LINK_MAX;
+ } else if ( *(__u16 *)(bh->b_data + 24) == MINIX3_SUPER_MAGIC) {
+
+ s->s_magic = MINIX3_SUPER_MAGIC;
+ sbi->s_imap_blocks = *(__u16 *)(bh->b_data + 6);
+ sbi->s_zmap_blocks = *(__u16 *)(bh->b_data + 8);
+ sbi->s_firstdatazone = *(__u16 *)(bh->b_data + 10);
+ sbi->s_log_zone_size = *(__u16 *)(bh->b_data + 12);
+ sbi->s_max_size = *(__u32 *)(bh->b_data + 16);
+ sbi->s_nzones = *(__u32 *)(bh->b_data + 20);
+ sbi->s_dirsize = 64;
+ sbi->s_namelen = 60;
+ sbi->s_version = MINIX_V3;
+ sbi->s_link_max = MINIX2_LINK_MAX;
+ if ( *(__u16 *)(bh->b_data + 28) != 1024) {
+ if (!sb_set_blocksize(s,( *(__u16 *)(bh->b_data + 28))))
+ goto out_bad_hblock;
+ }
} else
goto out_no_fs;

@@ -239,16 +259,16 @@
if (!NO_TRUNCATE)
s->s_root->d_op = &minix_dentry_operations;

- if (!(s->s_flags & MS_RDONLY)) {
+ if (!(s->s_flags & MS_RDONLY) && (sbi->s_version != MINIX_V3)) {
ms->s_state &= ~MINIX_VALID_FS;
mark_buffer_dirty(bh);
}
- if (!(sbi->s_mount_state & MINIX_VALID_FS))
- printk ("MINIX-fs: mounting unchecked file system, "
- "running fsck is recommended.\n");
- else if (sbi->s_mount_state & MINIX_ERROR_FS)
- printk ("MINIX-fs: mounting file system with errors, "
- "running fsck is recommended.\n");
+ if (!(sbi->s_mount_state & MINIX_VALID_FS) && (sbi->s_version !=
MINIX_V3))
+ printk ("MINIX-fs: mounting unchecked V%i file system, "
+ "running fsck is recommended.\n", sbi->s_version);
+ else if ((sbi->s_mount_state & MINIX_ERROR_FS) && (sbi->s_version !=
MINIX_V3))
+ printk ("MINIX-fs: mounting V%i file system with errors, "
+ "running fsck is recommended.\n", sbi->s_version);
return 0;

out_iput:
@@ -277,7 +297,7 @@

out_no_fs:
if (!silent)
- printk("VFS: Can't find a Minix or Minix V2 filesystem on device "
+ printk("VFS: Can't find a Minix V1|V2|V3 filesystem on device "
"%s.\n", s->s_id);
out_release:
brelse(bh);
diff -ur linux-2.6.14.5/fs/minix/minix.h
modified_linux-2.6.14.5/fs/minix/minix.h
--- linux-2.6.14.5/fs/minix/minix.h 2005-12-27 01:26:33.000000000 +0100
+++ modified_linux-2.6.14.5/fs/minix/minix.h 2006-01-05
14:55:00.000000000 +0100
@@ -12,6 +12,7 @@

#define MINIX_V1 0x0001 /* original minix fs */
#define MINIX_V2 0x0002 /* minix V2 fs */
+#define MINIX_V3 0x0003 /* minix V3 fs */

/*
* minix fs inode data in memory
diff -ur linux-2.6.14.5/include/linux/minix_fs.h
modified_linux-2.6.14.5/include/linux/minix_fs.h
--- linux-2.6.14.5/include/linux/minix_fs.h 2005-12-27
01:26:33.000000000 +0100
+++ modified_linux-2.6.14.5/include/linux/minix_fs.h 2006-01-05
14:54:06.000000000 +0100
@@ -23,6 +23,7 @@
#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 fs */
#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 fs, 30 char names */
+#define MINIX3_SUPER_MAGIC 0x4d5a /* minix V3 fs */
#define MINIX_VALID_FS 0x0001 /* Clean fs. */
#define MINIX_ERROR_FS 0x0002 /* fs has errors. */

@@ -78,7 +79,7 @@
};

struct minix_dir_entry {
- __u16 inode;
+ __u32 inode;
char name[0];
};


The remaining work is just here at the end in the structure
minix_dir_entry: How to merge the 16 bit pointers to the directories in
the old version with the 32 bit pointers in the new one.

Something will have to be patched also in dir.c


--- End Message ---