From patchwork Thu Sep 13 22:04:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 1454381 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 9C9853FE79 for ; Thu, 13 Sep 2012 22:04:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758848Ab2IMWEo (ORCPT ); Thu, 13 Sep 2012 18:04:44 -0400 Received: from cantor2.suse.de ([195.135.220.15]:52326 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754675Ab2IMWEn (ORCPT ); Thu, 13 Sep 2012 18:04:43 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 2AF12A2111 for ; Fri, 14 Sep 2012 00:04:42 +0200 (CEST) Received: by ds.suse.cz (Postfix, from userid 10065) id BDD2774924; Fri, 14 Sep 2012 00:04:41 +0200 (CEST) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH] btrfs: return EPERM upon rmdir on a subvolume Date: Fri, 14 Sep 2012 00:04:34 +0200 Message-Id: <1347573874-10808-1-git-send-email-dsterba@suse.cz> X-Mailer: git-send-email 1.7.6.233.gd79bc Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org A subvolume cannot be deleted via rmdir, but the error code ENOTEMPTY is confusing. Return EPERM instead, as this is not permitted. Signed-off-by: David Sterba --- fs/btrfs/inode.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a4167ef..a67dadd 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3815,9 +3815,10 @@ 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 || - btrfs_ino(inode) == BTRFS_FIRST_FREE_OBJECTID) + if (inode->i_size > BTRFS_EMPTY_DIR_SIZE) return -ENOTEMPTY; + if (btrfs_ino(inode) == BTRFS_FIRST_FREE_OBJECTID) + return -EPERM; trans = __unlink_start_trans(dir, dentry); if (IS_ERR(trans))