Wrapfs: support NFS exports
authorErez Zadok <ezk@cs.sunysb.edu>
Sun, 22 May 2016 05:23:47 +0000 (01:23 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Sun, 22 May 2016 05:23:47 +0000 (01:23 -0400)
Based on patch from Sandeep Joshi <sanjos100@gmail.com>.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/wrapfs/lookup.c
fs/wrapfs/main.c
fs/wrapfs/super.c
fs/wrapfs/wrapfs.h

index e4abcbe26b654cb10e9b94f7ea6a02a946385576..95d2dba270c1d5777d8c51c87f5d7d56ddd43caa 100644 (file)
@@ -308,7 +308,7 @@ setup_lower:
         * the VFS will continue the process of making this negative dentry
         * into a positive one.
         */
-       if (flags & (LOOKUP_CREATE|LOOKUP_RENAME_TARGET))
+       if (err == -ENOENT || (flags & (LOOKUP_CREATE|LOOKUP_RENAME_TARGET)))
                err = 0;
 
 out:
index b3042b62a1ade64a4053786bf8e9c9577afe0f41..71d11cf1a5946130c92783df0a19ca4072b30e1f 100644 (file)
@@ -64,6 +64,8 @@ static int wrapfs_read_super(struct super_block *sb, void *raw_data, int silent)
 
        sb->s_op = &wrapfs_sops;
 
+       sb->s_export_op = &wrapfs_export_ops; /* adding NFS support */
+
        /* get a new inode and allocate our root dentry */
        inode = wrapfs_iget(sb, lower_path.dentry->d_inode);
        if (IS_ERR(inode)) {
index 9f90f57be76999515dfff540423abb9e6396ee84..5c99c47eed0b911da54c250d05fba1c299f0b558 100644 (file)
@@ -166,3 +166,43 @@ const struct super_operations wrapfs_sops = {
        .destroy_inode  = wrapfs_destroy_inode,
        .drop_inode     = generic_delete_inode,
 };
+
+/* NFS support */
+
+static struct inode *wrapfs_nfs_get_inode(struct super_block *sb, u64 ino,
+                                         u32 generation)
+{
+       struct super_block *lower_sb;
+       struct inode *inode;
+       struct inode *lower_inode;
+
+       lower_sb = wrapfs_lower_super(sb);
+       lower_inode = ilookup(lower_sb, ino);
+       inode = wrapfs_iget(sb, lower_inode);
+       return inode;
+}
+
+static struct dentry *wrapfs_fh_to_dentry(struct super_block *sb,
+                                         struct fid *fid, int fh_len,
+                                         int fh_type)
+{
+       return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
+                                   wrapfs_nfs_get_inode);
+}
+
+static struct dentry *wrapfs_fh_to_parent(struct super_block *sb,
+                                         struct fid *fid, int fh_len,
+                                         int fh_type)
+{
+       return generic_fh_to_parent(sb, fid, fh_len, fh_type,
+                                   wrapfs_nfs_get_inode);
+}
+
+/*
+ * all other funcs are default as defined in exportfs/expfs.c
+ */
+
+const struct export_operations wrapfs_export_ops = {
+       .fh_to_dentry      = wrapfs_fh_to_dentry,
+       .fh_to_parent      = wrapfs_fh_to_parent
+};
index cb8c0ab18b74afd69e54cb91bbd223fdb1ecf8ca..0e5e34e84ea10433b49099a1f5e90681bc0ba114 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/xattr.h>
+#include <linux/exportfs.h>
 
 /* the file system name */
 #define WRAPFS_NAME "wrapfs"
@@ -47,6 +48,7 @@ extern const struct super_operations wrapfs_sops;
 extern const struct dentry_operations wrapfs_dops;
 extern const struct address_space_operations wrapfs_aops, wrapfs_dummy_aops;
 extern const struct vm_operations_struct wrapfs_vm_ops;
+extern const struct export_operations wrapfs_export_ops;
 
 extern int wrapfs_init_inode_cache(void);
 extern void wrapfs_destroy_inode_cache(void);