summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/import/importd.c29
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);