chiark / gitweb /
sd-dhcp6-client: delay setting the DUID and don't fail constructor
[elogind.git] / src / import / importd.c
index 58807378a7e58e5cc463d71c14f295bb1f8dc8f0..8a6a8c8ed1be85e332bad1abd6551a0c487b49db 100644 (file)
@@ -20,7 +20,6 @@
 ***/
 
 #include <sys/prctl.h>
-#include <sys/vfs.h>
 
 #include "sd-bus.h"
 #include "util.h"
@@ -32,6 +31,8 @@
 #include "mkdir.h"
 #include "def.h"
 #include "missing.h"
+#include "machine-pool.h"
+#include "path-util.h"
 #include "import-util.h"
 
 typedef struct Transfer Transfer;
@@ -643,23 +644,6 @@ 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;
@@ -705,7 +689,7 @@ 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);
+        r = setup_machine_directory((uint64_t) -1, error);
         if (r < 0)
                 return r;
 
@@ -800,7 +784,7 @@ 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);
+        r = setup_machine_directory((uint64_t) -1, error);
         if (r < 0)
                 return r;