Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

btrfs-progs: cmds: show child subvolumes during recursive delete #957

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions cmds/subvolume.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,33 @@ static int cmd_subvolume_delete(const struct cmd_struct *cmd, int argc, char **a
goto out;
}

if (flags & BTRFS_UTIL_DELETE_SUBVOLUME_RECURSIVE) {
struct btrfs_util_subvolume_iterator *iter;
err = btrfs_util_subvolume_iter_create_fd(fd, target_subvol_id,
BTRFS_UTIL_SUBVOLUME_ITERATOR_POST_ORDER,
&iter);
if (!err) {
char *child_path;
struct btrfs_util_subvolume_info subvol_info;
while (!(err = btrfs_util_subvolume_iter_next_info(iter, &child_path, &subvol_info))) {
pr_verbose(LOG_DEFAULT, "Delete subvolume %" PRIu64 " (%s): ",
subvol_info.id,
commit_mode == COMMIT_EACH ||
(commit_mode == COMMIT_AFTER && cnt + 1 == argc) ?
"commit" : "no-commit");
pr_verbose(LOG_DEFAULT, "'%s/%s/%s'\n", dname, vname, child_path);

free(child_path);
}
if (err != BTRFS_UTIL_ERROR_STOP_ITERATION)
warning("failed to iterate subvol : %s", btrfs_util_strerror(err));

btrfs_util_destroy_subvolume_iterator(iter);
} else {
warning("failed to create iter: %s", btrfs_util_strerror(err));
}
}

pr_verbose(LOG_DEFAULT, "Delete subvolume %" PRIu64 " (%s): ",
target_subvol_id,
commit_mode == COMMIT_EACH ||
Expand Down