f2fs_io: add compress/decompress commands
PATCH 1/1 f2fs_io: add compress/decompress commands
From: Daeho Jeong <[email protected]>
Added new commands, compress and decompress, to support F2FS_IOC_COMPRESS_FILE and F2FS_IOC_DECOMPRESS_FILE.
Signed-off-by Daeho Jeong <[email protected]>
--- tools/f2fs_io/f2fs_io.c | 46 +++++++++++++++++++++++++++++++++++++++++ tools/f2fs_io/f2fs_io.h | 2 ++ 2 files changed, 48 insertions(+)
tools/f2fs_io/f2fs_io.c +46 -0
@@ -965,6 +965,50 @@ static void do_set_coption(int argc, char **argv, const struct cmd_desc *cmd)exit (0 ); } +#define decompress_desc "decompress an already compressed file" +#define decompress_help "f2fs_io decompress [file_path]\n\n" + +static void do_decompress (int argc,char **argv,const struct cmd_desc *cmd) +{ +int fd, ret; + +if (argc !=2 ) { +fputs ("Excess arguments\n\n" , stderr); +fputs (cmd->cmd_help, stderr); +exit (1 ); + } + + fd =xopen (argv[1 ],O_WRONLY ,0 ); + + ret =ioctl (fd,F2FS_IOC_DECOMPRESS_FILE ); +if (ret <0 ) +die_errno ("F2FS_IOC_DECOMPRESS_FILE failed" ); + +exit (0 ); +} + +#define compress_desc "compress a compression enabled file" +#define compress_help "f2fs_io compress [file_path]\n\n" + +static void do_compress (int argc,char **argv,const struct cmd_desc *cmd) +{ +int fd, ret; + +if (argc !=2 ) { +fputs ("Excess arguments\n\n" , stderr); +fputs (cmd->cmd_help, stderr); +exit (1 ); + } + + fd =xopen (argv[1 ],O_WRONLY ,0 ); + + ret =ioctl (fd,F2FS_IOC_COMPRESS_FILE ); +if (ret <0 ) +die_errno ("F2FS_IOC_COMPRESS_FILE 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 }
@@ -991,6 +1035,8 @@ const struct cmd_desc cmd_list[] = {CMD (reserve_cblocks),CMD (get_coption),CMD (set_coption), +CMD (decompress), +CMD (compress), { NULL, NULL, NULL, NULL, 0 } };
tools/f2fs_io/f2fs_io.h +2 -0
@@ -88,6 +88,8 @@ typedef u32 __be32; struct f2fs_comp_option)#define F2FS_IOC_SET_COMPRESS_OPTION _IOW(F2FS_IOCTL_MAGIC, 22, \ struct f2fs_comp_option) +#define F2FS_IOC_DECOMPRESS_FILE _IO(F2FS_IOCTL_MAGIC, 23) +#define F2FS_IOC_COMPRESS_FILE _IO(F2FS_IOCTL_MAGIC, 24)#define F2FS_IOC_SET_ENCRYPTION_POLICY FS_IOC_SET_ENCRYPTION_POLICY#define F2FS_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY
Signature · 8 lines
2.29.2.576.ga3fc446d84-goog _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 6 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
Added new commands, compress and decompress, to support
F2FS_IOC_COMPRESS_FILEandF2FS_IOC_DECOMPRESS_FILE.Signed-off-by Daeho Jeong <[email protected]>
Reviewed-by Chao Yu <[email protected]>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel