xref: /DragonOS/user/apps/test-mount/src/main.rs (revision 4256da7fb6ad25a3caab6f656607aaf047cb6446)
1 use core::ffi::{c_char, c_void};
2 use libc::{mount, MS_BIND};
3 use std::time;
4 fn main() {
5     let clock = time::Instant::now();
6     let source = b"\0".as_ptr() as *const c_char;
7     let target = b"/mnt/tmp\0".as_ptr() as *const c_char;
8     let fstype = b"ramfs\0".as_ptr() as *const c_char;
9     let flags = MS_BIND;
10     let data = std::ptr::null() as *const c_void;
11     let result = unsafe { mount(source, target, fstype, flags, data) };
12 
13     if result == 0 {
14         println!("Mount successful");
15     } else {
16         println!("Mount failed");
17     }
18     let dur = clock.elapsed();
19     println!("mount costing time: {} ns", dur.as_nanos());
20 }
21