summaryrefslogtreecommitdiffstats
path: root/src/test/test-btrfs.c
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2023-06-20 15:22:24 +0200
committerGitHub <noreply@github.com>2023-06-20 15:22:24 +0200
commit1a5f67aba3c31282a2f353921e18cc013816006f (patch)
tree36931cf1ec110b1eec206105b3308a89cf65a7df /src/test/test-btrfs.c
parentupdate TODO (diff)
parentbtrfs-util: Add BTRFS_SNAPSHOT_LOCK_BSD (diff)
downloadsystemd-1a5f67aba3c31282a2f353921e18cc013816006f.tar.xz
systemd-1a5f67aba3c31282a2f353921e18cc013816006f.zip
Merge pull request #27863 from DaanDeMeyer/copy-lock
Add helpers to lock a directory before copying into it
Diffstat (limited to 'src/test/test-btrfs.c')
-rw-r--r--src/test/test-btrfs.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/test/test-btrfs.c b/src/test/test-btrfs.c
index ca01a8c856..95b7ef25d8 100644
--- a/src/test/test-btrfs.c
+++ b/src/test/test-btrfs.c
@@ -4,6 +4,7 @@
#include "btrfs-util.h"
#include "fd-util.h"
+#include "fs-util.h"
#include "fileio.h"
#include "format-util.h"
#include "log.h"
@@ -62,6 +63,14 @@ int main(int argc, char *argv[]) {
if (r < 0)
log_error_errno(r, "Failed to make snapshot: %m");
+ r = btrfs_subvol_snapshot_at(AT_FDCWD, "/xxxtest", AT_FDCWD, "/xxxtest4", BTRFS_SNAPSHOT_LOCK_BSD);
+ if (r < 0)
+ log_error_errno(r, "Failed to make snapshot: %m");
+ if (r >= 0)
+ assert_se(xopenat_lock(AT_FDCWD, "/xxxtest4", 0, 0, 0, LOCK_BSD, LOCK_EX|LOCK_NB) == -EAGAIN);
+
+ safe_close(r);
+
r = btrfs_subvol_remove("/xxxtest", BTRFS_REMOVE_QUOTA);
if (r < 0)
log_error_errno(r, "Failed to remove subvolume: %m");
@@ -74,6 +83,10 @@ int main(int argc, char *argv[]) {
if (r < 0)
log_error_errno(r, "Failed to remove subvolume: %m");
+ r = btrfs_subvol_remove("/xxxtest4", BTRFS_REMOVE_QUOTA);
+ if (r < 0)
+ log_error_errno(r, "Failed to remove subvolume: %m");
+
r = btrfs_subvol_snapshot_at(AT_FDCWD, "/etc", AT_FDCWD, "/etc2",
BTRFS_SNAPSHOT_READ_ONLY|BTRFS_SNAPSHOT_FALLBACK_COPY);
if (r < 0)
@@ -161,13 +174,15 @@ int main(int argc, char *argv[]) {
if (r < 0)
log_error_errno(r, "Failed to query quota: %m");
- assert_se(quota.referenced_max == 4ULL * 1024 * 1024 * 1024);
+ if (r >= 0)
+ assert_se(quota.referenced_max == 4ULL * 1024 * 1024 * 1024);
r = btrfs_subvol_get_subtree_quota("/xxxquotatest2", 0, &quota);
if (r < 0)
log_error_errno(r, "Failed to query quota: %m");
- assert_se(quota.referenced_max == 5ULL * 1024 * 1024 * 1024);
+ if (r >= 0)
+ assert_se(quota.referenced_max == 5ULL * 1024 * 1024 * 1024);
r = btrfs_subvol_remove("/xxxquotatest", BTRFS_REMOVE_QUOTA|BTRFS_REMOVE_RECURSIVE);
if (r < 0)