ri->ref_tree = 0;
return -ENOENT;
}
- error("failed to lookup path for root %llu: %s",
- (unsigned long long)ri->ref_tree, strerror(errno));
+ error("failed to lookup path for root %llu: %m",
+ (unsigned long long)ri->ref_tree);
return ret;
}
/* this ioctl fills in ino_args->treeid */
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &ino_args);
if (ret < 0) {
- error("failed to lookup path for dirid %llu: %s",
- (unsigned long long)BTRFS_FIRST_FREE_OBJECTID,
- strerror(errno));
+ error("failed to lookup path for dirid %llu: %m",
+ (unsigned long long)BTRFS_FIRST_FREE_OBJECTID);
return 0;
}
while (1) {
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
if (ret < 0) {
- error("can't perform the search: %s", strerror(errno));
+ error("can't perform the search: %m");
return 0;
}
/* the ioctl returns the number of item it found in nr_items */
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
if (ret < 0) {
- error("failed to lookup path for dirid %llu: %s",
- (unsigned long long)dirid, strerror(errno));
+ error("failed to lookup path for dirid %llu: %m",
+ (unsigned long long)dirid);
return ERR_PTR(ret);
}
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
if (ret < 0) {
- error("can't perform the search: %s", strerror(errno));
+ error("can't perform the search: %m");
return NULL;
}
/* the ioctl returns the number of item it found in nr_items */
ret = resolve_root(all_subvols, entry, top_id);
if (ret == -ENOENT) {
- entry->full_path = strdup("DELETED");
- entry->deleted = 1;
+ if (entry->root_id != BTRFS_FS_TREE_OBJECTID) {
+ entry->full_path = strdup("DELETED");
+ entry->deleted = 1;
+ } else {
+ /*
+ * The full path is not supposed to be printed,
+ * but we don't want to print an empty string,
+ * in case it appears somewhere.
+ */
+ entry->full_path = strdup("TOPLEVEL");
+ entry->deleted = 0;
+ }
}
ret = filter_root(entry, filter_set);
if (ret)
strcpy(uuidparse, "-");
else
uuid_unparse(subv->uuid, uuidparse);
- printf("%s", uuidparse);
+ printf("%-36s", uuidparse);
break;
case BTRFS_LIST_PUUID:
if (uuid_is_null(subv->puuid))
strcpy(uuidparse, "-");
else
uuid_unparse(subv->puuid, uuidparse);
- printf("%s", uuidparse);
+ printf("%-36s", uuidparse);
break;
case BTRFS_LIST_RUUID:
if (uuid_is_null(subv->ruuid))
strcpy(uuidparse, "-");
else
uuid_unparse(subv->ruuid, uuidparse);
- printf("%s", uuidparse);
+ printf("%-36s", uuidparse);
break;
case BTRFS_LIST_PATH:
BUG_ON(!subv->full_path);
n = rb_first(&sorted_tree->root);
while (n) {
entry = rb_entry(n, struct root_info, sort_node);
+
+ /* The toplevel subvolume is not listed by default */
+ if (entry->root_id == BTRFS_FS_TREE_OBJECTID)
+ goto next;
+
switch (layout) {
case BTRFS_LIST_LAYOUT_DEFAULT:
print_one_subvol_info_default(entry);
print_one_subvol_info_raw(entry, raw_prefix);
break;
}
+next:
n = rb_next(n);
}
}
ret = list_subvol_search(fd, root_lookup);
if (ret) {
- error("can't perform the search: %s", strerror(errno));
+ error("can't perform the search: %m");
return ret;
}
while(1) {
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
if (ret < 0) {
- error("can't perform the search: %s", strerror(errno));
+ error("can't perform the search: %m");
break;
}
/* the ioctl returns the number of item it found in nr_items */
ret = lookup_path_rootid(fd, treeid);
if (ret < 0)
- error("cannot resolve rootid for path: %s",
- strerror(errno));
+ error("cannot resolve rootid for path: %m");
return ret;
}