From: Yongpeng Yang <[email protected]>

Add a flags parameter to the fiemap subcommand, allowing the
specification of whether to retrieve file mappings after writing to the
file.

Signed-off-by: Yongpeng Yang <[email protected]>
---
 tools/f2fs_io/f2fs_io.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index 4429e0b..3b19724 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -1341,8 +1341,11 @@ static void do_randread(int argc, char **argv, const 
struct cmd_desc *cmd)
 }
 
 #define fiemap_desc "get block address in file"
-#define fiemap_help                                    \
-"f2fs_io fiemap [offset in 4kb] [count in 4kb] [file_path]\n\n"\
+#define fiemap_help                                                    \
+"f2fs_io fiemap [offset in 4kb] [count in 4kb] [flags] [file_path]\n\n"        
\
+"flags can be the following values:\n"                                 \
+"0: No extra actions\n"                                                        
\
+"1: Sync file data before map\n"                                       \
 
 #if defined(HAVE_LINUX_FIEMAP_H) && defined(HAVE_LINUX_FS_H)
 static void do_fiemap(int argc, char **argv, const struct cmd_desc *cmd)
@@ -1350,10 +1353,10 @@ static void do_fiemap(int argc, char **argv, const 
struct cmd_desc *cmd)
        unsigned int i;
        int fd, extents_mem_size;
        u64 start, length;
-       u32 mapped_extents;
+       u32 mapped_extents, flags;
        struct fiemap *fm = xmalloc(sizeof(struct fiemap));
 
-       if (argc != 4) {
+       if (argc != 5) {
                fputs("Excess arguments\n\n", stderr);
                fputs(cmd->cmd_help, stderr);
                exit(1);
@@ -1362,10 +1365,12 @@ static void do_fiemap(int argc, char **argv, const 
struct cmd_desc *cmd)
        memset(fm, 0, sizeof(struct fiemap));
        start = (u64)atoi(argv[1]) * F2FS_DEFAULT_BLKSIZE;
        length = (u64)atoi(argv[2]) * F2FS_DEFAULT_BLKSIZE;
+       flags = (u32)atoi(argv[3]);
        fm->fm_start = start;
        fm->fm_length = length;
+       fm->fm_flags = flags;
 
-       fd = xopen(argv[3], O_RDONLY | O_LARGEFILE, 0);
+       fd = xopen(argv[4], O_RDONLY | O_LARGEFILE, 0);
 
        printf("Fiemap: offset = %"PRIu64" len = %"PRIu64"\n",
                                start / F2FS_DEFAULT_BLKSIZE,
@@ -1381,6 +1386,7 @@ static void do_fiemap(int argc, char **argv, const struct 
cmd_desc *cmd)
        memset(fm, 0, sizeof(struct fiemap) + extents_mem_size);
        fm->fm_start = start;
        fm->fm_length = length;
+       fm->fm_flags = flags;
        fm->fm_extent_count = mapped_extents;
 
        if (ioctl(fd, FS_IOC_FIEMAP, fm) < 0)
-- 
2.50.1



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

Reply via email to