]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ovl: decode indexed dir file handles
authorAmir Goldstein <amir73il@gmail.com>
Sun, 24 Dec 2017 16:42:16 +0000 (18:42 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Wed, 24 Jan 2018 10:26:03 +0000 (11:26 +0100)
Decoding an indexed dir file handle is done by looking up the file handle
in index dir by name and then decoding the upper dir from the index origin
file handle. The decoded upper path is used to lookup an overlay dentry of
the same path.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/export.c
fs/overlayfs/namei.c
fs/overlayfs/overlayfs.h

index 0bca38c792444b1238706ac48889be649b5a10dc..7a4b6a0fd527d9175b3cab0c3fc6748ecf3abf37 100644 (file)
@@ -461,6 +461,19 @@ static struct dentry *ovl_lower_fh_to_d(struct super_block *sb,
                }
        }
 
+       /* Then try to get upper dir by index */
+       if (index && d_is_dir(index)) {
+               struct dentry *upper = ovl_index_upper(ofs, index);
+
+               err = PTR_ERR(upper);
+               if (IS_ERR_OR_NULL(upper))
+                       goto out_err;
+
+               dentry = ovl_get_dentry(sb, upper, NULL, NULL);
+               dput(upper);
+               goto out;
+       }
+
        /* Then lookup origin by fh */
        err = ovl_check_origin_fh(ofs, fh, NULL, &stack);
        if (err) {
index 741a42d974a354982528389d7c21e43b4fa9434f..6199bf7a77c7435977ca45b9e7f7f31f1ecd2289 100644 (file)
@@ -439,7 +439,7 @@ int ovl_verify_set_fh(struct dentry *dentry, const char *name,
 }
 
 /* Get upper dentry from index */
-static struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index)
+struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index)
 {
        struct ovl_fh *fh;
        struct dentry *upper;
index a47f9142b6be00c38a102f8e765bc2f8eb6e5216..a5d415aec1315a66356dc7df932fdc84ca0f0932 100644 (file)
@@ -270,6 +270,7 @@ int ovl_check_origin_fh(struct ovl_fs *ofs, struct ovl_fh *fh,
                        struct dentry *upperdentry, struct ovl_path **stackp);
 int ovl_verify_set_fh(struct dentry *dentry, const char *name,
                      struct dentry *real, bool is_upper, bool set);
+struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index);
 int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index);
 int ovl_get_index_name(struct dentry *origin, struct qstr *name);
 struct dentry *ovl_get_index_fh(struct ovl_fs *ofs, struct ovl_fh *fh);