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: <ded879cd-9ee0-5f0d-d745-c0ba26eebfb8@kernel.org>
Date:   Thu, 17 Aug 2023 22:58:50 +0800
From:   Chao Yu <chao@...nel.org>
To:     Qi Han <hanqi@...o.com>, jaegeuk@...nel.org
Cc:     linux-f2fs-devel@...ts.sourceforge.net,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] f2fs_io: add do_clearflags to clear nocompress/compress
 flag

On 2023/8/15 19:19, Qi Han wrote:
> To align f2fs_io functionality with chattr +/-c and +/-m, the
> do_clearflags function has been added to clear the FS_COMPR_FL and
> FS_NOCOMP_FL flags.
> 
> Signed-off-by: Qi Han <hanqi@...o.com>
> ---
>   man/f2fs_io.8           |  4 ++++
>   tools/f2fs_io/f2fs_io.c | 37 +++++++++++++++++++++++++++++++++++++
>   2 files changed, 41 insertions(+)
> 
> diff --git a/man/f2fs_io.8 b/man/f2fs_io.8
> index 450f1b7..4ffb28d 100644
> --- a/man/f2fs_io.8
> +++ b/man/f2fs_io.8
> @@ -18,6 +18,10 @@ Get the flags associated with the specified file.
>   Set an f2fs file on specified file.  The flag can be casefold,
>   compression, and nocompression.
>   .TP
> +\fBclearflags\fR \fI[flag] [file]\fR
> +Clear an f2fs file on specified file.  The flag can be compression,

Clear a specified flag on target file?

Thanks,

> +and nocompression.
> +.TP
>   \fBshutdown\fR \fIshutdown filesystem\fR
>   Freeze and stop all IOs for the file system mounted on
>   .IR dir.
> diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
> index 73ac700..a450bf1 100644
> --- a/tools/f2fs_io/f2fs_io.c
> +++ b/tools/f2fs_io/f2fs_io.c
> @@ -330,6 +330,42 @@ static void do_setflags(int argc, char **argv, const struct cmd_desc *cmd)
>   	exit(0);
>   }
>   
> +#define clearflags_desc "clearflags ioctl"
> +#define clearflags_help						\
> +"f2fs_io clearflags [flag] [file]\n\n"				\
> +"clear a flag given the file\n"					\
> +"flag can be\n"							\
> +"  compression\n"						\
> +"  nocompression\n"						\
> +
> +static void do_clearflags(int argc, char **argv, const struct cmd_desc *cmd)
> +{
> +	long flag = 0;
> +	int ret, fd;
> +
> +	if (argc != 3) {
> +		fputs("Excess arguments\n\n", stderr);
> +		fputs(cmd->cmd_help, stderr);
> +		exit(1);
> +	}
> +
> +	fd = xopen(argv[2], O_RDONLY, 0);
> +
> +	ret = ioctl(fd, F2FS_IOC_GETFLAGS, &flag);
> +	printf("get a flag on %s ret=%d, flags=%lx\n", argv[1], ret, flag);
> +	if (ret)
> +		die_errno("F2FS_IOC_GETFLAGS failed");
> +
> +	if (!strcmp(argv[1], "compression"))
> +		flag &= ~FS_COMPR_FL;
> +	else if (!strcmp(argv[1], "nocompression"))
> +		flag &= ~FS_NOCOMP_FL;
> +
> +	ret = ioctl(fd, F2FS_IOC_SETFLAGS, &flag);
> +	printf("clear a flag on %s ret=%d, flags=%s\n", argv[2], ret, argv[1]);
> +	exit(0);
> +}
> +
>   #define shutdown_desc "shutdown filesystem"
>   #define shutdown_help					\
>   "f2fs_io shutdown [level] [dir]\n\n"			\
> @@ -1464,6 +1500,7 @@ const struct cmd_desc cmd_list[] = {
>   	CMD(set_verity),
>   	CMD(getflags),
>   	CMD(setflags),
> +	CMD(clearflags),
>   	CMD(shutdown),
>   	CMD(pinfile),
>   	CMD(fallocate),

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ