f2fs_io: add set_fsverity

f2fs_io set_verity [file]

Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
This commit is contained in:
Jaegeuk Kim 2019-02-11 18:21:30 -08:00 committed by Jaegeuk Kim
parent 5d6d65d04b
commit f0f29da924
2 changed files with 30 additions and 0 deletions

View File

@ -130,6 +130,33 @@ static void full_write(int fd, const void *buf, size_t count)
}
}
#define set_verity_desc "Set fs-verity"
#define set_verity_help \
"f2fs_io set_verity [file]\n\n" \
"Set fsverity bit given a file\n" \
static void do_set_verity(int argc, char **argv, const struct cmd_desc *cmd)
{
int ret, fd;
if (argc != 2) {
fputs("Excess arguments\n\n", stderr);
fputs(cmd->cmd_help, stderr);
exit(1);
}
fd = open(argv[1], O_RDWR);
ret = ioctl(fd, FS_IOC_ENABLE_VERITY);
if (ret < 0) {
perror("FS_IOC_ENABLE_VERITY");
exit(1);
}
printf("Set fsverity bit to %s\n", argv[1]);
exit(0);
}
#define getflags_desc "getflags ioctl"
#define getflags_help \
"f2fs_io getflags [file]\n\n" \
@ -678,6 +705,7 @@ static void do_copy(int argc, char **argv, const struct cmd_desc *cmd)
static void do_help(int argc, char **argv, const struct cmd_desc *cmd);
const struct cmd_desc cmd_list[] = {
_CMD(help),
CMD(set_verity),
CMD(getflags),
CMD(setflags),
CMD(shutdown),

View File

@ -73,6 +73,8 @@ typedef u32 __be32;
#define F2FS_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY
#define F2FS_IOC_GET_ENCRYPTION_PWSALT FS_IOC_GET_ENCRYPTION_PWSALT
#define FS_IOC_ENABLE_VERITY _IO('f', 133)
/*
* Inode flags
*/