diff mbox series

[f2fs-dev] f2fs_io: add fdatasync

Message ID 20240927025218.191544-1-weilongping@oppo.com (mailing list archive)
State Superseded
Headers show
Series [f2fs-dev] f2fs_io: add fdatasync | expand

Commit Message

LongPing Wei Sept. 27, 2024, 2:52 a.m. UTC
Signed-off-by: LongPing Wei <weilongping@oppo.com>
---
 tools/f2fs_io/f2fs_io.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Comments

Chao Yu Sept. 29, 2024, 3:11 a.m. UTC | #1
Hi, Longping,

Missed to update manual of f2fs_io?

On 2024/9/27 10:52, LongPing Wei wrote:
> Signed-off-by: LongPing Wei <weilongping@oppo.com>
> ---
>   tools/f2fs_io/f2fs_io.c | 25 +++++++++++++++++++++++++
>   1 file changed, 25 insertions(+)
> 
> diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
> index 94f0adf..8fbad3c 100644
> --- a/tools/f2fs_io/f2fs_io.c
> +++ b/tools/f2fs_io/f2fs_io.c
> @@ -174,6 +174,30 @@ static void do_fsync(int argc, char **argv, const struct cmd_desc *cmd)
>   	exit(0);
>   }
>   
> +#define fdatasync_desc "fdatasync"
> +#define fdatasync_help						\
> +"f2fs_io fdatasync [file]\n\n"					\
> +"fdatasync given the file\n"					\
> +
> +static void do_fdatasync(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 (fdatasync(fd) != 0)
> +		die_errno("fdatasync failed");
> +
> +	printf("fdatasync a file\n");
> +	exit(0);
> +}
> +
>   #define set_verity_desc "Set fs-verity"
>   #define set_verity_help					\
>   "f2fs_io set_verity [file]\n\n"				\
> @@ -1808,6 +1832,7 @@ static void do_help(int argc, char **argv, const struct cmd_desc *cmd);
>   const struct cmd_desc cmd_list[] = {
>   	_CMD(help),
>   	CMD(fsync),
> +	CMD(fdatasync),
>   	CMD(set_verity),
>   	CMD(getflags),
>   	CMD(setflags),
diff mbox series

Patch

diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index 94f0adf..8fbad3c 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -174,6 +174,30 @@  static void do_fsync(int argc, char **argv, const struct cmd_desc *cmd)
 	exit(0);
 }
 
+#define fdatasync_desc "fdatasync"
+#define fdatasync_help						\
+"f2fs_io fdatasync [file]\n\n"					\
+"fdatasync given the file\n"					\
+
+static void do_fdatasync(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 (fdatasync(fd) != 0)
+		die_errno("fdatasync failed");
+
+	printf("fdatasync a file\n");
+	exit(0);
+}
+
 #define set_verity_desc "Set fs-verity"
 #define set_verity_help					\
 "f2fs_io set_verity [file]\n\n"				\
@@ -1808,6 +1832,7 @@  static void do_help(int argc, char **argv, const struct cmd_desc *cmd);
 const struct cmd_desc cmd_list[] = {
 	_CMD(help),
 	CMD(fsync),
+	CMD(fdatasync),
 	CMD(set_verity),
 	CMD(getflags),
 	CMD(setflags),