Remove a mount point. Most of this code is the same as `sys_mount`
(
context_ptr: *mut Context,
path_ptr: *const u8,
path_len: u64)
| 880 | /// Remove a mount point. |
| 881 | /// Most of this code is the same as `sys_mount` |
| 882 | fn sys_umount( |
| 883 | context_ptr: *mut Context, |
| 884 | path_ptr: *const u8, |
| 885 | path_len: u64) { |
| 886 | |
| 887 | let context = unsafe {&mut (*context_ptr)}; |
| 888 | |
| 889 | // Convert raw pointer to a slice |
| 890 | let u8_slice = unsafe {slice::from_raw_parts(path_ptr, path_len as usize)}; |
| 891 | let path_string = match str::from_utf8(u8_slice) { |
| 892 | Ok(s) => s, |
| 893 | Err(_) => { |
| 894 | // Bad utf8 conversion |
| 895 | context.rax = SYSCALL_ERROR_UTF8; |
| 896 | return; |
| 897 | } |
| 898 | }; |
| 899 | if let Some(mut thread) = process::take_current_thread() { |
| 900 | thread.set_context(context_ptr); |
| 901 | |
| 902 | let mut vfs = thread.vfs(); // An Arc clone of the VFS |
| 903 | if vfs.umount(path_string).is_err() { |
| 904 | context.rax = SYSCALL_ERROR_NOTFOUND; |
| 905 | } else { |
| 906 | context.rax = 0; // No error |
| 907 | } |
| 908 | process::set_current_thread(thread); |
| 909 | } |
| 910 | } |
| 911 | |
| 912 | fn sys_close(context_ptr: *mut Context, handle: u64) { |
| 913 | // Extract the current thread |
no test coverage detected