f2fs-tools: fix the wrong message when errno is EBUSY
authorTiezhu Yang <kernelpatch@126.com>
Wed, 10 May 2017 13:16:46 +0000 (21:16 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 10 May 2017 17:22:51 +0000 (10:22 -0700)
commitd9180db7d41a7ce99c6458dbe1578d775c4a3f58
tree588f7c8590a383c02cb926cf59dc53ad298852df
parentf642b24822c6cba5808a7517f23d423b05e57c8c
f2fs-tools: fix the wrong message when errno is EBUSY

If f2fs is unmounted with the -l option, the process can still use the
file system. In this case, the command mkfs.f2fs, fsck.f2fs, dump.f2fs,
defrag.f2fs, resize.f2fs and sload.f2fs failed due to the device is in
use by the system. At the moment f2fs is already not mounted, so it is
wrong to print error message "Error: Not available on mounted device!",
this patch fixes it.

[root@localhost home]# mkfs.f2fs -f /dev/sdb1
[root@localhost home]# mkdir -p /mnt/f2fs_mnt_point
[root@localhost home]# mount -t f2fs /dev/sdb1 /mnt/f2fs_mnt_point/
[root@localhost home]# cd /mnt/f2fs_mnt_point/
[root@localhost f2fs_mnt_point]# umount /dev/sdb1
umount: /mnt/f2fs_mnt_point: target is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
[root@localhost f2fs_mnt_point]# umount -l /dev/sdb1
[root@localhost f2fs_mnt_point]# umount /dev/sdb1
umount: /dev/sdb1: not mounted
[root@localhost f2fs_mnt_point]# mkfs.f2fs -f /dev/sdb1

F2FS-tools: mkfs.f2fs Ver: 1.8.0 (2017-04-28)

Info: Disable heap-based policy
Info: Debug level = 0
Info: Label =
Info: Trim is enabled
Error: In use by the system!
Error: Not available on mounted device!
[root@localhost f2fs_mnt_point]# fsck.f2fs /dev/sdb1
Error: In use by the system!
Error: Not available on mounted device!
[root@localhost f2fs_mnt_point]# dump.f2fs /dev/sdb1
Error: In use by the system!
Error: Not available on mounted device!
[root@localhost f2fs_mnt_point]# defrag.f2fs /dev/sdb1
Error: In use by the system!
Error: Not available on mounted device!
[root@localhost f2fs_mnt_point]# resize.f2fs /dev/sdb1
Error: In use by the system!
Error: Not available on mounted device!
[root@localhost f2fs_mnt_point]# sload.f2fs /dev/sdb1
Error: In use by the system!
Error: Not available on mounted device!

Signed-off-by: Tiezhu Yang <kernelpatch@126.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fsck/main.c
mkfs/f2fs_format_main.c