From patchwork Fri May 5 22:41:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luke Shumaker X-Patchwork-Id: 166 Return-Path: Delivered-To: patchwork@archlinux.org Received: from nymeria.archlinux.org by nymeria.archlinux.org (Dovecot) with LMTP id GTBtHbP/DFkdHwAAtiB/HQ for ; Sat, 06 May 2017 00:41:55 +0200 Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id 36212404ED; Sat, 6 May 2017 00:41:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on nymeria.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.5 tests=BAYES_00,RCVD_IN_DNSWL_MED shortcircuit=no autolearn=unavailable autolearn_force=no version=3.4.1 Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS; Sat, 6 May 2017 00:41:53 +0200 (CEST) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 29CCA2B07C; Fri, 5 May 2017 22:41:23 +0000 (UTC) Authentication-Results: luna.archlinux.org; dkim=none Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 59C8C2C08E for ; Fri, 5 May 2017 22:41:20 +0000 (UTC) Received: from nymeria.archlinux.org (nymeria.archlinux.org [89.238.67.251]) by luna.archlinux.org (Postfix) with ESMTPS for ; Fri, 5 May 2017 22:41:20 +0000 (UTC) Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id AADEF404C6 for ; Sat, 6 May 2017 00:41:13 +0200 (CEST) Received: from mav.lukeshu.com (mav.lukeshu.com [104.207.138.63]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS for ; Sat, 6 May 2017 00:41:13 +0200 (CEST) Received: from build64-par (unknown [IPv6:2601:803:202:9275:21f:e2ff:fe4d:191b]) by mav.lukeshu.com (Postfix) with ESMTPSA id 8D9F183CF5 for ; Fri, 5 May 2017 18:41:12 -0400 (EDT) From: Luke Shumaker To: arch-projects@archlinux.org Date: Fri, 5 May 2017 18:41:01 -0400 Message-Id: <20170505224110.28990-5-lukeshu@parabola.nu> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170505224110.28990-1-lukeshu@parabola.nu> References: <20170505224110.28990-1-lukeshu@parabola.nu> Subject: [arch-projects] [devtools][PATCH 04/13] lib/archroot.sh: subvolume_delete_recursive: support arbitrary recursion X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Arch Linux projects development discussion Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" X-UID: 384 Status: X-Keywords: Content-Length: 946 The `-xdev` flag to `find` makes it not recurse over subvolumes; so it only supports recursion with depth=1. Fix this by having the function recursively call itself. --- lib/archroot.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/archroot.sh b/lib/archroot.sh index 6b1b52e..3a1023e 100644 --- a/lib/archroot.sh +++ b/lib/archroot.sh @@ -52,11 +52,14 @@ subvolume_delete_recursive() { is_subvolume "$1" || return 0 while IFS= read -d $'\0' -r subvol; do - if ! btrfs subvolume delete "$subvol" &>/dev/null; then - error "Unable to delete subvolume %s" "$subvol" + if ! subvolume_delete_recursive "$subvol"; then return 1 fi - done < <(find "$1" -xdev -depth -inum 256 -print0) + done < <(find "$1" -mindepth 1 -xdev -depth -inum 256 -print0) + if ! btrfs subvolume delete "$1" &>/dev/null; then + error "Unable to delete subvolume %s" "$subvol" + return 1 + fi return 0 }