diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-02-19 16:19:15 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-02-24 17:27:53 +0100 |
commit | ce06fdfb3de7a6591041828361f8d10c04a4677e (patch) | |
tree | 48edd02a5fedb686882350be2d35f0070062cc40 /src/import/importd.c | |
parent | 4b3eff61640672bf0b19cb8cdd88ce5e84dcda1c (diff) |
import: print nice warning if we need btrfs but /var/lib/machines is not btrfs
Diffstat (limited to 'src/import/importd.c')
-rw-r--r-- | src/import/importd.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/import/importd.c b/src/import/importd.c index eaf04e6a2b..58807378a7 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -20,6 +20,7 @@ ***/ #include <sys/prctl.h> +#include <sys/vfs.h> #include "sd-bus.h" #include "util.h" @@ -29,8 +30,9 @@ #include "def.h" #include "socket-util.h" #include "mkdir.h" -#include "import-util.h" #include "def.h" +#include "missing.h" +#include "import-util.h" typedef struct Transfer Transfer; typedef struct Manager Manager; @@ -641,6 +643,23 @@ static Transfer *manager_find(Manager *m, TransferType type, const char *dkr_ind return NULL; } +static int check_btrfs(sd_bus_error *error) { + struct statfs sfs; + + if (statfs("/var/lib/machines", &sfs) < 0) { + if (errno != ENOENT) + return -errno; + + if (statfs("/var/lib", &sfs) < 0) + return -errno; + } + + if (!F_TYPE_EQUAL(sfs.f_type, BTRFS_SUPER_MAGIC)) + return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "/var/lib/machines is not a btrfs file system. Operation is not supported on legacy file systems."); + + return 0; +} + static int method_pull_tar_or_raw(sd_bus *bus, sd_bus_message *msg, void *userdata, sd_bus_error *error) { _cleanup_(transfer_unrefp) Transfer *t = NULL; const char *remote, *local, *verify, *object; @@ -686,6 +705,10 @@ static int method_pull_tar_or_raw(sd_bus *bus, sd_bus_message *msg, void *userda if (v < 0) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Unknown verification mode %s", verify); + r = check_btrfs(error); + if (r < 0) + return r; + type = streq_ptr(sd_bus_message_get_member(msg), "PullTar") ? TRANSFER_TAR : TRANSFER_RAW; if (manager_find(m, type, NULL, remote)) @@ -777,6 +800,10 @@ static int method_pull_dkr(sd_bus *bus, sd_bus_message *msg, void *userdata, sd_ if (v != IMPORT_VERIFY_NO) return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "DKR does not support verification."); + r = check_btrfs(error); + if (r < 0) + return r; + if (manager_find(m, TRANSFER_DKR, index_url, remote)) return sd_bus_error_setf(error, BUS_ERROR_TRANSFER_IN_PROGRESS, "Transfer for %s already in progress.", remote); |