path: root/fs
diff options
authorHugh Dickins <>2008-11-19 15:36:38 -0800
committerLinus Torvalds <>2008-11-19 18:49:59 -0800
commitf9454548e17cd56bad081bd7d55a09b001950cbb (patch)
treedd1d2000dbdae6d9baa638d5166b268ec40e8445 /fs
parent63eb6b93ce725e4c5f38fc85dd703d49465b03cb (diff)
don't unlink an active swapfile
Peter Cordes is sorry that he rm'ed his swapfiles while they were in use, he then had no pathname to swapoff. It's a curious little oversight, but not one worth a lot of hackery. Kudos to Willy Tarreau for turning this around from a discussion of synthetic pathnames to how to prevent unlink. Mimic immutable: prohibit unlinking an active swapfile in may_delete() (and don't worry my little head over the tiny race window). Signed-off-by: Hugh Dickins <> Cc: Willy Tarreau <> Acked-by: Christoph Hellwig <> Cc: Peter Cordes <> Cc: Bodo Eggert <> Cc: David Newall <> Cc: Peter Zijlstra <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'fs')
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 09ce58e49e7..d34e0f9681c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1378,7 +1378,7 @@ static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
if (IS_APPEND(dir))
return -EPERM;
if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
- IS_IMMUTABLE(victim->d_inode))
+ IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
return -EPERM;
if (isdir) {
if (!S_ISDIR(victim->d_inode->i_mode))