Skip to contentSkip to conversation

mkfs.f2fs: fix sparse_mode case on stat

PATCH In review Jaegeuk Kim 3 participants 3 messages Feb 13, 2024 – Feb 20, 2024 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mkfs.f2fs: fix sparse_mode case on stat

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")
---
 lib/libf2fs.c | 3 +++
 1 file changed, 3 insertions(+)
lib/libf2fs.c +3 -0
index 5c6c5b7bf8a7..d51e485361ee 100644
@@ -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;
 	}
Signature · 8 lines
2.43.0.687.g38aa6559b0-goog



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · Jaegeuk Kim

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")
---
 lib/libf2fs.c | 3 +++
 1 file changed, 3 insertions(+)
lib/libf2fs.c +3 -1
index 5c6c5b7bf8a7..d51e485361ee 100644
@@ -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

Quoted 4 lines

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reviewed-by on v1 1/1
#2 lore raw
In reply to Jaegeuk Kim
Quoted 5 lines · Jaegeuk Kim

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")

Thanks,

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel