(
context_ptr: *mut Context,
syscall_id: u64,
path_ptr: *const u8,
path_len: u64)
| 796 | } |
| 797 | |
| 798 | fn sys_mount( |
| 799 | context_ptr: *mut Context, |
| 800 | syscall_id: u64, |
| 801 | path_ptr: *const u8, |
| 802 | path_len: u64) { |
| 803 | |
| 804 | let context = unsafe {&mut (*context_ptr)}; |
| 805 | |
| 806 | // High 32 bits of RAX contain the handle |
| 807 | let handle = syscall_id >> 32; |
| 808 | |
| 809 | // Convert raw pointer to a slice |
| 810 | let u8_slice = unsafe {slice::from_raw_parts(path_ptr, path_len as usize)}; |
| 811 | let path_string = match str::from_utf8(u8_slice) { |
| 812 | Ok(s) => s, |
| 813 | Err(_) => { |
| 814 | // Bad utf8 conversion |
| 815 | context.rax = SYSCALL_ERROR_UTF8; |
| 816 | return; |
| 817 | } |
| 818 | }; |
| 819 | if let Some(mut thread) = process::take_current_thread() { |
| 820 | thread.set_context(context_ptr); |
| 821 | let rdv = match thread.take_rendezvous(handle) { |
| 822 | Some(rdv) => rdv, |
| 823 | None => { |
| 824 | // Invalid handle |
| 825 | thread.return_error(SYSCALL_ERROR_INVALID_HANDLE); |
| 826 | process::set_current_thread(thread); |
| 827 | return; |
| 828 | } |
| 829 | }; |
| 830 | |
| 831 | let mut vfs = thread.vfs(); // An Arc clone of the VFS |
| 832 | vfs.mount(path_string, rdv); |
| 833 | context.rax = 0; // No error (vfs.mount never fails. Probably should) |
| 834 | process::set_current_thread(thread); |
| 835 | } |
| 836 | } |
| 837 | |
| 838 | /// Get a list of mounted paths in a memory handle |
| 839 | fn sys_listmounts(context_ptr: *mut Context) { |
no test coverage detected