dump.f2fs: allow to dump data on mounted device
authorChao Yu <yuchao0@huawei.com>
Mon, 29 Jul 2019 15:39:36 +0000 (23:39 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 20 Aug 2019 18:23:58 +0000 (11:23 -0700)
In generic/38[3456], we use quotactl(2) to check if prjquota is
enabled on the given device (src/feature -P $dev in _require_prjquota),
and quotactl(2) requires the given device is a mounted device.

So it requires dump.f2fs to list/check enabled features on a mounted
device, let's relieve to allow such operation.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
lib/libf2fs.c

index 88ab70f..0536e5c 100644 (file)
@@ -818,7 +818,7 @@ void get_kernel_uname_version(__u8 *version)
 #ifndef ANDROID_WINDOWS_HOST
 static int open_check_fs(char *path, int flag)
 {
-       if (c.func != FSCK || c.fix_on || c.auto_fix)
+       if (c.func != DUMP && (c.func != FSCK || c.fix_on || c.auto_fix))
                return -1;
 
        /* allow to open ro */
@@ -864,7 +864,7 @@ int get_device_info(int i)
                        return -1;
                }
 
-               if (S_ISBLK(stat_buf->st_mode) && !c.force) {
+               if (S_ISBLK(stat_buf->st_mode) && !c.force && c.func != DUMP) {
                        fd = open(dev->path, O_RDWR | O_EXCL);
                        if (fd < 0)
                                fd = open_check_fs(dev->path, O_EXCL);