From 8c9cfc28448bf671807e7d96b580221edebd71da Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 21 Oct 2015 19:45:44 +0200 Subject: import: when downloading images, create a subtree quota group for them --- src/shared/import-util.c | 27 +++++++++++++++++++++++++++ src/shared/import-util.h | 2 ++ 2 files changed, 29 insertions(+) (limited to 'src/shared') diff --git a/src/shared/import-util.c b/src/shared/import-util.c index 001a8a37e8..56388d5dd6 100644 --- a/src/shared/import-util.c +++ b/src/shared/import-util.c @@ -19,6 +19,7 @@ along with systemd; If not, see . ***/ +#include "btrfs-util.h" #include "util.h" #include "import-util.h" @@ -201,3 +202,29 @@ bool dkr_id_is_valid(const char *id) { return true; } + +int import_assign_pool_quota_and_warn(const char *path) { + int r; + + r = btrfs_subvol_auto_qgroup("/var/lib/machines", 0, true); + if (r == -ENOTTY) { + log_debug_errno(r, "Failed to set up default quota hierarchy for /var/lib/machines, as directory is not on btrfs or not a subvolume. Ignoring."); + return 0; + } + if (r < 0) + return log_error_errno(r, "Failed to set up default quota hierarchy for /var/lib/machines: %m"); + if (r > 0) + log_info("Set up default quota hierarchy for /var/lib/machines."); + + r = btrfs_subvol_auto_qgroup(path, 0, true); + if (r == -ENOTTY) { + log_debug_errno(r, "Failed to set up quota hierarchy for %s, as directory is not on btrfs or not a subvolume. Ignoring.", path); + return 0; + } + if (r < 0) + return log_error_errno(r, "Failed to set up default quota hierarchy for %s: %m", path); + if (r > 0) + log_info("Set up default quota hierarchy for %s.", path); + + return 0; +} diff --git a/src/shared/import-util.h b/src/shared/import-util.h index 7bf7d4ca40..9120a5119f 100644 --- a/src/shared/import-util.h +++ b/src/shared/import-util.h @@ -47,3 +47,5 @@ bool dkr_id_is_valid(const char *id); bool dkr_ref_is_valid(const char *ref); bool dkr_digest_is_valid(const char *digest); #define dkr_tag_is_valid(tag) filename_is_valid(tag) + +int import_assign_pool_quota_and_warn(const char *path); -- cgit v1.2.3-54-g00ecf