mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-26 19:51:32 +00:00
f2fs_io: support compress blocks ioctls
Adds to support below three commands to operate reserved blocks in compressed inode. - get_cblocks - release_cblocks - reserve_cblocks Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
36053752e8
commit
596408fd82
@ -697,6 +697,81 @@ static void do_copy(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
close(dst_fd);
|
||||
}
|
||||
|
||||
#define get_cblocks_desc "get number of reserved blocks on compress inode"
|
||||
#define get_cblocks_help "f2fs_io get_cblocks [file]\n\n"
|
||||
|
||||
static void do_get_cblocks(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
{
|
||||
unsigned long long blkcnt;
|
||||
int ret, fd;
|
||||
|
||||
if (argc != 2) {
|
||||
fputs("Excess arguments\n\n", stderr);
|
||||
fputs(cmd->cmd_help, stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fd = xopen(argv[1], O_RDONLY, 0);
|
||||
|
||||
ret = ioctl(fd, F2FS_IOC_GET_COMPRESS_BLOCKS, &blkcnt);
|
||||
if (ret < 0)
|
||||
die_errno("F2FS_IOC_GET_COMPRESS_BLOCKS failed");
|
||||
|
||||
printf("%llu\n", blkcnt);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#define release_cblocks_desc "release reserved blocks on compress inode"
|
||||
#define release_cblocks_help "f2fs_io release_cblocks [file]\n\n"
|
||||
|
||||
static void do_release_cblocks(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
{
|
||||
unsigned long long blkcnt;
|
||||
int ret, fd;
|
||||
|
||||
if (argc != 2) {
|
||||
fputs("Excess arguments\n\n", stderr);
|
||||
fputs(cmd->cmd_help, stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fd = xopen(argv[1], O_RDONLY, 0);
|
||||
|
||||
ret = ioctl(fd, F2FS_IOC_RELEASE_COMPRESS_BLOCKS, &blkcnt);
|
||||
if (ret < 0)
|
||||
die_errno("F2FS_IOC_RELEASE_COMPRESS_BLOCKS failed");
|
||||
|
||||
printf("%llu\n", blkcnt);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#define reserve_cblocks_desc "reserve blocks on compress inode"
|
||||
#define reserve_cblocks_help "f2fs_io reserve_cblocks [file]\n\n"
|
||||
|
||||
static void do_reserve_cblocks(int argc, char **argv, const struct cmd_desc *cmd)
|
||||
{
|
||||
unsigned long long blkcnt;
|
||||
int ret, fd;
|
||||
|
||||
if (argc != 2) {
|
||||
fputs("Excess arguments\n\n", stderr);
|
||||
fputs(cmd->cmd_help, stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fd = xopen(argv[1], O_RDONLY, 0);
|
||||
|
||||
ret = ioctl(fd, F2FS_IOC_RESERVE_COMPRESS_BLOCKS, &blkcnt);
|
||||
if (ret < 0)
|
||||
die_errno("F2FS_IOC_RESERVE_COMPRESS_BLOCKS failed");
|
||||
|
||||
printf("%llu\n", blkcnt);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
#define CMD_HIDDEN 0x0001
|
||||
#define CMD(name) { #name, do_##name, name##_desc, name##_help, 0 }
|
||||
@ -717,6 +792,9 @@ const struct cmd_desc cmd_list[] = {
|
||||
CMD(gc_urgent),
|
||||
CMD(defrag_file),
|
||||
CMD(copy),
|
||||
CMD(get_cblocks),
|
||||
CMD(release_cblocks),
|
||||
CMD(reserve_cblocks),
|
||||
{ NULL, NULL, NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
|
@ -68,6 +68,12 @@ typedef u32 __be32;
|
||||
#define F2FS_IOC_SET_PIN_FILE _IOW(F2FS_IOCTL_MAGIC, 13, __u32)
|
||||
#define F2FS_IOC_GET_PIN_FILE _IOR(F2FS_IOCTL_MAGIC, 14, __u32)
|
||||
#define F2FS_IOC_PRECACHE_EXTENTS _IO(F2FS_IOCTL_MAGIC, 15)
|
||||
#define F2FS_IOC_RESIZE_FS _IOW(F2FS_IOCTL_MAGIC, 16, __u64)
|
||||
#define F2FS_IOC_GET_COMPRESS_BLOCKS _IOR(F2FS_IOCTL_MAGIC, 17, __u64)
|
||||
#define F2FS_IOC_RELEASE_COMPRESS_BLOCKS \
|
||||
_IOR(F2FS_IOCTL_MAGIC, 18, __u64)
|
||||
#define F2FS_IOC_RESERVE_COMPRESS_BLOCKS \
|
||||
_IOR(F2FS_IOCTL_MAGIC, 19, __u64)
|
||||
|
||||
#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