]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
makefs: add "support" for f2fs
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 13 Nov 2021 15:40:46 +0000 (16:40 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 16 Nov 2021 12:55:49 +0000 (13:55 +0100)
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.

src/shared/mkfs-util.c

index de03cd3c7d2d960c3fc2d059a9d27230db24f29b..061a2c2ef749465047ea650bd0cf775a8ffb7ebe 100644 (file)
@@ -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