瀏覽代碼

ovl: set d->is_dir and d->opaque for last path element

Certain properties in ovl_lookup_data should be set only for the last
element of the path. IOW, if we are calling ovl_lookup_single() for an
absolute redirect, then d->is_dir and d->opaque do not make much sense
for intermediate path elements. Instead set them only if dentry being
lookup is last path element.

As of now we do not seem to be making use of d->opaque if it is set for
a path/dentry in lower. But just define the semantics so that future code
can make use of this assumption.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Vivek Goyal 7 年之前
父節點
當前提交
102b0d11cb
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      fs/overlayfs/namei.c

+ 6 - 2
fs/overlayfs/namei.c

@@ -230,6 +230,7 @@ static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d,
 {
 {
 	struct dentry *this;
 	struct dentry *this;
 	int err;
 	int err;
+	bool last_element = !post[0];
 
 
 	this = lookup_one_len_unlocked(name, base, namelen);
 	this = lookup_one_len_unlocked(name, base, namelen);
 	if (IS_ERR(this)) {
 	if (IS_ERR(this)) {
@@ -257,12 +258,15 @@ static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d,
 			goto put_and_out;
 			goto put_and_out;
 		goto out;
 		goto out;
 	}
 	}
-	d->is_dir = true;
+	if (last_element)
+		d->is_dir = true;
 	if (d->last)
 	if (d->last)
 		goto out;
 		goto out;
 
 
 	if (ovl_is_opaquedir(this)) {
 	if (ovl_is_opaquedir(this)) {
-		d->stop = d->opaque = true;
+		d->stop = true;
+		if (last_element)
+			d->opaque = true;
 		goto out;
 		goto out;
 	}
 	}
 	err = ovl_check_redirect(this, d, prelen, post);
 	err = ovl_check_redirect(this, d, prelen, post);