aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2014-04-01 11:08:41 -0400
committerMiklos Szeredi <mszeredi@suse.cz>2014-04-01 11:08:41 -0400
commit44b1d53043c482225196e8a9cd9f35163a1b3336 (patch)
treefe41d2e81747b987d19ab39251cec8e2dac7964e /fs/namei.c
parent455c6fdbd219161bd09b1165f11699d6d73de11c (diff)
vfs: add d_is_dir()
Add d_is_dir(dentry) helper which is analogous to S_ISDIR(). To avoid confusion, rename d_is_directory() to d_can_lookup(). Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Reviewed-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 4b491b431990..e987ea7c305f 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1796,7 +1796,7 @@ static int link_path_walk(const char *name, struct nameidata *nd)
1796 if (err) 1796 if (err)
1797 return err; 1797 return err;
1798 } 1798 }
1799 if (!d_is_directory(nd->path.dentry)) { 1799 if (!d_can_lookup(nd->path.dentry)) {
1800 err = -ENOTDIR; 1800 err = -ENOTDIR;
1801 break; 1801 break;
1802 } 1802 }
@@ -1817,7 +1817,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
1817 struct dentry *root = nd->root.dentry; 1817 struct dentry *root = nd->root.dentry;
1818 struct inode *inode = root->d_inode; 1818 struct inode *inode = root->d_inode;
1819 if (*name) { 1819 if (*name) {
1820 if (!d_is_directory(root)) 1820 if (!d_can_lookup(root))
1821 return -ENOTDIR; 1821 return -ENOTDIR;
1822 retval = inode_permission(inode, MAY_EXEC); 1822 retval = inode_permission(inode, MAY_EXEC);
1823 if (retval) 1823 if (retval)
@@ -1873,7 +1873,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
1873 dentry = f.file->f_path.dentry; 1873 dentry = f.file->f_path.dentry;
1874 1874
1875 if (*name) { 1875 if (*name) {
1876 if (!d_is_directory(dentry)) { 1876 if (!d_can_lookup(dentry)) {
1877 fdput(f); 1877 fdput(f);
1878 return -ENOTDIR; 1878 return -ENOTDIR;
1879 } 1879 }
@@ -1955,7 +1955,7 @@ static int path_lookupat(int dfd, const char *name,
1955 err = complete_walk(nd); 1955 err = complete_walk(nd);
1956 1956
1957 if (!err && nd->flags & LOOKUP_DIRECTORY) { 1957 if (!err && nd->flags & LOOKUP_DIRECTORY) {
1958 if (!d_is_directory(nd->path.dentry)) { 1958 if (!d_can_lookup(nd->path.dentry)) {
1959 path_put(&nd->path); 1959 path_put(&nd->path);
1960 err = -ENOTDIR; 1960 err = -ENOTDIR;
1961 } 1961 }
@@ -2414,11 +2414,11 @@ static int may_delete(struct inode *dir, struct dentry *victim, bool isdir)
2414 IS_IMMUTABLE(inode) || IS_SWAPFILE(inode)) 2414 IS_IMMUTABLE(inode) || IS_SWAPFILE(inode))
2415 return -EPERM; 2415 return -EPERM;
2416 if (isdir) { 2416 if (isdir) {
2417 if (!d_is_directory(victim) && !d_is_autodir(victim)) 2417 if (!d_is_dir(victim))
2418 return -ENOTDIR; 2418 return -ENOTDIR;
2419 if (IS_ROOT(victim)) 2419 if (IS_ROOT(victim))
2420 return -EBUSY; 2420 return -EBUSY;
2421 } else if (d_is_directory(victim) || d_is_autodir(victim)) 2421 } else if (d_is_dir(victim))
2422 return -EISDIR; 2422 return -EISDIR;
2423 if (IS_DEADDIR(dir)) 2423 if (IS_DEADDIR(dir))
2424 return -ENOENT; 2424 return -ENOENT;
@@ -3016,11 +3016,10 @@ finish_open:
3016 } 3016 }
3017 audit_inode(name, nd->path.dentry, 0); 3017 audit_inode(name, nd->path.dentry, 0);
3018 error = -EISDIR; 3018 error = -EISDIR;
3019 if ((open_flag & O_CREAT) && 3019 if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry))
3020 (d_is_directory(nd->path.dentry) || d_is_autodir(nd->path.dentry)))
3021 goto out; 3020 goto out;
3022 error = -ENOTDIR; 3021 error = -ENOTDIR;
3023 if ((nd->flags & LOOKUP_DIRECTORY) && !d_is_directory(nd->path.dentry)) 3022 if ((nd->flags & LOOKUP_DIRECTORY) && !d_can_lookup(nd->path.dentry))
3024 goto out; 3023 goto out;
3025 if (!S_ISREG(nd->inode->i_mode)) 3024 if (!S_ISREG(nd->inode->i_mode))
3026 will_truncate = false; 3025 will_truncate = false;
@@ -3744,7 +3743,7 @@ exit1:
3744slashes: 3743slashes:
3745 if (d_is_negative(dentry)) 3744 if (d_is_negative(dentry))
3746 error = -ENOENT; 3745 error = -ENOENT;
3747 else if (d_is_directory(dentry) || d_is_autodir(dentry)) 3746 else if (d_is_dir(dentry))
3748 error = -EISDIR; 3747 error = -EISDIR;
3749 else 3748 else
3750 error = -ENOTDIR; 3749 error = -ENOTDIR;
@@ -4123,7 +4122,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
4123 struct inode **delegated_inode) 4122 struct inode **delegated_inode)
4124{ 4123{
4125 int error; 4124 int error;
4126 int is_dir = d_is_directory(old_dentry) || d_is_autodir(old_dentry); 4125 int is_dir = d_is_dir(old_dentry);
4127 const unsigned char *old_name; 4126 const unsigned char *old_name;
4128 4127
4129 if (old_dentry->d_inode == new_dentry->d_inode) 4128 if (old_dentry->d_inode == new_dentry->d_inode)
@@ -4216,7 +4215,7 @@ retry_deleg:
4216 if (d_is_negative(old_dentry)) 4215 if (d_is_negative(old_dentry))
4217 goto exit4; 4216 goto exit4;
4218 /* unless the source is a directory trailing slashes give -ENOTDIR */ 4217 /* unless the source is a directory trailing slashes give -ENOTDIR */
4219 if (!d_is_directory(old_dentry) && !d_is_autodir(old_dentry)) { 4218 if (!d_is_dir(old_dentry)) {
4220 error = -ENOTDIR; 4219 error = -ENOTDIR;
4221 if (oldnd.last.name[oldnd.last.len]) 4220 if (oldnd.last.name[oldnd.last.len])
4222 goto exit4; 4221 goto exit4;