summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-11-12 15:56:56 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-11-16 13:55:48 +0100
commit8d433a99a414adfc6785fd892b0349847f9488b4 (patch)
treeaebb235c6abd0138b3d5e78c9e86d403c37f4af9 /src
parent7ffe593b792653edf220dff893a02d2266959a76 (diff)
downloadsystemd-8d433a99a414adfc6785fd892b0349847f9488b4.tar.gz
makefs: fix too-long swap labels
Apparently mkswap has it's own limit, and it seems to be one lower than the one for ext2/3/4. $ for i in ext2 ext3 ext4 btrfs xfs vfat swap minix; do echo $i && wipefs -q -a '/var/tmp/głąbźśńćąśððð.img' build/systemd-makefs $i '/var/tmp/głąbźśńćąśððð.img' done ext2 /var/tmp/głąbźśńćąśððð.img successfully formatted as ext2 (label "głąbźśńćą", uuid 7626bc5c-8ac4-43cf-87b7-1b2761272dd3) ext3 /var/tmp/głąbźśńćąśððð.img successfully formatted as ext3 (label "głąbźśńćą", uuid 0da22cad-0dbf-4a7a-962d-12cd39d006b5) ext4 /var/tmp/głąbźśńćąśððð.img successfully formatted as ext4 (label "głąbźśńćą", uuid dded267b-8955-4d19-82a5-1f231d446059) btrfs /var/tmp/głąbźśńćąśððð.img successfully formatted as btrfs (label "głąbźśńćąśððð.img", uuid 9e2e89f1-010d-4ab6-80f3-f9e215dbc225) xfs /var/tmp/głąbźśńćąśððð.img successfully formatted as xfs (label "głąbźśń", uuid 2cc937af-4c41-465c-8f52-aab2304bd860) vfat mkfs.fat 4.2 (2021-01-31) /var/tmp/głąbźśńćąśððð.img successfully formatted as vfat (label "G__B_______", uuid a3a9e028) swap ... LABEL=głąbźśńć, UUID=0ab787aa-37a6-4b32-978b-d71efc6e6098 /var/tmp/głąbźśńćąśððð.img successfully formatted as swap (label "głąbźśńć", uuid 0ab787aa-37a6-4b32-978b-d71efc6e6098) minix ... /var/tmp/głąbźśńćąśððð.img successfully formatted as minix (no label or uuid specified)
Diffstat (limited to 'src')
-rw-r--r--src/shared/mkfs-util.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/shared/mkfs-util.c b/src/shared/mkfs-util.c
index f67d7475a0..de03cd3c7d 100644
--- a/src/shared/mkfs-util.c
+++ b/src/shared/mkfs-util.c
@@ -119,10 +119,15 @@ int make_filesystem(
return log_oom();
}
- if (STR_IN_SET(fstype, "ext2", "ext3", "ext4", "xfs")) {
- r = mangle_linux_fs_label(label, streq(fstype, "xfs") ? 12 : 16, &mangled_label);
+ if (STR_IN_SET(fstype, "ext2", "ext3", "ext4", "xfs", "swap")) {
+ size_t max_len =
+ streq(fstype, "xfs") ? 12 :
+ streq(fstype, "swap") ? 15 :
+ 16;
+
+ r = mangle_linux_fs_label(label, max_len, &mangled_label);
if (r < 0)
- return log_error_errno(r, "Failed to determine fs label from string \"%s\": %m", label);
+ return log_error_errno(r, "Failed to determine volume label from string \"%s\": %m", label);
label = mangled_label;
} else if (streq(fstype, "vfat")) {