diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-04-06 10:57:17 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-04-06 11:28:16 +0200 |
commit | d9e2daaf3d8649650cf9784b4fe9d9de4507da0c (patch) | |
tree | a6f5960da742e676f249036e59656dac040ecaed /src/test | |
parent | 41d1ed059bbc863c73161f39594de2eb7b338886 (diff) |
btrfs: support recursively removing btrfs snapshots
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-btrfs.c | 48 | ||||
-rw-r--r-- | src/test/test-hostname.c | 1 |
2 files changed, 42 insertions, 7 deletions
diff --git a/src/test/test-btrfs.c b/src/test/test-btrfs.c index 9e6538e735..373ce43aeb 100644 --- a/src/test/test-btrfs.c +++ b/src/test/test-btrfs.c @@ -27,8 +27,7 @@ #include "btrfs-util.h" int main(int argc, char *argv[]) { - int r; - int fd; + int r, fd; fd = open("/", O_RDONLY|O_CLOEXEC|O_DIRECTORY); if (fd < 0) @@ -81,15 +80,15 @@ int main(int argc, char *argv[]) { if (r < 0) log_error_errno(r, "Failed to make snapshot: %m"); - r = btrfs_subvol_remove("/xxxtest"); + r = btrfs_subvol_remove("/xxxtest", false); if (r < 0) log_error_errno(r, "Failed to remove subvolume: %m"); - r = btrfs_subvol_remove("/xxxtest2"); + r = btrfs_subvol_remove("/xxxtest2", false); if (r < 0) log_error_errno(r, "Failed to remove subvolume: %m"); - r = btrfs_subvol_remove("/xxxtest3"); + r = btrfs_subvol_remove("/xxxtest3", false); if (r < 0) log_error_errno(r, "Failed to remove subvolume: %m"); @@ -97,9 +96,46 @@ int main(int argc, char *argv[]) { if (r < 0) log_error_errno(r, "Failed to make snapshot: %m"); - r = btrfs_subvol_remove("/etc2"); + r = btrfs_subvol_remove("/etc2", false); if (r < 0) log_error_errno(r, "Failed to remove subvolume: %m"); + r = btrfs_subvol_make("/xxxrectest"); + if (r < 0) + log_error_errno(r, "Failed to make subvolume: %m"); + + r = btrfs_subvol_make("/xxxrectest/xxxrectest2"); + if (r < 0) + log_error_errno(r, "Failed to make subvolume: %m"); + + r = btrfs_subvol_make("/xxxrectest/xxxrectest3"); + if (r < 0) + log_error_errno(r, "Failed to make subvolume: %m"); + + r = btrfs_subvol_make("/xxxrectest/xxxrectest3/sub"); + if (r < 0) + log_error_errno(r, "Failed to make subvolume: %m"); + + if (mkdir("/xxxrectest/dir", 0755) < 0) + log_error_errno(errno, "Failed to make directory: %m"); + + r = btrfs_subvol_make("/xxxrectest/dir/xxxrectest4"); + if (r < 0) + log_error_errno(r, "Failed to make subvolume: %m"); + + if (mkdir("/xxxrectest/dir/xxxrectest4/dir", 0755) < 0) + log_error_errno(errno, "Failed to make directory: %m"); + + r = btrfs_subvol_make("/xxxrectest/dir/xxxrectest4/dir/xxxrectest5"); + if (r < 0) + log_error_errno(r, "Failed to make subvolume: %m"); + + if (mkdir("/xxxrectest/mnt", 0755) < 0) + log_error_errno(errno, "Failed to make directory: %m"); + + r = btrfs_subvol_remove("/xxxrectest", true); + if (r < 0) + log_error_errno(r, "Failed to recursively remove subvolume: %m"); + return 0; } diff --git a/src/test/test-hostname.c b/src/test/test-hostname.c index c7e5de896b..dd50c5148c 100644 --- a/src/test/test-hostname.c +++ b/src/test/test-hostname.c @@ -19,7 +19,6 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ - #include "hostname-setup.h" #include "util.h" |