[PATCH v2] erofs-utils: adjust volume label maximum length to the kernel implementation
Naoto Yamaguchi
wata2ki at gmail.com
Thu Aug 15 01:53:30 AEST 2024
The erofs implementation of kernel has limitation of the volume label length.
The volume label data size of super block is 16 bytes.
The kernel implementation requires to null terminate inside a that 16 bytes.
Logs:
$ ./mkfs/mkfs.erofs test16.erofs -L 0123456789abcdef test/
$ mount -o loop ./test16.erofs ./mnt/
$ dmesg
[26477.019283] erofs: (device loop0): erofs_read_superblock: bad volume name without NIL terminator
$ ./mkfs/mkfs.erofs test15.erofs -L 0123456789abcde test/
$ mount -o loop ./test15.erofs ./mnt/
$ dmesg
[26500.516871] erofs: (device loop0): mounted with root inode @ nid 36.
This patch adjusts volume label maximum length to the kernel implementation.
Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi at aisin.co.jp>
---
mkfs/main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mkfs/main.c b/mkfs/main.c
index b7129eb..ff26c16 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -151,7 +151,7 @@ static void usage(int argc, char **argv)
printf(
" -C# specify the size of compress physical cluster in bytes\n"
" -EX[,...] X=extended options\n"
- " -L volume-label set the volume label (maximum 16)\n"
+ " -L volume-label set the volume label (maximum 15 character)\n"
" -T# specify a fixed UNIX timestamp # as build time\n"
" --all-time the timestamp is also applied to all files (default)\n"
" --mkfs-time the timestamp is applied as build time only\n"
@@ -598,7 +598,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
case 'L':
if (optarg == NULL ||
- strlen(optarg) > sizeof(g_sbi.volume_name)) {
+ strlen(optarg) > (sizeof(g_sbi.volume_name) - 1u)) {
erofs_err("invalid volume label");
return -EINVAL;
}
--
2.43.0
More information about the Linux-erofs
mailing list