1+ use core:: mem:: size_of;
2+
13use std:: { io:: Error , os:: fd:: AsFd } ;
24
3- use rustix:: io:: Errno ;
4- use rustix:: ioctl;
5+ use rustix:: {
6+ io:: Errno ,
7+ ioctl:: { ioctl, opcode, Opcode , Setter , Updater } ,
8+ } ;
59
610pub use super :: { EnableVerityError , FsVerityHashValue , MeasureVerityError } ;
711
@@ -21,7 +25,7 @@ struct FsVerityEnableArg {
2125}
2226
2327// #define FS_IOC_ENABLE_VERITY _IOW('f', 133, struct fsverity_enable_arg)
24- const FS_IOC_ENABLE_VERITY : u32 = ioctl :: opcode:: write :: < FsVerityEnableArg > ( b'f' , 133 ) ;
28+ const FS_IOC_ENABLE_VERITY : Opcode = opcode:: write :: < FsVerityEnableArg > ( b'f' , 133 ) ;
2529
2630/// Enable fsverity on the target file. This is a thin safe wrapper for the underlying base `ioctl`
2731/// and hence all constraints apply such as requiring the file descriptor to already be `O_RDONLY`
@@ -30,9 +34,9 @@ pub(super) fn fs_ioc_enable_verity<H: FsVerityHashValue>(
3034 fd : impl AsFd ,
3135) -> Result < ( ) , EnableVerityError > {
3236 unsafe {
33- match ioctl:: ioctl (
37+ match ioctl (
3438 fd,
35- ioctl :: Setter :: < { FS_IOC_ENABLE_VERITY } , FsVerityEnableArg > :: new ( FsVerityEnableArg {
39+ Setter :: < { FS_IOC_ENABLE_VERITY } , FsVerityEnableArg > :: new ( FsVerityEnableArg {
3640 version : 1 ,
3741 hash_algorithm : H :: ALGORITHM as u32 ,
3842 block_size : 4096 ,
@@ -64,13 +68,13 @@ struct FsVerityDigest<F> {
6468}
6569
6670// #define FS_IOC_MEASURE_VERITY _IORW('f', 134, struct fsverity_digest)
67- const FS_IOC_MEASURE_VERITY : u32 = ioctl :: opcode:: read_write :: < FsVerityDigest < ( ) > > ( b'f' , 134 ) ;
71+ const FS_IOC_MEASURE_VERITY : Opcode = opcode:: read_write :: < FsVerityDigest < ( ) > > ( b'f' , 134 ) ;
6872
6973/// Measure the fsverity digest of the provided file descriptor.
7074pub ( super ) fn fs_ioc_measure_verity < H : FsVerityHashValue > (
7175 fd : impl AsFd ,
7276) -> Result < H , MeasureVerityError > {
73- let digest_size = std :: mem :: size_of :: < H > ( ) as u16 ;
77+ let digest_size = size_of :: < H > ( ) as u16 ;
7478 let digest_algorithm = H :: ALGORITHM as u16 ;
7579
7680 let mut digest = FsVerityDigest :: < H > {
@@ -80,9 +84,9 @@ pub(super) fn fs_ioc_measure_verity<H: FsVerityHashValue>(
8084 } ;
8185
8286 let r = unsafe {
83- ioctl:: ioctl (
87+ ioctl (
8488 fd,
85- ioctl :: Updater :: < { FS_IOC_MEASURE_VERITY } , FsVerityDigest < H > > :: new ( & mut digest) ,
89+ Updater :: < { FS_IOC_MEASURE_VERITY } , FsVerityDigest < H > > :: new ( & mut digest) ,
8690 )
8791 } ;
8892 match r {
0 commit comments