From patchwork Thu Apr 8 22:47:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: R Harshavardhana X-Patchwork-Id: 91527 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o38MlAIH007828 for ; Thu, 8 Apr 2010 22:47:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933753Ab0DHWrH (ORCPT ); Thu, 8 Apr 2010 18:47:07 -0400 Received: from zp3.zcs.datasyncintra.net ([208.88.241.29]:12420 "EHLO zp3.zcs.datasyncintra.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933751Ab0DHWrF (ORCPT ); Thu, 8 Apr 2010 18:47:05 -0400 Received: from localhost (localhost [127.0.0.1]) by zp3.zcs.datasyncintra.net (Postfix) with ESMTP id A816720C7 for ; Thu, 8 Apr 2010 17:47:04 -0500 (CDT) X-Virus-Scanned: amavisd-new at zp3.zcs.datasyncintra.net Received: from zp3.zcs.datasyncintra.net ([127.0.0.1]) by localhost (zp3.zcs.datasyncintra.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4D0ttIXHo-TJ for ; Thu, 8 Apr 2010 17:47:04 -0500 (CDT) Received: from localhost.localdomain (adsl-99-160-131-163.dsl.pltn13.sbcglobal.net [99.160.131.163]) (Authenticated sender: harsha@gluster.com) by zp3.zcs.datasyncintra.net (Postfix) with ESMTPSA id D6E5E2071 for ; Thu, 8 Apr 2010 17:47:03 -0500 (CDT) From: Harshavardhana To: linux-btrfs@vger.kernel.org Subject: [PATCH][TAKE-1] fs/btrfs: Return EPERM for rmdir on subvolumes and snapshots Date: Thu, 8 Apr 2010 15:47:00 -0700 Message-Id: <1270766820-7345-1-git-send-email-harsha@gluster.com> X-Mailer: git-send-email 1.6.6.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 08 Apr 2010 22:47:21 +0000 (UTC) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a85b90c..465c3de 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2591,9 +2591,11 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) struct btrfs_trans_handle *trans; unsigned long nr = 0; - if (inode->i_size > BTRFS_EMPTY_DIR_SIZE || - inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) - return -ENOTEMPTY; + if (inode->i_size > BTRFS_EMPTY_DIR_SIZE) + return -ENOTEMPTY; + + if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) + return -EPERM; ret = btrfs_reserve_metadata_space(root, 5); if (ret)