From patchwork Mon Jun 13 07:29:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Philipp X-Patchwork-Id: 874072 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5D7UVwq009075 for ; Mon, 13 Jun 2011 07:30:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753349Ab1FMHa2 (ORCPT ); Mon, 13 Jun 2011 03:30:28 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:39355 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753132Ab1FMHa2 (ORCPT ); Mon, 13 Jun 2011 03:30:28 -0400 Received: by wwa36 with SMTP id 36so4548042wwa.1 for ; Mon, 13 Jun 2011 00:30:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer:cc; bh=ERywVQHmNqoGnI9mPmoHWl3H2B6BcJFMFWZVfISt3yo=; b=RxrQicoMedH4n/A8wzWIlEKv2tVvX6rUcfarI1+zr+99Vm0eY7pZKvMsb6fqEsIJcE Hxa6W/q03Kofq9VQ3hptXSO0kb3wkKTvjxgNolCB1atANyUejVdDV/ppJmldvsXl/m+x cNfyYnEyR6jCXlUFP3hbLKAi5kNXspzIqQbzY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=cLS5VkWCSLJ9NCuNuUcahYnxRZG32fpyEj7cztrxGuLoNlGIqa+J3rkVNJGB6WMTzX Aocts0x+FPhBDLBqFYdQS1d2zUqKWF62JEAx7qs8cQP4blXNzNAFiMy648UBc+2NGxOM H9SLp0Y6pwwz6lIF+0yXtJTgx+DvC/lKXcw6g= Received: by 10.216.230.76 with SMTP id i54mr4578110weq.108.1307950227059; Mon, 13 Jun 2011 00:30:27 -0700 (PDT) Received: from localhost.localdomain (84-119-39-73.dynamic.xdsl-line.inode.at [84.119.39.73]) by mx.google.com with ESMTPS id z22sm2713286weq.2.2011.06.13.00.30.26 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 13 Jun 2011 00:30:26 -0700 (PDT) From: Andreas Philipp To: linux-btrfs@vger.kernel.org Cc: Andreas Philipp Subject: [PATCH] print parent ID in btrfs suvolume list Date: Mon, 13 Jun 2011 09:29:52 +0200 Message-Id: <1307950192-15691-1-git-send-email-philipp.andreas@gmail.com> X-Mailer: git-send-email 1.7.3.4 CC: hugo@carfax.org.uk, kreijack@libero.it, stephane_chazelas@yahoo.fr, anthony@xtfx.me 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.6 (demeter1.kernel.org [140.211.167.41]); Mon, 13 Jun 2011 07:30:46 +0000 (UTC) There was some discussion on "where" subvolumes live in. Why do we not simply print the parent ID for each subvolume in btrfs subvolume list. This patch adds this functionality. Signed-off-by: Andreas Philipp --- btrfs-list.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/btrfs-list.c b/btrfs-list.c index f804dfc..a57ec4c 100644 --- a/btrfs-list.c +++ b/btrfs-list.c @@ -203,6 +203,7 @@ static int add_root(struct root_lookup *root_lookup, static int resolve_root(struct root_lookup *rl, struct root_info *ri) { u64 top_id; + u64 parent_id = 0; char *full_path = NULL; int len = 0; struct root_info *found; @@ -233,6 +234,11 @@ static int resolve_root(struct root_lookup *rl, struct root_info *ri) } next = found->ref_tree; + /* record the first parent */ + if ( parent_id == 0 ) { + parent_id = next; + } + /* if the ref_tree refers to ourselves, we're at the top */ if (next == found->root_id) { top_id = next; @@ -249,8 +255,8 @@ static int resolve_root(struct root_lookup *rl, struct root_info *ri) break; } } - printf("ID %llu top level %llu path %s\n", - (unsigned long long)ri->root_id, (unsigned long long)top_id, + printf("ID %llu parent %llu top level %llu path %s\n", + (unsigned long long)ri->root_id, (unsigned long long) parent_id, (unsigned long long)top_id, full_path); free(full_path); return 0;