diff options
author | Jan Schmidt <list.btrfs@jan-o-sch.net> | 2011-11-02 11:42:30 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-11-02 15:46:10 -0400 |
commit | 6055e736045d7e1f83ea77551941c7745ad36ec2 (patch) | |
tree | efb881b6d1d1ea02a2ab159dbb9a956fc496332c /btrfs-list.c | |
parent | dcdbc1ce18ef73224198d45d8463a86709379202 (diff) |
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 <list.btrfs@jan-o-sch.net>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'btrfs-list.c')
-rw-r--r-- | btrfs-list.c | 35 |
1 files changed, 35 insertions, 0 deletions
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; +} |