]> Git Repo - linux.git/commitdiff
don't unlink an active swapfile
authorHugh Dickins <[email protected]>
Wed, 19 Nov 2008 23:36:38 +0000 (15:36 -0800)
committerLinus Torvalds <[email protected]>
Thu, 20 Nov 2008 02:49:59 +0000 (18:49 -0800)
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 <[email protected]>
Cc: Willy Tarreau <[email protected]>
Acked-by: Christoph Hellwig <[email protected]>
Cc: Peter Cordes <[email protected]>
Cc: Bodo Eggert <[email protected]>
Cc: David Newall <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
fs/namei.c

index 09ce58e49e72bb000004851a1ea23e958b0b917d..d34e0f9681c6557d83852cf04646afbf9e670d98 100644 (file)
@@ -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))
This page took 0.058661 seconds and 4 git commands to generate.