patch for allowing msdos/vfat nfs exports

Nathan Laredo (nlaredo@transmeta.com)
Mon, 23 Jul 2001 16:55:17 -0700 (PDT)


Linus was nice enough to change the kernel this morning for me
to allow msdos/vfat NFS exports. Since this is totally new code
and there is no guarantee it won't destroy everything on your
fat filesystem he asked me to post the diff to the kernel mailing
list so more people could look at it/test it out before it goes
back into the standard kernel.

The patch below is relative to Linus' current working tree
(which should be the same 2.4.7 in theory).

I've been using it for half a day now and so far it hasn't done
anything bad, but please be careful if you decide to test it and
backup your data and after testing, be sure to compare your data
to your backup.

Note: this patch will NOT work for older kernels. dentry_to_fh and
fh_to_dentry are provided (just as in reiserfs).

Please send me email directly with your experiences using this patch
since I offered to collect them for Linus.

-- Nathan Laredo
nlaredo@transmeta.com

diff -r -u linux/fs/fat/inode.c linux-new/fs/fat/inode.c
--- linux/fs/fat/inode.c Mon Jun 11 19:15:27 2001
+++ linux-new/fs/fat/inode.c Mon Jul 23 14:35:41 2001
@@ -403,12 +403,60 @@
inode->i_nlink = fat_subdirs(inode)+2;
}

+static int fat_dentry_to_fh(struct dentry *dentry, __u32 *data, int *lenp, int need_parent)
+{
+ struct inode *inode = dentry->d_inode;
+ unsigned int i_pos = MSDOS_I(inode)->i_location;
+
+ *data = i_pos;
+ *lenp = 1;
+ return 1;
+}
+
+static struct dentry *fat_fh_to_dentry(struct super_block *sb, __u32 *data, int len, int fhtype, int parent)
+{
+ struct list_head *lp;
+ struct dentry *result;
+ unsigned int i_pos = data[0];
+ struct inode *inode;
+
+ inode = fat_iget(sb, i_pos);
+
+ if (!inode)
+ return ERR_PTR(-ESTALE);
+
+ /* now to find a dentry.
+ * If possible, get a well-connected one
+ */
+ spin_lock(&dcache_lock);
+ for (lp = inode->i_dentry.next; lp != &inode->i_dentry ; lp=lp->next) {
+ result = list_entry(lp,struct dentry, d_alias);
+ if (! (result->d_flags & DCACHE_NFSD_DISCONNECTED)) {
+ dget_locked(result);
+ result->d_vfs_flags |= DCACHE_REFERENCED;
+ spin_unlock(&dcache_lock);
+ iput(inode);
+ return result;
+ }
+ }
+ spin_unlock(&dcache_lock);
+ result = d_alloc_root(inode);
+ if (result == NULL) {
+ iput(inode);
+ return ERR_PTR(-ENOMEM);
+ }
+ result->d_flags |= DCACHE_NFSD_DISCONNECTED;
+ return result;
+}
+
static struct super_operations fat_sops = {
write_inode: fat_write_inode,
delete_inode: fat_delete_inode,
put_super: fat_put_super,
statfs: fat_statfs,
clear_inode: fat_clear_inode,
+ fh_to_dentry: fat_fh_to_dentry,
+ dentry_to_fh: fat_dentry_to_fh
};

/*

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