On 2018/02/16 4:05, Omar Sandoval wrote: > From: Omar Sandoval <osan...@fb.com>
> +static struct subvol_list *btrfs_list_deleted_subvols(int fd, > + struct > btrfs_list_filter_set *filter_set) > +{ > + struct subvol_list *subvols = NULL; > + uint64_t *ids = NULL; > + size_t i, n; > + enum btrfs_util_error err; > + int ret = -1; > + > + err = btrfs_util_deleted_subvolumes_fd(fd, &ids, &n); > + if (err) { > + error_btrfs_util(err); > + return NULL; > + } > + > + subvols = malloc(sizeof(*subvols) + n * sizeof(subvols->subvols[0])); > + if (!subvols) { > + error("out of memory"); > + goto out; > + } > + > + subvols->num = 0; > + for (i = 0; i < n; i++) { > + struct listed_subvol *subvol = &subvols->subvols[subvols->num]; > + > + err = btrfs_util_subvolume_info_fd(fd, ids[i], &subvol->info); > + if (err) { I think there is a small chance that subvolume would be removed from tree between btrfs_util_deleted_subvolumes_fd() and btrfs_util_subvolume_info_fd(). So, error of BTRFS_UTIL_ERROR_SUBVOLUME_NOT_FOUND should be ignored. > + error_btrfs_util(err); > + goto out; > + } > + > + subvol->path = strdup("DELETED"); > + if (!subvol->path) > + goto out; > + > + if (!filters_match(subvol, filter_set)) { > + free(subvol->path); > + continue; > + } > + > + subvols->num++; > + } > + > + ret = 0; > +out: > + if (ret) { > + free_subvol_list(subvols); > + subvols = NULL; > + free(ids); > + } > + return subvols; > +} -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html