From d9e2daaf3d8649650cf9784b4fe9d9de4507da0c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 6 Apr 2015 10:57:17 +0200 Subject: btrfs: support recursively removing btrfs snapshots --- src/import/export-tar.c | 2 +- src/import/import-raw.c | 6 ++---- src/import/import-tar.c | 9 +++------ src/import/pull-common.c | 6 ++---- src/import/pull-dkr.c | 3 +-- src/import/pull-raw.c | 6 ++---- src/import/pull-tar.c | 3 +-- 7 files changed, 12 insertions(+), 23 deletions(-) (limited to 'src/import') diff --git a/src/import/export-tar.c b/src/import/export-tar.c index c27bab46b0..c2fd656527 100644 --- a/src/import/export-tar.c +++ b/src/import/export-tar.c @@ -77,7 +77,7 @@ TarExport *tar_export_unref(TarExport *e) { } if (e->temp_path) { - (void) btrfs_subvol_remove(e->temp_path); + (void) btrfs_subvol_remove(e->temp_path, false); free(e->temp_path); } diff --git a/src/import/import-raw.c b/src/import/import-raw.c index 3a315139e5..ad8f806aff 100644 --- a/src/import/import-raw.c +++ b/src/import/import-raw.c @@ -241,10 +241,8 @@ static int raw_import_finish(RawImport *i) { return r; } - if (i->force_local) { - (void) btrfs_subvol_remove(i->final_path); - (void) rm_rf(i->final_path, REMOVE_ROOT|REMOVE_PHYSICAL); - } + if (i->force_local) + (void) rm_rf(i->final_path, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_SUBVOLUME); r = rename_noreplace(AT_FDCWD, i->temp_path, AT_FDCWD, i->final_path); if (r < 0) diff --git a/src/import/import-tar.c b/src/import/import-tar.c index c5346ca2b0..6ec5504265 100644 --- a/src/import/import-tar.c +++ b/src/import/import-tar.c @@ -87,8 +87,7 @@ TarImport* tar_import_unref(TarImport *i) { } if (i->temp_path) { - (void) btrfs_subvol_remove(i->temp_path); - (void) rm_rf(i->temp_path, REMOVE_ROOT|REMOVE_PHYSICAL); + (void) rm_rf(i->temp_path, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_SUBVOLUME); free(i->temp_path); } @@ -197,10 +196,8 @@ static int tar_import_finish(TarImport *i) { return r; } - if (i->force_local) { - (void) btrfs_subvol_remove(i->final_path); - (void) rm_rf(i->final_path, REMOVE_ROOT|REMOVE_PHYSICAL); - } + if (i->force_local) + (void) rm_rf(i->final_path, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_SUBVOLUME); r = rename_noreplace(AT_FDCWD, i->temp_path, AT_FDCWD, i->final_path); if (r < 0) diff --git a/src/import/pull-common.c b/src/import/pull-common.c index d4cebe205e..ee0c064dfc 100644 --- a/src/import/pull-common.c +++ b/src/import/pull-common.c @@ -124,10 +124,8 @@ int pull_make_local_copy(const char *final, const char *image_root, const char * p = strjoina(image_root, "/", local); - if (force_local) { - (void) btrfs_subvol_remove(p); - (void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL); - } + if (force_local) + (void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_SUBVOLUME); r = btrfs_subvol_snapshot(final, p, false, false); if (r == -ENOTTY) { diff --git a/src/import/pull-dkr.c b/src/import/pull-dkr.c index a1e6fe8ff7..402ddac32b 100644 --- a/src/import/pull-dkr.c +++ b/src/import/pull-dkr.c @@ -111,8 +111,7 @@ DkrPull* dkr_pull_unref(DkrPull *i) { sd_event_unref(i->event); if (i->temp_path) { - (void) btrfs_subvol_remove(i->temp_path); - (void) rm_rf(i->temp_path, REMOVE_ROOT|REMOVE_PHYSICAL); + (void) rm_rf(i->temp_path, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_SUBVOLUME); free(i->temp_path); } diff --git a/src/import/pull-raw.c b/src/import/pull-raw.c index e10b280b66..ebbe6a9cd3 100644 --- a/src/import/pull-raw.c +++ b/src/import/pull-raw.c @@ -277,10 +277,8 @@ static int raw_pull_make_local_copy(RawPull *i) { p = strjoina(i->image_root, "/", i->local, ".raw"); - if (i->force_local) { - (void) btrfs_subvol_remove(p); - (void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL); - } + if (i->force_local) + (void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_SUBVOLUME); r = tempfn_random(p, &tp); if (r < 0) diff --git a/src/import/pull-tar.c b/src/import/pull-tar.c index 60dc22fdfa..0efa07d3f3 100644 --- a/src/import/pull-tar.c +++ b/src/import/pull-tar.c @@ -88,8 +88,7 @@ TarPull* tar_pull_unref(TarPull *i) { sd_event_unref(i->event); if (i->temp_path) { - (void) btrfs_subvol_remove(i->temp_path); - (void) rm_rf(i->temp_path, REMOVE_ROOT|REMOVE_PHYSICAL); + (void) rm_rf(i->temp_path, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_SUBVOLUME); free(i->temp_path); } -- cgit v1.2.3-54-g00ecf