lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6f097ce3-5a0b-4d58-bd48-6b2ed135747f@kernel.org>
Date: Wed, 26 Feb 2025 09:45:20 +0800
From: Chao Yu <chao@...nel.org>
To: Daeho Jeong <daeho43@...il.com>, linux-kernel@...r.kernel.org,
 linux-f2fs-devel@...ts.sourceforge.net, kernel-team@...roid.com
Cc: chao@...nel.org, Daeho Jeong <daehojeong@...gle.com>
Subject: Re: [f2fs-dev] [PATCH] f2fs-tools: add ftruncate command in f2fs_io

On 2/26/25 08:27, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@...gle.com>
> 
> add ftruncate command to do file truncate.

Need to update manual of f2fs_io as well?

Thanks,

> 
> Signed-off-by: Daeho Jeong <daehojeong@...gle.com>
> ---
>  tools/f2fs_io/f2fs_io.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
> index fa01f8f..08056a9 100644
> --- a/tools/f2fs_io/f2fs_io.c
> +++ b/tools/f2fs_io/f2fs_io.c
> @@ -1887,6 +1887,31 @@ static void do_get_advise(int argc, char **argv, const struct cmd_desc *cmd)
>  	printf("\n");
>  }
>  
> +#define ftruncate_desc "ftruncate a file"
> +#define ftruncate_help					\
> +"f2fs_io ftruncate [length] [file_path]\n\n"	\
> +"Do ftruncate a file in file_path with the length\n"	\
> +
> +static void do_ftruncate(int argc, char **argv, const struct cmd_desc *cmd)
> +{
> +	int fd, ret;
> +	off_t length;
> +
> +	if (argc != 3) {
> +		fputs("Excess arguments\n\n", stderr);
> +		fputs(cmd->cmd_help, stderr);
> +		exit(1);
> +	}
> +
> +	length = atoll(argv[1]);
> +	fd = xopen(argv[2], O_WRONLY, 0);
> +
> +	ret = ftruncate(fd, length);
> +	if (ret < 0)
> +		die_errno("ftruncate failed");
> +	exit(0);
> +}
> +
>  #define CMD_HIDDEN 	0x0001
>  #define CMD(name) { #name, do_##name, name##_desc, name##_help, 0 }
>  #define _CMD(name) { #name, do_##name, NULL, NULL, CMD_HIDDEN }
> @@ -1932,6 +1957,7 @@ const struct cmd_desc cmd_list[] = {
>  	CMD(removexattr),
>  	CMD(lseek),
>  	CMD(get_advise),
> +	CMD(ftruncate),
>  	{ NULL, NULL, NULL, NULL, 0 }
>  };
>  


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ