Commit 2bc334dc authored by Nick Piggin's avatar Nick Piggin

jfs: dont overwrite dentry name in d_revalidate

Use vfat's method for dealing with negative dentries to preserve case,
rather than overwrite dentry name in d_revalidate, which is a bit ugly
and also gets in the way of doing lock-free path walking.
Signed-off-by: default avatarNick Piggin <npiggin@kernel.dk>
parent 79eb4dde
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/namei.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/quotaops.h> #include <linux/quotaops.h>
#include <linux/exportfs.h> #include <linux/exportfs.h>
...@@ -1597,21 +1598,47 @@ static int jfs_ci_compare(struct dentry *dir, struct qstr *a, struct qstr *b) ...@@ -1597,21 +1598,47 @@ static int jfs_ci_compare(struct dentry *dir, struct qstr *a, struct qstr *b)
goto out; goto out;
} }
result = 0; result = 0;
out:
return result;
}
static int jfs_ci_revalidate(struct dentry *dentry, struct nameidata *nd)
{
/* /*
* We want creates to preserve case. A negative dentry, a, that * This is not negative dentry. Always valid.
* has a different case than b may cause a new entry to be created *
* with the wrong case. Since we can't tell if a comes from a negative * Note, rename() to existing directory entry will have ->d_inode,
* dentry, we blindly replace it with b. This should be harmless if * and will use existing name which isn't specified name by user.
* a is not a negative dentry. *
* We may be able to drop this positive dentry here. But dropping
* positive dentry isn't good idea. So it's unsupported like
* rename("filename", "FILENAME") for now.
*/ */
memcpy((unsigned char *)a->name, b->name, a->len); if (dentry->d_inode)
out: return 1;
return result;
/*
* This may be nfsd (or something), anyway, we can't see the
* intent of this. So, since this can be for creation, drop it.
*/
if (!nd)
return 0;
/*
* Drop the negative dentry, in order to make sure to use the
* case sensitive name which is specified by user if this is
* for creation.
*/
if (!(nd->flags & (LOOKUP_CONTINUE | LOOKUP_PARENT))) {
if (nd->flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET))
return 0;
}
return 1;
} }
const struct dentry_operations jfs_ci_dentry_operations = const struct dentry_operations jfs_ci_dentry_operations =
{ {
.d_hash = jfs_ci_hash, .d_hash = jfs_ci_hash,
.d_compare = jfs_ci_compare, .d_compare = jfs_ci_compare,
.d_revalidate = jfs_ci_revalidate,
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment