]> www.infradead.org Git - users/jedix/linux-maple.git/commit
btrfs: do not allow mounting non-subvolumes via subvol option
authorDavid Sterba <dsterba@suse.cz>
Thu, 29 Sep 2011 11:11:33 +0000 (13:11 +0200)
committerChris Mason <chris.mason@oracle.com>
Wed, 16 Nov 2011 02:20:45 +0000 (21:20 -0500)
commitd9b5beca0f6d568aa8dbc166acfb38cfeb07c4ff
tree5e5e459a8589f60d9e1fac9a0adbfd9417459253
parent7e0bd4fa758afb0f166c922e9351eaf710daac43
btrfs: do not allow mounting non-subvolumes via subvol option

There's a missing test whether the path passed to subvol=path option
during mount is a real subvolume, allowing any directory located in
default subovlume to be passed and accepted for mount.

(current btrfs progs prevent this early)
$ btrfs subvol snapshot . p1-snap
ERROR: '.' is not a subvolume

(with "is subvolume?" test bypassed)
$ btrfs subvol snapshot . p1-snap
Create a snapshot of '.' in './p1-snap'

$ btrfs subvol list -p .
ID 258 parent 5 top level 5 path subvol
ID 259 parent 5 top level 5 path subvol1
ID 260 parent 5 top level 5 path default-subvol1
ID 262 parent 5 top level 5 path p1/p1-snapshot
ID 263 parent 259 top level 5 path subvol1/subvol1-snap

The problem I see is that this makes a false impression of snapshotting the
given subvolume but in fact snapshots the default one: a user expects outcome
like ID 263 but in fact gets ID 262 .

This patch makes mount fail with EINVAL with a message in syslog.

Signed-off-by: David Sterba <dsterba@suse.cz>
(cherry picked from commit f9d9ef62cd3ecbd6cbb7957a253c1e81f69d5586)
fs/btrfs/super.c