aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2009-05-03 19:32:03 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2009-06-11 21:36:06 -0400
commitf3da392e9ff14b9f388e74319e6d195848991c07 (patch)
treed9e7660e5c0b4524aeaafcc5b89a9d68a7ca3817 /fs
parent8c85e125124a473d6f3e9bb187b0b84207f81d91 (diff)
dcache: extrace and use d_unlinked()
d_unlinked() will be used in middle-term to ban checkpointing when opened but unlinked file is detected, and in long term, to detect such situation and special case on it. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/dcache.c7
-rw-r--r--fs/namespace.c8
2 files changed, 7 insertions, 8 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 75659a6fd1f8..9e5cd3c3a6ba 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1910,7 +1910,7 @@ char *__d_path(const struct path *path, struct path *root,
1910 1910
1911 spin_lock(&vfsmount_lock); 1911 spin_lock(&vfsmount_lock);
1912 prepend(&end, &buflen, "\0", 1); 1912 prepend(&end, &buflen, "\0", 1);
1913 if (!IS_ROOT(dentry) && d_unhashed(dentry) && 1913 if (d_unlinked(dentry) &&
1914 (prepend(&end, &buflen, " (deleted)", 10) != 0)) 1914 (prepend(&end, &buflen, " (deleted)", 10) != 0))
1915 goto Elong; 1915 goto Elong;
1916 1916
@@ -2035,7 +2035,7 @@ char *dentry_path(struct dentry *dentry, char *buf, int buflen)
2035 2035
2036 spin_lock(&dcache_lock); 2036 spin_lock(&dcache_lock);
2037 prepend(&end, &buflen, "\0", 1); 2037 prepend(&end, &buflen, "\0", 1);
2038 if (!IS_ROOT(dentry) && d_unhashed(dentry) && 2038 if (d_unlinked(dentry) &&
2039 (prepend(&end, &buflen, "//deleted", 9) != 0)) 2039 (prepend(&end, &buflen, "//deleted", 9) != 0))
2040 goto Elong; 2040 goto Elong;
2041 if (buflen < 1) 2041 if (buflen < 1)
@@ -2097,9 +2097,8 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size)
2097 read_unlock(&current->fs->lock); 2097 read_unlock(&current->fs->lock);
2098 2098
2099 error = -ENOENT; 2099 error = -ENOENT;
2100 /* Has the current directory has been unlinked? */
2101 spin_lock(&dcache_lock); 2100 spin_lock(&dcache_lock);
2102 if (IS_ROOT(pwd.dentry) || !d_unhashed(pwd.dentry)) { 2101 if (!d_unlinked(pwd.dentry)) {
2103 unsigned long len; 2102 unsigned long len;
2104 struct path tmp = root; 2103 struct path tmp = root;
2105 char * cwd; 2104 char * cwd;
diff --git a/fs/namespace.c b/fs/namespace.c
index 120b8a6b99ed..7e537f0393b5 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1384,7 +1384,7 @@ static int graft_tree(struct vfsmount *mnt, struct path *path)
1384 goto out_unlock; 1384 goto out_unlock;
1385 1385
1386 err = -ENOENT; 1386 err = -ENOENT;
1387 if (IS_ROOT(path->dentry) || !d_unhashed(path->dentry)) 1387 if (!d_unlinked(path->dentry))
1388 err = attach_recursive_mnt(mnt, path, NULL); 1388 err = attach_recursive_mnt(mnt, path, NULL);
1389out_unlock: 1389out_unlock:
1390 mutex_unlock(&path->dentry->d_inode->i_mutex); 1390 mutex_unlock(&path->dentry->d_inode->i_mutex);
@@ -1566,7 +1566,7 @@ static int do_move_mount(struct path *path, char *old_name)
1566 if (IS_DEADDIR(path->dentry->d_inode)) 1566 if (IS_DEADDIR(path->dentry->d_inode))
1567 goto out1; 1567 goto out1;
1568 1568
1569 if (!IS_ROOT(path->dentry) && d_unhashed(path->dentry)) 1569 if (d_unlinked(path->dentry))
1570 goto out1; 1570 goto out1;
1571 1571
1572 err = -EINVAL; 1572 err = -EINVAL;
@@ -2129,9 +2129,9 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
2129 error = -ENOENT; 2129 error = -ENOENT;
2130 if (IS_DEADDIR(new.dentry->d_inode)) 2130 if (IS_DEADDIR(new.dentry->d_inode))
2131 goto out2; 2131 goto out2;
2132 if (d_unhashed(new.dentry) && !IS_ROOT(new.dentry)) 2132 if (d_unlinked(new.dentry))
2133 goto out2; 2133 goto out2;
2134 if (d_unhashed(old.dentry) && !IS_ROOT(old.dentry)) 2134 if (d_unlinked(old.dentry))
2135 goto out2; 2135 goto out2;
2136 error = -EBUSY; 2136 error = -EBUSY;
2137 if (new.mnt == root.mnt || 2137 if (new.mnt == root.mnt ||