* [PATCH 1/2] f2fs-tools: show versions if exist
@ 2018-11-16 6:06 Jaegeuk Kim
2018-11-16 6:06 ` [PATCH 2/2] f2fs-tools: create sparse file first before stat Jaegeuk Kim
2018-11-17 2:27 ` [PATCH 1/2] f2fs-tools: show versions if exist Chao Yu
0 siblings, 2 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2018-11-16 6:06 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim
If it's not defined, we need to skip to show the definition.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
include/f2fs_fs.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index cdf54e5..65cc8fd 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -1326,7 +1326,11 @@ static inline int is_qf_ino(struct f2fs_super_block *sb, nid_t ino)
static inline void show_version(const char *prog)
{
+#if defined(F2FS_TOOLS_VERSION) && defined(F2FS_TOOLS_DATE)
MSG(0, "%s %s (%s)\n", prog, F2FS_TOOLS_VERSION, F2FS_TOOLS_DATE);
+#else
+ MSG(0, "%s -- version not supported\n", prog);
+#endif
}
struct feature {
--
2.19.0.605.g01d371f741-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] f2fs-tools: create sparse file first before stat
2018-11-16 6:06 [PATCH 1/2] f2fs-tools: show versions if exist Jaegeuk Kim
@ 2018-11-16 6:06 ` Jaegeuk Kim
2018-11-17 2:32 ` Chao Yu
2018-11-17 2:27 ` [PATCH 1/2] f2fs-tools: show versions if exist Chao Yu
1 sibling, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2018-11-16 6:06 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim
We must create a sparse file first before calling stat().
Fixes: eb9d8037ed3b ("f2fs-tools: avoid mounting f2fs if tools already open the device")
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
lib/libf2fs.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index bf2830d..a1a5c02 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -793,17 +793,24 @@ int get_device_info(int i)
#endif
struct device_info *dev = c.devices + i;
+ if (c.sparse_mode) {
+ fd = open(dev->path, O_RDWR | O_CREAT | O_BINARY, 0644);
+ if (fd < 0) {
+ MSG(0, "\tError: Failed to open a sparse file!\n");
+ return -1;
+ }
+ }
+
stat_buf = malloc(sizeof(struct stat));
ASSERT(stat_buf);
- if (stat(dev->path, stat_buf) < 0 ) {
- MSG(0, "\tError: Failed to get the device stat!\n");
- free(stat_buf);
- return -1;
- }
- if (c.sparse_mode) {
- fd = open(dev->path, O_RDWR | O_CREAT | O_BINARY, 0644);
- } else {
+ if (!c.sparse_mode) {
+ if (stat(dev->path, stat_buf) < 0 ) {
+ MSG(0, "\tError: Failed to get the device stat!\n");
+ free(stat_buf);
+ return -1;
+ }
+
if (S_ISBLK(stat_buf->st_mode))
fd = open(dev->path, O_RDWR | O_EXCL);
else
--
2.19.0.605.g01d371f741-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] f2fs-tools: show versions if exist
2018-11-16 6:06 [PATCH 1/2] f2fs-tools: show versions if exist Jaegeuk Kim
2018-11-16 6:06 ` [PATCH 2/2] f2fs-tools: create sparse file first before stat Jaegeuk Kim
@ 2018-11-17 2:27 ` Chao Yu
1 sibling, 0 replies; 4+ messages in thread
From: Chao Yu @ 2018-11-17 2:27 UTC (permalink / raw)
To: Jaegeuk Kim, linux-f2fs-devel
On 2018-11-16 14:06, Jaegeuk Kim wrote:
> If it's not defined, we need to skip to show the definition.
>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Thanks,
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-11-17 2:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-16 6:06 [PATCH 1/2] f2fs-tools: show versions if exist Jaegeuk Kim
2018-11-16 6:06 ` [PATCH 2/2] f2fs-tools: create sparse file first before stat Jaegeuk Kim
2018-11-17 2:32 ` Chao Yu
2018-11-17 2:27 ` [PATCH 1/2] f2fs-tools: show versions if exist Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).