f2fs_io: add fsync
PATCH 1/3 f2fs_io: add fsync
--- tools/f2fs_io/f2fs_io.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
tools/f2fs_io/f2fs_io.c +25 -0
@@ -130,6 +130,30 @@ static void full_write(int fd, const void *buf, size_t count) } } +#define fsync_desc "fsync" +#define fsync_help \ +"f2fs_io fsync [file]\n\n" \ +"fsync given the file\n" \ + +static void do_fsync (int argc,char **argv,const struct cmd_desc *cmd) +{ +int fd; + +if (argc !=2 ) { +fputs ("Excess arguments\n\n" , stderr); +fputs (cmd->cmd_help, stderr); +exit (1 ); + } + + fd =xopen (argv[1 ],O_WRONLY ,0 ); + +if (fsync (fd) !=0 ) +die_errno ("fsync failed" ); + +printf ("fsync a file\n" ); +exit (0 ); +} +#define set_verity_desc "Set fs-verity"#define set_verity_help \ "f2fs_io set_verity [file]\n\n" \
@@ -780,6 +804,7 @@ static void do_reserve_cblocks(int argc, char **argv, const struct cmd_desc *cmdstatic void do_help (int argc,char **argv,const struct cmd_desc *cmd);const struct cmd_desc cmd_list[] = {_CMD (help), +CMD (fsync),CMD (set_verity),CMD (getflags),CMD (setflags),
Signature · 8 lines
2.26.2.526.g744177e7f7-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 2/3 f2fs_io: don't give garbage data in upper 32bits
--- tools/f2fs_io/f2fs_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/f2fs_io/f2fs_io.c +2 -2
@@ -192,7 +192,7 @@ static void do_set_verity(int argc, char **argv, const struct cmd_desc *cmd)static void do_getflags (int argc,char **argv,const struct cmd_desc *cmd) { -long flag; +long flag =0 ;int ret, fd;int exist =0 ;
@@ -239,7 +239,7 @@ static void do_getflags(int argc, char **argv, const struct cmd_desc *cmd)static void do_setflags (int argc,char **argv,const struct cmd_desc *cmd) { -long flag; +long flag =0 ;int ret, fd;if (argc !=3 ) {
Signature · 8 lines
2.26.2.526.g744177e7f7-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 2/3] f2fs_io: don't give garbage data in upper 32bits
Quoted 1 line · Jaegeuk Kim
Signed-off-by Jaegeuk Kim <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 3/3 f2fs_io: show more flags
In reply to Jaegeuk Kim--- tools/f2fs_io/f2fs_io.c | 28 ++++++++++++++++++++++++++++ tools/f2fs_io/f2fs_io.h | 12 ++++++++++++ 2 files changed, 40 insertions(+)
tools/f2fs_io/f2fs_io.c +28 -0
@@ -186,6 +186,10 @@ static void do_set_verity(int argc, char **argv, const struct cmd_desc *cmd)"f2fs_io getflags [file]\n\n" \"get a flag given the file\n" \"flag can show \n" \ +" encryption\n" \ +" nocow(pinned)\n" \ +" inline_data\n" \ +" verity\n" \" casefold\n" \" compression\n" \" nocompression\n"
@@ -222,6 +226,30 @@ static void do_getflags(int argc, char **argv, const struct cmd_desc *cmd)printf ("nocompression" ); exist =1 ; } +if (flag &FS_ENCRYPT_FL ) { +if (exist) +printf ("," ); +printf ("encrypt" ); + exist =1 ; + } +if (flag &FS_VERITY_FL ) { +if (exist) +printf ("," ); +printf ("verity" ); + exist =1 ; + } +if (flag &FS_INLINE_DATA_FL ) { +if (exist) +printf ("," ); +printf ("inline_data" ); + exist =1 ; + } +if (flag &FS_NOCOW_FL ) { +if (exist) +printf ("," ); +printf ("nocow(pinned)" ); + exist =1 ; + }if (!exist)printf ("none" );printf ("\n" );
tools/f2fs_io/f2fs_io.h +12 -0
@@ -110,6 +110,18 @@ typedef u32 __be32;#define F2FS_IOC_FSGETXATTR FS_IOC_FSGETXATTR#define F2FS_IOC_FSSETXATTR FS_IOC_FSSETXATTR +#ifndef FS_ENCRYPT_FL +#define FS_ENCRYPT_FL 0x00000800/* Encrypted file */ +#endif +#ifndef FS_VERITY_FL +#define FS_VERITY_FL 0x00100000/* Verity protected inode */ +#endif +#ifndef FS_INLINE_DATA_FL +#define FS_INLINE_DATA_FL 0x10000000/* Reserved for ext4 */ +#endif +#ifndef FS_NOCOW_FL +#define FS_NOCOW_FL 0x00800000/* Do not cow file */ +#endif #ifndef FS_NOCOMP_FL #define FS_NOCOMP_FL 0x00000400/* Don't compress */ #endif
Signature · 8 lines
2.26.2.526.g744177e7f7-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 3/3] f2fs_io: show more flags
Quoted 58 lines · Jaegeuk Kim
Signed-off-by Jaegeuk Kim <[email protected]>--- tools/f2fs_io/f2fs_io.c | 28 ++++++++++++++++++++++++++++ tools/f2fs_io/f2fs_io.h | 12 ++++++++++++ 2 files changed, 40 insertions(+)tools/f2fs_io/f2fs_io.c +28
-0@@ -186,6 +186,10 @@ static void do_set_verity(int argc, char **argv, const struct cmd_desc *cmd)"f2fs_io getflags [file]\n\n" \"get a flag given the file\n" \"flag can show \n" \ +" encryption\n" \ +" nocow(pinned)\n" \ +" inline_data\n" \ +" verity\n" \" casefold\n" \" compression\n" \" nocompression\n" @@ -222,6 +226,30 @@ static void do_getflags(int argc, char **argv, const struct cmd_desc *cmd)printf ("nocompression" ); exist =1 ; } +if (flag &FS_ENCRYPT_FL ) { +if (exist) +printf ("," ); +printf ("encrypt" ); + exist =1 ; + } +if (flag &FS_VERITY_FL ) { +if (exist) +printf ("," ); +printf ("verity" ); + exist =1 ; + } +if (flag &FS_INLINE_DATA_FL ) { +if (exist) +printf ("," ); +printf ("inline_data" ); + exist =1 ; + } +if (flag &FS_NOCOW_FL ) { +if (exist) +printf ("," ); +printf ("nocow(pinned)" ); + exist =1 ; + }if (!exist)printf ("none" );printf ("\n" );tools/f2fs_io/f2fs_io.h +0
-0@@ -110,6 +110,18 @@ typedef u32 __be32;#define F2FS_IOC_FSGETXATTR FS_IOC_FSGETXATTR
tools/f2fs_io/f2fs_io.h typedef u32 __be32; · line 120
Quoted 10 lines
tools/f2fs_io/f2fs_io.h +8
-0#define F2FS_IOC_FSSETXATTR FS_IOC_FSSETXATTR +#ifndef FS_ENCRYPT_FL +#define FS_ENCRYPT_FL 0x00000800/* Encrypted file */ +#endif +#ifndef FS_VERITY_FL +#define FS_VERITY_FL 0x00100000/* Verity protected inode */ +#endif +#ifndef FS_INLINE_DATA_FL +#define FS_INLINE_DATA_FL 0x10000000/* Reserved for ext4 */
/* Inline data regular/symlink */
tools/f2fs_io/f2fs_io.h typedef u32 __be32; · line 127
Quoted 8 lines
tools/f2fs_io/f2fs_io.h +4
-0+#endif +#ifndef FS_NOCOW_FL +#define FS_NOCOW_FL 0x00800000/* Do not cow file */ +#endif #ifndef FS_NOCOMP_FL #define FS_NOCOMP_FL 0x00000400/* Don't compress */ #endif
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 3/3] f2fs_io: show more flags
Quoted 61 lines · Chao Yu
Quoted 60 lines · Jaegeuk Kim
Signed-off-by Jaegeuk Kim <[email protected]>--- tools/f2fs_io/f2fs_io.c | 28 ++++++++++++++++++++++++++++ tools/f2fs_io/f2fs_io.h | 12 ++++++++++++ 2 files changed, 40 insertions(+)tools/f2fs_io/f2fs_io.c +28
-0@@ -186,6 +186,10 @@ static void do_set_verity(int argc, char **argv, const struct cmd_desc *cmd)"f2fs_io getflags [file]\n\n" \"get a flag given the file\n" \"flag can show \n" \ +" encryption\n" \ +" nocow(pinned)\n" \ +" inline_data\n" \ +" verity\n" \" casefold\n" \" compression\n" \" nocompression\n" @@ -222,6 +226,30 @@ static void do_getflags(int argc, char **argv, const struct cmd_desc *cmd)printf ("nocompression" ); exist =1 ; } +if (flag &FS_ENCRYPT_FL ) { +if (exist) +printf ("," ); +printf ("encrypt" ); + exist =1 ; + } +if (flag &FS_VERITY_FL ) { +if (exist) +printf ("," ); +printf ("verity" ); + exist =1 ; + } +if (flag &FS_INLINE_DATA_FL ) { +if (exist) +printf ("," ); +printf ("inline_data" ); + exist =1 ; + } +if (flag &FS_NOCOW_FL ) { +if (exist) +printf ("," ); +printf ("nocow(pinned)" ); + exist =1 ; + }if (!exist)printf ("none" );printf ("\n" );tools/f2fs_io/f2fs_io.h +0
-0@@ -110,6 +110,18 @@ typedef u32 __be32;#define F2FS_IOC_FSGETXATTR FS_IOC_FSGETXATTR#define F2FS_IOC_FSSETXATTR FS_IOC_FSSETXATTR
Quoted 10 lines
tools/f2fs_io/f2fs_io.h typedef u32 __be32; · line 120
Quoted 8 lines
tools/f2fs_io/f2fs_io.h +8
-0+#ifndef FS_ENCRYPT_FL +#define FS_ENCRYPT_FL 0x00000800/* Encrypted file */ +#endif +#ifndef FS_VERITY_FL +#define FS_VERITY_FL 0x00100000/* Verity protected inode */ +#endif +#ifndef FS_INLINE_DATA_FL +#define FS_INLINE_DATA_FL 0x10000000/* Reserved for ext4 */ /* Inline data regular/symlink */
Done.
Quoted 9 lines
tools/f2fs_io/f2fs_io.h typedef u32 __be32; · line 127
Quoted 9 lines
tools/f2fs_io/f2fs_io.h +4
-0+#endif +#ifndef FS_NOCOW_FL +#define FS_NOCOW_FL 0x00800000/* Do not cow file */ +#endif #ifndef FS_NOCOMP_FL #define FS_NOCOMP_FL 0x00000400/* Don't compress */ #endif
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 10 lines · Jaegeuk Kim
Signed-off-by Jaegeuk Kim <[email protected]>--- tools/f2fs_io/f2fs_io.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)tools/f2fs_io/f2fs_io.c +0
-0
tools/f2fs_io/f2fs_io.c static void full_write(int fd, const void *buf, size_t count) · line 135
Quoted 6 lines
tools/f2fs_io/f2fs_io.c +3
-0@@ -130,6 +130,30 @@ static void full_write(int fd, const void *buf, size_t count) } } +#define fsync_desc "fsync" +#define fsync_help \ +"f2fs_io fsync [file]\n\n" \
What about supporting fdatasync via an additional argument here?
Quoted 26 lines
tools/f2fs_io/f2fs_io.c +21
-0+"fsync given the file\n" \ + +static void do_fsync(int argc, char **argv, const struct cmd_desc *cmd) +{ +int fd; + +if (argc !=2 ) { +fputs ("Excess arguments\n\n" , stderr); +fputs (cmd->cmd_help, stderr); +exit (1 ); + } + + fd =xopen (argv[1 ],O_WRONLY ,0 ); + +if (fsync (fd) !=0 ) +die_errno ("fsync failed" ); + +printf ("fsync a file\n" ); +exit (0 ); +} +#define set_verity_desc "Set fs-verity"#define set_verity_help \ "f2fs_io set_verity [file]\n\n" \
tools/f2fs_io/f2fs_io.c static void do_reserve_cblocks(int argc, char **argv, const struct cmd_desc *cmd · line 810
Quoted 7 lines
tools/f2fs_io/f2fs_io.c +1
-0@@ -780,6 +804,7 @@ static void do_reserve_cblocks(int argc, char **argv, const struct cmd_desc *cmdstatic void do_help (int argc,char **argv,const struct cmd_desc *cmd);const struct cmd_desc cmd_list[] = {_CMD (help), +CMD (fsync),CMD (set_verity),CMD (getflags),CMD (setflags),
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 14 lines · Chao Yu
Quoted 13 lines · Jaegeuk Kim
Signed-off-by Jaegeuk Kim <[email protected]>--- tools/f2fs_io/f2fs_io.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)tools/f2fs_io/f2fs_io.c +0
-0@@ -130,6 +130,30 @@ static void full_write(int fd, const void *buf, size_t count) } }
Quoted 5 lines
tools/f2fs_io/f2fs_io.c static void full_write(int fd, const void *buf, size_t count) · line 135
Quoted 3 lines
tools/f2fs_io/f2fs_io.c +3
-0+#define fsync_desc "fsync" +#define fsync_help \ +"f2fs_io fsync [file]\n\n" \What about supporting fdatasync via an additional argument here?
I prefer to add another command "fdatasync" for simplicity. :P
Quoted 26 lines
Quoted 26 lines
tools/f2fs_io/f2fs_io.c +21
-0+"fsync given the file\n" \ + +static void do_fsync(int argc, char **argv, const struct cmd_desc *cmd) +{ +int fd; + +if (argc !=2 ) { +fputs ("Excess arguments\n\n" , stderr); +fputs (cmd->cmd_help, stderr); +exit (1 ); + } + + fd =xopen (argv[1 ],O_WRONLY ,0 ); + +if (fsync (fd) !=0 ) +die_errno ("fsync failed" ); + +printf ("fsync a file\n" ); +exit (0 ); +} +#define set_verity_desc "Set fs-verity"#define set_verity_help \ "f2fs_io set_verity [file]\n\n" \@@ -780,6 +804,7 @@ static void do_reserve_cblocks(int argc, char **argv, const struct cmd_desc *cmd
Quoted 8 lines
tools/f2fs_io/f2fs_io.c static void do_reserve_cblocks(int argc, char **argv, const struct cmd_desc *cmd · line 810
Quoted 8 lines
tools/f2fs_io/f2fs_io.c +1
-0static void do_help (int argc,char **argv,const struct cmd_desc *cmd);const struct cmd_desc cmd_list[] = {_CMD (help), +CMD (fsync),CMD (set_verity),CMD (getflags),CMD (setflags),
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 15 lines · Jaegeuk Kim
Quoted 14 lines · Chao Yu
Quoted 13 lines · Jaegeuk Kim
Signed-off-by Jaegeuk Kim <[email protected]>--- tools/f2fs_io/f2fs_io.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)tools/f2fs_io/f2fs_io.c +0
-0@@ -130,6 +130,30 @@ static void full_write(int fd, const void *buf, size_t count) } }
Quoted 7 lines
Quoted 5 lines
tools/f2fs_io/f2fs_io.c static void full_write(int fd, const void *buf, size_t count) · line 135
Quoted 3 lines
tools/f2fs_io/f2fs_io.c +3
-0+#define fsync_desc "fsync" +#define fsync_help \ +"f2fs_io fsync [file]\n\n" \What about supporting fdatasync via an additional argument here?
I prefer to add another command "fdatasync" for simplicity. :P
LGTM as well. :)
Thanks
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
tools/f2fs_io/f2fs_io.c +21
-0+"fsync given the file\n" \ + +static void do_fsync(int argc, char **argv, const struct cmd_desc *cmd) +{ +int fd; + +if (argc !=2 ) { +fputs ("Excess arguments\n\n" , stderr); +fputs (cmd->cmd_help, stderr); +exit (1 ); + } + + fd =xopen (argv[1 ],O_WRONLY ,0 ); + +if (fsync (fd) !=0 ) +die_errno ("fsync failed" ); + +printf ("fsync a file\n" ); +exit (0 ); +} +#define set_verity_desc "Set fs-verity"#define set_verity_help \ "f2fs_io set_verity [file]\n\n" \@@ -780,6 +804,7 @@ static void do_reserve_cblocks(int argc, char **argv, const struct cmd_desc *cmdstatic void do_help (int argc,char **argv,const struct cmd_desc *cmd);
Quoted 9 lines
Quoted 7 lines
tools/f2fs_io/f2fs_io.c static void do_reserve_cblocks(int argc, char **argv, const struct cmd_desc *cmd · line 810
Quoted 7 lines
tools/f2fs_io/f2fs_io.c +1
-0const struct cmd_desc cmd_list[] = {_CMD (help), +CMD (fsync),CMD (set_verity),CMD (getflags),CMD (setflags),.
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel