Skip to contentSkip to conversation

print parent ID in btrfs suvolume list

PATCH Superseded Andreas Philipp 1 participant 1 message Jun 13, 2011 Btrfs file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 print parent ID in btrfs suvolume list

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.

---
 btrfs-list.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
btrfs-list.c +8 -2
index f804dfc..a57ec4c 100644
@@ -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;
Signature · 1 line
1.7.3.4