11// SPDX-License-Identifier: Apache-2.0
22// Copyright 2021 Keylime Authors
3-
4- use super :: * ;
5-
6- use keylime :: error :: { Error , Result } ;
7- use std :: fs ;
8- use std :: io :: BufRead ;
9- use std :: os :: unix :: fs :: PermissionsExt ;
10- use std :: path :: PathBuf ;
11- use std :: process :: Command ;
3+ use crate :: error :: { Error , Result } ;
4+ use log :: * ;
5+ use std :: {
6+ fs ,
7+ io :: { BufRead , BufReader } ,
8+ os :: unix :: fs :: PermissionsExt ,
9+ path :: { Path , PathBuf } ,
10+ process :: Command ,
11+ } ;
1212
1313pub static MOUNTINFO : & str = "/proc/self/mountinfo" ;
1414
@@ -27,7 +27,7 @@ pub static MOUNTINFO: &str = "/proc/self/mountinfo";
2727 * - false if not mounted
2828 *
2929 */
30- fn check_mount ( secure_dir : & Path ) -> Result < bool > {
30+ pub fn check_mount ( secure_dir : & Path ) -> Result < bool > {
3131 let f = fs:: File :: open ( MOUNTINFO ) ?;
3232 let f = BufReader :: new ( f) ;
3333 let lines = f. lines ( ) ;
@@ -39,7 +39,7 @@ fn check_mount(secure_dir: &Path) -> Result<bool> {
3939 // Skip all fields up to the separator
4040 let mut iter = iter. skip_while ( |& x| x != "-" ) ;
4141
42- if let Some ( separator ) = iter. next ( ) {
42+ if let Some ( _separator ) = iter. next ( ) {
4343 // The file system type is the first element after the separator
4444 if let Some ( fs_type) = iter. next ( ) {
4545 if fs_type == "tmpfs" {
@@ -80,7 +80,7 @@ fn check_mount(secure_dir: &Path) -> Result<bool> {
8080 * implementation as the original python version, but the chown/geteuid
8181 * functions are unsafe function in Rust to use.
8282 */
83- pub ( crate ) fn mount ( work_dir : & Path , secure_size : & str ) -> Result < PathBuf > {
83+ pub fn mount ( work_dir : & Path , secure_size : & str ) -> Result < PathBuf > {
8484 // Mount the directory to file system
8585 let secure_dir_path = Path :: new ( work_dir) . join ( "secure" ) ;
8686
@@ -140,6 +140,7 @@ pub(crate) fn mount(work_dir: &Path, secure_size: &str) -> Result<PathBuf> {
140140
141141 Ok ( secure_dir_path)
142142}
143+
143144#[ cfg( test) ]
144145mod tests {
145146 use super :: * ;
@@ -148,7 +149,7 @@ mod tests {
148149 fn test_secure_mount ( ) {
149150 let temp_workdir = tempfile:: tempdir ( ) . unwrap ( ) ; //#[allow_ci]
150151 let secure_size = "1m" ;
151- let test_mount = mount ( temp_workdir. path ( ) , secure_size) ;
152+ let _test_mount = mount ( temp_workdir. path ( ) , secure_size) ;
152153 assert ! ( check_mount( temp_workdir. path( ) ) . is_ok( ) ) ;
153154 }
154155}
0 commit comments