From: Zbigniew Jędrzejewski-Szmek Date: Sat, 13 Nov 2021 15:40:46 +0000 (+0100) Subject: makefs: add "support" for f2fs X-Git-Tag: v250-rc1~240^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d96440fd551b3c037369857b6c0a26e931144d7;p=thirdparty%2Fsystemd.git makefs: add "support" for f2fs The man page doesn't quite match what --help says, and I needed to use "-f" to write a wiped partition. This all feels a bit experimental, but the fs has some adherents, and we should make it easy to use. (Also, an empty 256MB device formatted and mounted shows up as Filesystem Size Used Avail Use% Mounted on /dev/loop0 254M 85M 170M 34% /var/tmp/mount which also seems a bit over the top…) Requested in https://github.com/systemd/systemd/pull/21275#issuecomment-967928690. --- diff --git a/src/shared/mkfs-util.c b/src/shared/mkfs-util.c index de03cd3c7d2..061a2c2ef74 100644 --- a/src/shared/mkfs-util.c +++ b/src/shared/mkfs-util.c @@ -183,6 +183,17 @@ int make_filesystem( discard ? NULL : "--nodiscard", NULL); + } else if (streq(fstype, "f2fs")) { + (void) execlp(mkfs, mkfs, + "-q", + "-g", /* "default options" */ + "-f", /* force override, without this it doesn't seem to want to write to an empty partition */ + "-l", label, + "-U", vol_id, + "-t", one_zero(discard), + node, + NULL); + } else if (streq(fstype, "xfs")) { const char *j; @@ -223,7 +234,7 @@ int make_filesystem( _exit(EXIT_FAILURE); } - if (STR_IN_SET(fstype, "ext2", "ext3", "ext4", "btrfs", "xfs", "vfat", "swap")) + if (STR_IN_SET(fstype, "ext2", "ext3", "ext4", "btrfs", "f2fs", "xfs", "vfat", "swap")) log_info("%s successfully formatted as %s (label \"%s\", uuid %s)", node, fstype, label, vol_id); else