All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: correctly escape subvol in btrfs_show_options
@ 2025-03-19 21:49 Johannes Kimmel
  2025-03-19 23:52 ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Kimmel @ 2025-03-19 21:49 UTC (permalink / raw)
  To: linux-btrfs; +Cc: clm, josef, dsterba, linux-kernel, Calvin Walton

Currently, displaying the btrfs subvol mount option doesn't escape `,`.
This makes parsing /proc/self/mounts and /proc/self/mountinfo
ambigious for subvolume names that contain commas. The text after the
comma could be mistaken for another option (think "subvol=foo,ro", where
ro is actually part of the subvolumes name).

This patch replaces the manual escape characters list with a call to
seq_show_option. Thanks to Calvin Walton for suggesting this approach.

Fixes: c8d3fe028f64 ("Btrfs: show subvol= and subvolid= in /proc/mounts")
Suggested-by: Calvin Walton <calvin.walton@kepstin.ca>
Signed-off-by: Johannes Kimmel <kernel@bareminimum.eu>
---
 fs/btrfs/super.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index dc4fee519ca6..a5f29ff3fbc2 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1139,8 +1139,7 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
 	subvol_name = btrfs_get_subvol_name_from_objectid(info,
 			btrfs_root_id(BTRFS_I(d_inode(dentry))->root));
 	if (!IS_ERR(subvol_name)) {
-		seq_puts(seq, ",subvol=");
-		seq_escape(seq, subvol_name, " \t\n\\");
+		seq_show_option(seq, "subvol", subvol_name);
 		kfree(subvol_name);
 	}
 	return 0;
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-22 10:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-19 21:49 [PATCH] btrfs: correctly escape subvol in btrfs_show_options Johannes Kimmel
2025-03-19 23:52 ` David Sterba
2025-03-22 10:15   ` Johannes Kimmel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.