Merge pull request #24794 from DaanDeMeyer/repart-follow-ups

repart: Extend squashfs logic to all read-only filesystems
This commit is contained in:
Lennart Poettering
2022-09-23 15:12:56 +02:00
committed by GitHub
3 changed files with 23 additions and 15 deletions
+11 -5
View File
@@ -4,6 +4,7 @@
#include "id128-util.h"
#include "mkfs-util.h"
#include "mountpoint-util.h"
#include "path-util.h"
#include "process-util.h"
#include "stdio-util.h"
@@ -102,6 +103,11 @@ int make_filesystem(
assert(fstype);
assert(label);
if (fstype_is_ro(fstype) && !root)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Cannot generate read-only filesystem %s without a source tree.",
fstype);
if (streq(fstype, "swap")) {
if (root)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
@@ -112,19 +118,19 @@ int make_filesystem(
if (r < 0)
return log_error_errno(r, "Failed to determine whether mkswap binary exists: %m");
} else if (streq(fstype, "squashfs")) {
if (!root)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Cannot generate squashfs filesystems without a source tree.");
r = find_executable("mksquashfs", &mkfs);
if (r == -ENOENT)
return log_error_errno(SYNTHETIC_ERRNO(EPROTONOSUPPORT), "mksquashfs binary not available.");
if (r < 0)
return log_error_errno(r, "Failed to determine whether mksquashfs binary exists: %m");
} else if (fstype_is_ro(fstype)) {
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
"Don't know how to create read-only file system '%s', refusing.",
fstype);
} else {
if (root)
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
"Populating with source tree is only supported for squashfs");
"Populating with source tree is only supported for read-only filesystems");
r = mkfs_exists(fstype);
if (r < 0)
return log_error_errno(r, "Failed to determine whether mkfs binary for %s exists: %m", fstype);
+2
View File
@@ -5,6 +5,8 @@
#include "sd-id128.h"
#include "strv.h"
int mkfs_exists(const char *fstype);
int make_filesystem(const char *node, const char *fstype, const char *label, const char *root, sd_id128_t uuid, bool discard);