From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: [PATCH 14/14] hfsplus: fix rename over directories Date: Fri, 1 Oct 2010 09:28:11 +0200 Message-ID: <20101001072811.GN27055@lst.de> References: <20101001072500.GA26972@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, Vlado Plaga To: viro@zeniv.linux.org.uk, zippel@linux-m68k.org Return-path: Received: from verein.lst.de ([213.95.11.210]:49005 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751917Ab0JAH2V (ORCPT ); Fri, 1 Oct 2010 03:28:21 -0400 Content-Disposition: inline In-Reply-To: <20101001072500.GA26972@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: When renaming over a directory we need to use hfsplus_rmdir instead of hfsplus_unlink to evict the victim. This makes sure we properly error out on non-empty directory as required by Posix (BZ #16571), and it also makes sure we do the right thing in case i_nlink will every be set correctly for directories on hfsplus. Reported-by: Vlado Plaga Signed-off-by: Christoph Hellwig Index: linux-2.6/fs/hfsplus/dir.c =================================================================== --- linux-2.6.orig/fs/hfsplus/dir.c 2010-10-01 09:00:23.246023612 +0200 +++ linux-2.6/fs/hfsplus/dir.c 2010-10-01 09:02:39.409023616 +0200 @@ -452,7 +452,10 @@ static int hfsplus_rename(struct inode * /* Unlink destination if it already exists */ if (new_dentry->d_inode) { - res = hfsplus_unlink(new_dir, new_dentry); + if (S_ISDIR(new_dentry->d_inode->i_mode)) + res = hfsplus_rmdir(new_dir, new_dentry); + else + res = hfsplus_unlink(new_dir, new_dentry); if (res) return res; }