- ret = test_issubvolume(fullpath);
- if (ret < 0) {
- error("cannot access subvolume %s: %s", fullpath,
- strerror(-ret));
- goto out;
- }
- if (!ret) {
- error("not a subvolume: %s", fullpath);
- ret = 1;
- goto out;
- }
-
- ret = find_mount_root(fullpath, &mnt);
- if (ret < 0) {
- error("find_mount_root failed on '%s': %s",
- fullpath, strerror(-ret));
- goto out;
- }
- if (ret > 0) {
- error("%s doesn't belong to btrfs mount point", fullpath);
- goto out;
- }
- ret = 1;
- svpath = get_subvol_name(mnt, fullpath);
-
- fd = btrfs_open_dir(fullpath, &dirstream1, 1);
- if (fd < 0)
- goto out;
-
- ret = btrfs_list_get_path_rootid(fd, &sv_id);
- if (ret) {
- error("can't get rootid for '%s'", fullpath);
- goto out;
- }
-
- mntfd = btrfs_open_dir(mnt, &dirstream2, 1);
- if (mntfd < 0)
- goto out;
-
- if (sv_id == BTRFS_FS_TREE_OBJECTID) {
- printf("%s is toplevel subvolume\n", fullpath);
- goto out;
+ if (by_rootid) {
+ ret = get_subvol_info_by_rootid(fullpath, &get_ri, rootid_arg);
+ } else if (by_uuid) {
+ ret = get_subvol_info_by_uuid(fullpath, &get_ri, uuid_arg);
+ } else {
+ ret = get_subvol_info(fullpath, &get_ri);