From 94789777b9e8f350ba815b07baa5383e99cd1944 Mon Sep 17 00:00:00 2001 From: Anand Jain Date: Tue, 15 Sep 2015 16:46:22 +0800 Subject: btrfs-progs: provide fail safe for BTRFS_IOC_GET_FSLABEL ioctl Old kernels before 3.9 do not provide ioctl BTRFS_IOC_GET_FSLABEL. So we need to provide a fail safe logic for btrfs-progs running on those kernel. In this patch when get_label_mounted() fails on the old kernel it will fail back to the old method and uses get_label_unmounted(), where it will read from the disk directly. Signed-off-by: Anand Jain Signed-off-by: David Sterba --- cmds-filesystem.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'cmds-filesystem.c') diff --git a/cmds-filesystem.c b/cmds-filesystem.c index 8822695e..09cb37d9 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -468,7 +468,13 @@ static int btrfs_scan_kernel(void *search, unsigned unit_mode) goto out; } - if (get_label_mounted(mnt->mnt_dir, label)) { + ret = get_label_mounted(mnt->mnt_dir, label); + /* provide backward kernel compatibility */ + if (ret == -ENOTTY) + ret = get_label_unmounted( + (const char *)dev_info_arg->path, label); + + if (ret) { kfree(dev_info_arg); goto out; } -- cgit v1.2.3