diff mbox series

[f2fs-dev] mkfs.f2fs: fix sparse_mode case on stat

Message ID 20240213234100.2445417-1-jaegeuk@kernel.org (mailing list archive)
State New
Headers show
Series [f2fs-dev] mkfs.f2fs: fix sparse_mode case on stat | expand

Commit Message

Jaegeuk Kim Feb. 13, 2024, 11:41 p.m. UTC
When we turn on sparse_mode, stat() will be failed, as the file will be
created afterwards. Let's fix.

Fixes: 14197d546b93 ("f2fs-tools: fix to check loop device")
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 lib/libf2fs.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Daeho Jeong Feb. 14, 2024, 12:05 a.m. UTC | #1
Reviewed-by: Daeho Jeong <daehojeong@google.com>

On Tue, Feb 13, 2024 at 3:42 PM Jaegeuk Kim <jaegeuk@kernel.org> wrote:
>
> When we turn on sparse_mode, stat() will be failed, as the file will be
> created afterwards. Let's fix.
>
> Fixes: 14197d546b93 ("f2fs-tools: fix to check loop device")
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  lib/libf2fs.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> index 5c6c5b7bf8a7..d51e485361ee 100644
> --- a/lib/libf2fs.c
> +++ b/lib/libf2fs.c
> @@ -814,6 +814,9 @@ int f2fs_dev_is_umounted(char *path)
>          * the file system. In this case, we should not format.
>          */
>         if (stat(path, &st_buf)) {
> +               /* sparse file will be created after this. */
> +               if (c.sparse_mode)
> +                       return 0;
>                 MSG(0, "Info: stat failed errno:%d\n", errno);
>                 return -1;
>         }
> --
> 2.43.0.687.g38aa6559b0-goog
>
>
>
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Chao Yu Feb. 20, 2024, 3:24 a.m. UTC | #2
On 2024/2/14 7:41, Jaegeuk Kim wrote:
> When we turn on sparse_mode, stat() will be failed, as the file will be
> created afterwards. Let's fix.
> 
> Fixes: 14197d546b93 ("f2fs-tools: fix to check loop device")
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,
diff mbox series

Patch

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 5c6c5b7bf8a7..d51e485361ee 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -814,6 +814,9 @@  int f2fs_dev_is_umounted(char *path)
 	 * the file system. In this case, we should not format.
 	 */
 	if (stat(path, &st_buf)) {
+		/* sparse file will be created after this. */
+		if (c.sparse_mode)
+			return 0;
 		MSG(0, "Info: stat failed errno:%d\n", errno);
 		return -1;
 	}