UMSDOS patches against 2.2.2

Matija Nalis (mnalis@public.srce.hr)
3 Mar 1999 01:23:11 GMT


Here is diff for UMSDOSFS against kernel 2.2.2 (It was ready in 2.2.1,
but didn't make it in time).

It fixes:

1) different handling of hardlinks in normal and pseudoroot mode
2) enables use of pseudoroot mode with initrd

the thing that remains is bad hardlink moving/modifying problem.
Any ideas are welcome.

diff -ur linux-2.2.2-orig/fs/umsdos/README-WIP.txt linux-2.2.2-my/fs/umsdos/README-WIP.txt
--- linux-2.2.2-orig/fs/umsdos/README-WIP.txt Sun Nov 29 20:43:13 1998
+++ linux-2.2.2-my/fs/umsdos/README-WIP.txt Tue Mar 2 23:01:28 1999
@@ -14,7 +14,7 @@
Legend: those lines marked with '+' on the beggining of line indicates it
passed all of my tests, and performed perfect in all of them.

-Current status (981129) - UMSDOS dentry-pre 0.84:
+Current status (990202) - UMSDOS 0.85:

(1) pure MSDOS (no --linux-.--- EMD file):

@@ -56,7 +56,7 @@

WRITE:
+ create symlink - works
-- create hardlink - works, but see portability WARNING below
+- create hardlink - works
+ create file - works
+ create special file - works
+ write to file - works
@@ -90,24 +90,23 @@
contains hardlinks will break them.

Note: (about pseudoroot) If you are currently trying to use UMSDOS as root
-partition (with linux installed in c:\linux) it will boot, but there are
+partition (with linux installed in c:\linux) it will boot, but there may be
some problems. Volunteers ready to test pseudoroot are needed (preferably
-ones with working backups or unimportant data). There are problems with
-different interpretation of hard links in normal in pseudo-root modes,
-resulting is 'silent delete' of them sometimes. Also, '/DOS' pseudo
+ones with working backups or unimportant data). For example, '/DOS' pseudo
directory is only partially re-implemented and buggy. It works most of the
time, though. Update: should work ok in 0.84, although it still does not
work correctly in combination with initrd featere. Working on this!

-Warning: (about creating hardlinks in pseudoroot mode) - hardlinks created in
-pseudoroot mode are not compatibile with 'normal' hardlinks, and vice versa.
-That is because harlink which is /foo in pseudoroot mode, becomes
-/linux/foo in normal mode. I'm thinking about this one. However, since most
-people either always use pseudoroot, or always use normal umsdos filesystem,
-this is no showstopper.
+Note: (about creating hardlinks in pseudoroot mode) - hardlinks created in
+pseudoroot mode are now again compatibile with 'normal' hardlinks, and vice
+versa. Thanks to Sorin Iordachescu <sorin@rodae.ro> for providing fix.

-Warning: (about hardlinks) - modifying hardlinks (esp. if there are in
+Warning: (about hardlinks) - modifying hardlinks (esp. if they are in
different directories) are currently somewhat broken, I'm working on it.
+Problem seems to be that code uses and updates EMD of directory where 'real
+hardlink' is stored, not EMD of directory where our pseudo-hardlink is
+located! I'm looking for ideas how to work around this in clean way, since
+without it modifying hardlinks in any but most simple ways is broken!

------------------------------------------------------------------------------

diff -ur linux-2.2.2-orig/fs/umsdos/dir.c linux-2.2.2-my/fs/umsdos/dir.c
--- linux-2.2.2-orig/fs/umsdos/dir.c Sun Nov 29 20:43:13 1998
+++ linux-2.2.2-my/fs/umsdos/dir.c Tue Mar 2 22:55:25 1999
@@ -648,10 +648,20 @@
/* N.B. not safe -- fix this soon! */
current->fs->root = dentry->d_sb->s_root;
path = d_path(dentry, buffer, len);
+
+ if (*path == '/')
+ path++; /* skip leading '/' */
+
+ if (old_root->d_inode == pseudo_root)
+ {
+ *(path-1) = '/';
+ path -= (UMSDOS_PSDROOT_LEN+1);
+ memcpy(path, UMSDOS_PSDROOT_NAME, UMSDOS_PSDROOT_LEN);
+ }
+
current->fs->root = old_root;
return path;
}
-

/*
* Return the dentry which points to a pseudo-hardlink.
@@ -696,7 +706,14 @@
/* start at root dentry */
dentry_dst = dget(base);
path[len] = '\0';
- pt = path + 1; /* skip leading '/' */
+
+ pt = path;
+ if (*path == '/')
+ pt++; /* skip leading '/' */
+
+ if (base->d_inode == pseudo_root)
+ pt += (UMSDOS_PSDROOT_LEN + 1);
+
while (1) {
struct dentry *dir = dentry_dst, *demd;
char *start = pt;
diff -ur linux-2.2.2-orig/fs/umsdos/inode.c linux-2.2.2-my/fs/umsdos/inode.c
--- linux-2.2.2-orig/fs/umsdos/inode.c Sun Nov 29 20:43:13 1998
+++ linux-2.2.2-my/fs/umsdos/inode.c Tue Mar 2 22:55:25 1999
@@ -378,7 +378,7 @@
if (!res)
goto out_fail;

- printk (KERN_INFO "UMSDOS dentry-pre 0.84 "
+ printk (KERN_INFO "UMSDOS 0.85 "
"(compatibility level %d.%d, fast msdos)\n",
UMSDOS_VERSION, UMSDOS_RELEASE);

@@ -423,16 +423,20 @@
/*
* Check for an alternate root if we're the root device.
*/
+
+extern kdev_t ROOT_DEV;
static struct dentry *check_pseudo_root(struct super_block *sb)
{
struct dentry *root, *init;

/*
* Check whether we're mounted as the root device.
- * If so, this should be the only superblock.
+ * must check like this, because we can be used with initrd
*/
- if (sb->s_list.next->next != &sb->s_list)
+
+ if (sb->s_dev != ROOT_DEV)
goto out_noroot;
+
printk("check_pseudo_root: mounted as root\n");

root = lookup_dentry(UMSDOS_PSDROOT_NAME, dget(sb->s_root), 0);
diff -ur linux-2.2.2-orig/init/main.c linux-2.2.2-my/init/main.c
--- linux-2.2.2-orig/init/main.c Tue Feb 23 23:54:56 1999
+++ linux-2.2.2-my/init/main.c Tue Mar 2 22:55:25 1999
@@ -1303,21 +1303,6 @@
/* Mount the root filesystem.. */
mount_root();

-#ifdef CONFIG_UMSDOS_FS
- {
- /*
- When mounting a umsdos fs as root, we detect
- the pseudo_root (/linux) and initialise it here.
- pseudo_root is defined in fs/umsdos/inode.c
- */
- extern struct inode *pseudo_root;
- if (pseudo_root != NULL){
- current->fs->root = pseudo_root->i_sb->s_root;
- current->fs->pwd = pseudo_root->i_sb->s_root;
- }
- }
-#endif
-
#ifdef CONFIG_BLK_DEV_INITRD
root_mountflags = real_root_mountflags;
if (mount_initrd && ROOT_DEV != real_root_dev
diff -ur linux-2.2.2-orig/kernel/ksyms.c linux-2.2.2-my/kernel/ksyms.c
--- linux-2.2.2-orig/kernel/ksyms.c Tue Feb 23 23:54:56 1999
+++ linux-2.2.2-my/kernel/ksyms.c Tue Mar 2 22:55:25 1999
@@ -183,6 +183,7 @@
EXPORT_SYMBOL(vfs_unlink);
EXPORT_SYMBOL(vfs_rename);
EXPORT_SYMBOL(__pollwait);
+EXPORT_SYMBOL(ROOT_DEV);

#if !defined(CONFIG_NFSD) && defined(CONFIG_NFSD_MODULE)
EXPORT_SYMBOL(do_nfsservctl);

-- 
Opinions above are GNU-copylefted.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/