File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -19,8 +19,9 @@ name = "composefs"
19
19
version = " 1"
20
20
21
21
[features ]
22
- # Depend on 1.0.4 APIs
22
+ # Require functions from the C library corresponding to the provided version.
23
23
v1_0_4 = []
24
+ v1_0_7 = [" v1_0_4" ]
24
25
25
26
[build-dependencies ]
26
27
system-deps = " 6"
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ extern "C" {
11
11
pub fn lcfs_fd_get_fsverity ( digest : * mut u8 , fd : std:: os:: raw:: c_int ) -> std:: os:: raw:: c_int ;
12
12
#[ cfg( feature = "v1_0_4" ) ]
13
13
pub fn lcfs_fd_enable_fsverity ( fd : std:: os:: raw:: c_int ) -> std:: os:: raw:: c_int ;
14
+ #[ cfg( feature = "v1_0_7" ) ]
15
+ pub fn lcfs_fd_require_fsverity ( digest : * mut u8 , fd : std:: os:: raw:: c_int ) -> std:: os:: raw:: c_int ;
14
16
}
15
17
16
18
/// Convert an integer return value into a `Result`.
@@ -41,6 +43,19 @@ mod tests {
41
43
Ok ( ( ) )
42
44
}
43
45
46
+ #[ test]
47
+ #[ cfg( feature = "v1_0_7" ) ]
48
+ fn test_fd_require_fsverity ( ) -> Result < ( ) > {
49
+ let mut tf = tempfile:: NamedTempFile :: new ( ) ?;
50
+ tf. write_all ( b"hello" ) ?;
51
+ let tf = std:: fs:: File :: open ( tf. path ( ) ) ?;
52
+ // This fd can't have fsverity enabled
53
+ let mut buf = [ 0u8 ; LCFS_SHA256_DIGEST_LEN ] ;
54
+ let r = unsafe { lcfs_fd_require_fsverity ( buf. as_mut_ptr ( ) , tf. as_raw_fd ( ) ) } ;
55
+ assert_ne ! ( r, 0 ) ;
56
+ Ok ( ( ) )
57
+ }
58
+
44
59
#[ test]
45
60
fn test_digest ( ) -> Result < ( ) > {
46
61
for f in [ lcfs_compute_fsverity_from_fd, lcfs_fd_get_fsverity] {
You can’t perform that action at this time.
0 commit comments