From a46bb377105153c734bab690508c3d3bbc8248d3 Mon Sep 17 00:00:00 2001 From: Allison Karlitskaya Date: Mon, 2 Dec 2024 21:00:47 +0100 Subject: [PATCH] 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 --- src/shared/mkfs-util.c | 6 ++++++ src/shared/mkfs-util.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/shared/mkfs-util.c b/src/shared/mkfs-util.c index e8412cb4b0..629d02207c 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 ca2fae7e3e..2e83370d03 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);