xfs_io: implement 'set_encpolicy' and 'get_encpolicy' commands
PATCH v2 1/1 xfs_io: implement 'set_encpolicy' and 'get_encpolicy' commands
From: Eric Biggers <[email protected]>
Add set_encpolicy and get_encpolicy commands to xfs_io so that xfstests will be able to test filesystem encryption using the actual user API, not just hacked in with a mount option. These commands use the common "fscrypt" API currently implemented by ext4 and f2fs, but it's also under development for ubifs and planned for xfs.
Note that to get encrypted files to actually work, it's also necessary to add a key to the kernel keyring. This patch does not add a command for this to xfs_io because it's possible to do it using keyctl. keyctl can also be used to remove keys, revoke keys, invalidate keys, etc.
--- io/Makefile | 6 +- io/encrypt.c | 302 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ io/init.c | 1 + io/io.h | 1 + man/man8/xfs_io.8 | 27 +++++ 5 files changed, 334 insertions(+), 3 deletions(-) create mode 100644 io/encrypt.c
io/Makefile +3 -3
@@ -9,9 +9,9 @@ LTCOMMAND = xfs_io LSRCFILES = xfs_bmap.sh xfs_freeze.sh xfs_mkfile.sh HFILES = init.h io.h CFILES = init.c \ - attr.c bmap.c file.c freeze.c fsync.c getrusage.c imap.c link.c \ - mmap.c open.c parent.c pread.c prealloc.c pwrite.c seek.c shutdown.c \ - sync.c truncate.c reflink.c cowextsize.c + attr.c bmap.c encrypt.c file.c freeze.c fsync.c getrusage.c imap.c \ + link.c mmap.c open.c parent.c pread.c prealloc.c pwrite.c seek.c \ + shutdown.c sync.c truncate.c reflink.c cowextsize.c LLDLIBS = $(LIBXCMD) $(LIBHANDLE) $(LIBPTHREAD) LTDEPENDENCIES = $(LIBXCMD) $(LIBHANDLE)
io/encrypt.c new file +302 -0
302 lines not on this page · raw message
io/init.c +1 -0
@@ -59,6 +59,7 @@ init_commands(void)attr_init ();bmap_init ();copy_range_init (); +encrypt_init ();fadvise_init ();file_init ();flink_init ();
io/io.h +1 -0
@@ -94,6 +94,7 @@ extern void dump_buffer(off64_t, ssize_t);extern void attr_init (void );extern void bmap_init (void ); +extern void encrypt_init (void );extern void file_init (void );extern void flink_init (void );extern void freeze_init (void );
man/man8/xfs_io.8 +27 -0
@@ -886,6 +886,33 @@ verbose output will be printed. .IP .B [NOTE: Not currently operational on Linux.] .PD +.TP +.BI "set_encpolicy [ \-c " mode " ] [ \-n " mode " ] [ \-f " flags " ] [ \-v " version " ] [ " keydesc " ] +On filesystems that support encryption, assign an encryption policy to the +current file. +.I keydesc +is a 16-byte hex string which identifies the encryption key to use. +If not specified, a "default" key descriptor of all 0's will be used. +.RS 1.0i +.PD 0 +.TP 0.4i +.BI \-c " mode +contents encryption mode (e.g. AES-256-XTS) +.TP +.BI \-n " mode +filenames encryption mode (e.g. AES-256-CTS) +.TP +.BI \-f " flags +policy flags (numeric) +.TP +.BI \-v " version +version of policy structure (numeric) +.RE +.PD +.TP +.BR get_encpolicy +On filesystems that support encryption, display the encryption policy of the +current file. .SH SEE ALSO .BR mkfs.xfs (8),
Signature · 1 line
2.8.0.rc3.226.g39d4020
Quoted 8 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Add
set_encpolicyandget_encpolicycommands toxfs_ioso that xfstests will be able to test filesystem encryption using the actual user API, not just hacked in with a mount option. These commands use the common "fscrypt" API currently implemented by ext4 and f2fs, but it's also under development for ubifs and planned for xfs.
Quoted 6 lines
Note that to get encrypted files to actually work, it's also necessary to add a key to the kernel keyring. This patch does not add a command for this to
xfs_iobecause it's possible to do it using keyctl. keyctl can also be used to remove keys, revoke keys, invalidate keys, etc.Signed-off-by Eric Biggers <[email protected]>
Thanks for the update -