From 6055e736045d7e1f83ea77551941c7745ad36ec2 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Wed, 2 Nov 2011 11:42:30 -0400 Subject: Btrfs-progs: added ioctls and commands to resolve inodes and logical addrs two new commands that make use of the new path resolving functions implemented for scrub, doing the resolving in-kernel. the result for both commands is a list of files belonging to that inode / logical address. Signed-off-by: Jan Schmidt Signed-off-by: Chris Mason --- btrfs-list.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'btrfs-list.c') diff --git a/btrfs-list.c b/btrfs-list.c index 5751f1dd..5f4a9bea 100644 --- a/btrfs-list.c +++ b/btrfs-list.c @@ -899,3 +899,38 @@ int find_updated_files(int fd, u64 root_id, u64 oldest_gen) printf("transid marker was %llu\n", (unsigned long long)max_found); return ret; } + +char *path_for_root(int fd, u64 root) +{ + struct root_lookup root_lookup; + struct rb_node *n; + char *ret_path = NULL; + int ret; + + ret = __list_subvol_search(fd, &root_lookup); + if (ret < 0) + return ERR_PTR(ret); + + ret = __list_subvol_fill_paths(fd, &root_lookup); + if (ret < 0) + return ERR_PTR(ret); + + n = rb_last(&root_lookup.root); + while (n) { + struct root_info *entry; + u64 root_id; + u64 parent_id; + u64 level; + char *path; + entry = rb_entry(n, struct root_info, rb_node); + resolve_root(&root_lookup, entry, &root_id, &parent_id, &level, + &path); + if (root_id == root) + ret_path = path; + else + free(path); + n = rb_prev(n); + } + + return ret_path; +} -- cgit v1.2.3