]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libmount: run btrfs subvol checks for "auto" fs type
authorStanislav Brabec <sbrabec@suse.cz>
Tue, 26 Jan 2016 20:59:55 +0000 (21:59 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 1 Feb 2016 10:59:31 +0000 (11:59 +0100)
commitd2f8267847ecbe763a3b63af1289bf1179cd8c45
tree49df43b76332adfab01bfbe912ea728dec5d4aed
parent314c3358d53b99338d32f30dde720bf173e61c1b
libmount: run btrfs subvol checks for "auto" fs type

It is possible to mount btrfs using "auto" keyword in fstab. In such
case, btrfs specific checks are skipped. Run them for "auto" as well.

Looking at the code, it is a safe approach. In case of btrfs, it will do
what is needed, in case of no btrfs, btrfs_get_default_subvol_id() will
fail, and the rest of the code is skipped.

How to reproduce:
See reproducer in 2cd28fc and replace fstab line by
echo "/dev/loop0 $PWD/btrfs_mnt btrfs auto 0 0" >>/etc/fstab

Current behavior of second "mount -a":
mount: /dev/loop0 is already mounted or /root/btrfs_mnt busy
       /dev/loop0 is already mounted on /root/btrfs_mnt

Testcases for btrfs and ext4:
truncate -s1G btrfs_test.img
truncate -s1G ext4_test.img
mkdir -p btrfs_mnt
mkdir -p ext4_mnt
/sbin/mkfs.btrfs -f -d single -m single ./btrfs_test.img
/sbin/mkfs.ext4 ./ext4_test.img
losetup /dev/loop0 $PWD/btrfs_test.img
losetup /dev/loop1 $PWD/ext4_test.img
echo "/dev/loop0 $PWD/btrfs_mnt auto defaults 0 0" >>/etc/fstab
echo "/dev/loop1 $PWD/ext4_mnt auto defaults 0 0" >>/etc/fstab
./mount -a
./mount -a
umount btrfs_mnt
umount ext4_mnt
sed -i "/\/dev\/loop[01]/d" /etc/fstab
losetup -d /dev/loop0
losetup -d /dev/loop1
rm btrfs_test.img
rm ext4_test.img
rmdir btrfs_mnt
rmdir ext4_mnt

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
libmount/src/tab.c