diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2024-03-05 11:10:12 -0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2024-03-06 09:42:08 -0800 |
commit | efcff4bc169fbcb7276769ab0ad5444b1df33a70 (patch) | |
tree | b73410eee618c08811d5e74d8139084b4d4836eb | |
parent | 4ecb90c2e32fe5f9509e4ecdb7000a98ed2897bc (diff) | |
download | f2fs-tools-efcff4bc169fbcb7276769ab0ad5444b1df33a70.tar.gz |
f2fs-tools: deal with permission denial on non-root user
This fixes some android build failures due to the missing permission when
checking the loop device. Until we get a better solution, let's ignore
the error with warnings.
Reviewed-by: Huang Jianan <huangjianan@xiaomi.com>
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | lib/libf2fs.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/libf2fs.c b/lib/libf2fs.c index d51e485..1cfbf31 100644 --- a/lib/libf2fs.c +++ b/lib/libf2fs.c @@ -854,9 +854,15 @@ int f2fs_dev_is_umounted(char *path) loop_fd = open(mnt->mnt_fsname, O_RDONLY); if (loop_fd < 0) { + /* non-root users have no permission */ + if (errno == EPERM || errno == EACCES) { + MSG(0, "Info: open %s failed errno:%d - be careful to overwrite a mounted loopback file.\n", + mnt->mnt_fsname, errno); + return 0; + } MSG(0, "Info: open %s failed errno:%d\n", - mnt->mnt_fsname, errno); - return -1; + mnt->mnt_fsname, errno); + return -errno; } err = ioctl(loop_fd, LOOP_GET_STATUS64, &loopinfo); @@ -864,7 +870,7 @@ int f2fs_dev_is_umounted(char *path) if (err < 0) { MSG(0, "\tError: ioctl LOOP_GET_STATUS64 failed errno:%d!\n", errno); - return -1; + return -errno; } if (st_buf.st_dev == loopinfo.lo_device && |