@@ -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);
Convert compression related ioctls to get extra attr ioctls. Signed-off-by: Sheng Yong <shengyong@oppo.com> --- tools/f2fs_io/f2fs_io.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)