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] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230529013502.2230810-3-shengyong@oppo.com>
Date:   Mon, 29 May 2023 09:35:02 +0800
From:   Sheng Yong <shengyong@...o.com>
To:     jaegeuk@...nel.org, chao@...nel.org
Cc:     linux-f2fs-devel@...ts.sourceforge.net,
        linux-kernel@...r.kernel.org, Sheng Yong <shengyong@...o.com>
Subject: [PATCH 2/2] f2fs_io: convert compression ioctls to [get|set]_attr

Convert compression related ioctls to get extra attr ioctls.

Signed-off-by: Sheng Yong <shengyong@...o.com>
---
 tools/f2fs_io/f2fs_io.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index 70e0347..f6e6057 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -1012,7 +1012,9 @@ static void do_copy(int argc, char **argv, const struct cmd_desc *cmd)
 
 static void do_get_cblocks(int argc, char **argv, const struct cmd_desc *cmd)
 {
-	unsigned long long blkcnt;
+	struct f2fs_extra_attr attr = {
+		.field = F2FS_EXTRA_ATTR_COMPR_BLOCKS,
+	};
 	int ret, fd;
 
 	if (argc != 2) {
@@ -1023,11 +1025,11 @@ static void do_get_cblocks(int argc, char **argv, const struct cmd_desc *cmd)
 
 	fd = xopen(argv[1], O_RDONLY, 0);
 
-	ret = ioctl(fd, F2FS_IOC_GET_COMPRESS_BLOCKS, &blkcnt);
+	ret = ioctl(fd, F2FS_IOC_GET_EXTRA_ATTR, &attr);
 	if (ret < 0)
 		die_errno("F2FS_IOC_GET_COMPRESS_BLOCKS failed");
 
-	printf("%llu\n", blkcnt);
+	printf("%llu\n", (unsigned long long)attr.attr);
 
 	exit(0);
 }
@@ -1090,6 +1092,7 @@ static void do_reserve_cblocks(int argc, char **argv, const struct cmd_desc *cmd
 
 static void do_get_coption(int argc, char **argv, const struct cmd_desc *cmd)
 {
+	struct f2fs_extra_attr attr = {0};
 	struct f2fs_comp_option option;
 	int ret, fd;
 
@@ -1099,11 +1102,15 @@ static void do_get_coption(int argc, char **argv, const struct cmd_desc *cmd)
 		exit(1);
 	}
 
+	attr.field = F2FS_EXTRA_ATTR_COMPR_OPTION;
+	attr.attr_size = sizeof(option);
+	attr.attr = (unsigned long)&option;
+
 	fd = xopen(argv[1], O_RDONLY, 0);
 
-	ret = ioctl(fd, F2FS_IOC_GET_COMPRESS_OPTION, &option);
+	ret = ioctl(fd, F2FS_IOC_GET_EXTRA_ATTR, &attr);
 	if (ret < 0)
-		die_errno("F2FS_IOC_GET_COMPRESS_OPTION failed");
+		die_errno("F2FS_IOC_GET_EXTRA_ATTR failed");
 
 	printf("compression algorithm:%u\n", option.algorithm);
 	printf("compression cluster log size:%u\n", option.log_cluster_size);
@@ -1119,6 +1126,7 @@ static void do_get_coption(int argc, char **argv, const struct cmd_desc *cmd)
 
 static void do_set_coption(int argc, char **argv, const struct cmd_desc *cmd)
 {
+	struct f2fs_extra_attr attr = {0};
 	struct f2fs_comp_option option;
 	int fd, ret;
 
@@ -1130,12 +1138,15 @@ static void do_set_coption(int argc, char **argv, const struct cmd_desc *cmd)
 
 	option.algorithm = atoi(argv[1]);
 	option.log_cluster_size = atoi(argv[2]);
+	attr.field = F2FS_EXTRA_ATTR_COMPR_OPTION;
+	attr.attr_size = sizeof(option);
+	attr.attr = (unsigned long)&option;
 
 	fd = xopen(argv[3], O_WRONLY, 0);
 
-	ret = ioctl(fd, F2FS_IOC_SET_COMPRESS_OPTION, &option);
+	ret = ioctl(fd, F2FS_IOC_SET_EXTRA_ATTR, &attr);
 	if (ret < 0)
-		die_errno("F2FS_IOC_SET_COMPRESS_OPTION failed");
+		die_errno("F2FS_IOC_SET_EXTRA_ATTR failed");
 
 	printf("set compression option: algorithm=%u, log_cluster_size=%u\n",
 			option.algorithm, option.log_cluster_size);
-- 
2.40.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ