Skip to content

Commit 6217642

Browse files
t-8chbrauner
authored andcommitted
fs: avoid empty option when generating legacy mount string
As each option string fragment is always prepended with a comma it would happen that the whole string always starts with a comma. This could be interpreted by filesystem drivers as an empty option and may produce errors. For example the NTFS driver from ntfs.ko behaves like this and fails when mounted via the new API. Link: util-linux/util-linux#2298 Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Fixes: 3e1aeb0 ("vfs: Implement a filesystem superblock creation/configuration context") Cc: stable@vger.kernel.org Message-Id: <20230607-fs-empty-option-v1-1-20c8dbf4671b@weissschuh.net> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 943211c commit 6217642

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/fs_context.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,8 @@ static int legacy_parse_param(struct fs_context *fc, struct fs_parameter *param)
561561
return -ENOMEM;
562562
}
563563

564-
ctx->legacy_data[size++] = ',';
564+
if (size)
565+
ctx->legacy_data[size++] = ',';
565566
len = strlen(param->key);
566567
memcpy(ctx->legacy_data + size, param->key, len);
567568
size += len;

0 commit comments

Comments
 (0)