lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1412798740-18881-1-git-send-email-fabf@skynet.be>
Date:	Wed,  8 Oct 2014 22:05:40 +0200
From:	Fabian Frederick <fabf@...net.be>
To:	linux-kernel@...r.kernel.org
Cc:	Fabian Frederick <fabf@...net.be>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: [RFC 1/1 linux-next] fs/affs: only call remove_header on empty directory

affs_rmdir unconditionally called affs_remove_header which had to check stype
then directory emptiness.

This patch directly checks for directory status(like ext filesystems)

remove_header is also called by affs_unlink and affs_rename but
switch(stype) seems no longer needed.

Cc: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Fabian Frederick <fabf@...net.be>
---
 fs/affs/affs.h     |  1 +
 fs/affs/amigaffs.c | 18 +-----------------
 fs/affs/namei.c    | 11 +++++++++--
 3 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index 9bca881..3a7f287 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -130,6 +130,7 @@ void affs_mark_sb_dirty(struct super_block *sb);
 extern int	affs_insert_hash(struct inode *inode, struct buffer_head *bh);
 extern int	affs_remove_hash(struct inode *dir, struct buffer_head *rem_bh);
 extern int	affs_remove_header(struct dentry *dentry);
+extern int	affs_empty_dir(struct inode *inode);
 extern u32	affs_checksum_block(struct super_block *sb, struct buffer_head *bh);
 extern void	affs_fix_checksum(struct super_block *sb, struct buffer_head *bh);
 extern void	secs_to_datestamp(time_t secs, struct affs_date *ds);
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index abc8539..9288d28 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -229,7 +229,7 @@ done:
 }
 
 
-static int
+int
 affs_empty_dir(struct inode *inode)
 {
 	struct super_block *sb = inode->i_sb;
@@ -286,22 +286,6 @@ affs_remove_header(struct dentry *dentry)
 
 	affs_lock_link(inode);
 	affs_lock_dir(dir);
-	switch (be32_to_cpu(AFFS_TAIL(sb, bh)->stype)) {
-	case ST_USERDIR:
-		/* if we ever want to support links to dirs
-		 * i_hash_lock of the inode must only be
-		 * taken after some checks
-		 */
-		affs_lock_dir(inode);
-		retval = affs_empty_dir(inode);
-		affs_unlock_dir(inode);
-		if (retval)
-			goto done_unlock;
-		break;
-	default:
-		break;
-	}
-
 	retval = affs_remove_hash(dir, bh);
 	if (retval)
 		goto done_unlock;
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index 035bd31..b352f78 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -321,11 +321,18 @@ affs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 int
 affs_rmdir(struct inode *dir, struct dentry *dentry)
 {
+	struct inode *inode = dentry->d_inode;
+	int retval;
+
 	pr_debug("%s(dir=%u, %lu \"%.*s\")\n",
 		__func__, (u32)dir->i_ino, dentry->d_inode->i_ino,
 		 (int)dentry->d_name.len, dentry->d_name.name);
-
-	return affs_remove_header(dentry);
+	affs_lock_dir(inode);
+	retval = affs_empty_dir(inode);
+	affs_unlock_dir(inode);
+	if (!retval)
+		retval = affs_remove_header(dentry);
+	return retval;
 }
 
 int
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ