From: Allison Karlitskaya Date: Mon, 2 Dec 2024 20:00:47 +0000 (+0100) Subject: mkfs-util: add fsverity option to make_filesystem() X-Git-Tag: v258-rc1~478^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a46bb377105153c734bab690508c3d3bbc8248d3;p=thirdparty%2Fsystemd.git mkfs-util: add fsverity option to make_filesystem() Add an fsverity flag to MkfsFlags and use it to pass the `-O verity` option when creating an ext4 or f2fs filesystem: they share the same argument for this. The only other filesystem that currently supports fs-verity is btrfs and it doesn't require a flag to be enabled when creating the filesystem. Nothing uses this yet. Signed-off-by: Allison Karlitskaya --- diff --git a/src/shared/mkfs-util.c b/src/shared/mkfs-util.c index e8412cb4b02..629d02207c1 100644 --- a/src/shared/mkfs-util.c +++ b/src/shared/mkfs-util.c @@ -435,6 +435,9 @@ int make_filesystem( if (FLAGS_SET(flags, MKFS_QUIET) && strv_extend(&argv, "-q") < 0) return log_oom(); + if (FLAGS_SET(flags, MKFS_FS_VERITY) && strv_extend_many(&argv, "-O", "verity") < 0) + return log_oom(); + if (strv_extend(&argv, node) < 0) return log_oom(); @@ -501,6 +504,9 @@ int make_filesystem( if (FLAGS_SET(flags, MKFS_QUIET) && strv_extend(&argv, "-q") < 0) return log_oom(); + if (FLAGS_SET(flags, MKFS_FS_VERITY) && strv_extend_many(&argv, "-O", "verity") < 0) + return log_oom(); + if (sector_size > 0) { if (strv_extend(&argv, "-w") < 0) return log_oom(); diff --git a/src/shared/mkfs-util.h b/src/shared/mkfs-util.h index ca2fae7e3e0..2e83370d03c 100644 --- a/src/shared/mkfs-util.h +++ b/src/shared/mkfs-util.h @@ -8,6 +8,7 @@ typedef enum MakeFilesystemFlags { MKFS_QUIET = 1 << 0, /* Suppress mkfs command output */ MKFS_DISCARD = 1 << 1, /* Enable 'discard' mode on the filesystem */ + MKFS_FS_VERITY = 1 << 2, /* Enable fs-verity support on the filesystem */ } MakeFileSystemFlags; int mkfs_exists(const char *fstype);