mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-23 01:59:54 +00:00
f2fs_io: add compress/decompress commands
commit 7b63f7b399
category: bugfix
issue: #I6VAS0
CVE: NA
Signed-off-by: DongSenhao <dongsenhao2@huawei.com>
---------------------------------------
Added new commands, compress and decompress, to support
F2FS_IOC_COMPRESS_FILE and F2FS_IOC_DECOMPRESS_FILE.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: dongsenhao <dongsenhao2@huawei.com>
This commit is contained in:
parent
89dc315596
commit
a1879e5af8
@ -1052,6 +1052,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 }
|
||||
@ -1079,6 +1123,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 }
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user