MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / sys_listmounts

Function sys_listmounts

kernel/src/syscalls.rs:839–878  ·  view source on GitHub ↗

Get a list of mounted paths in a memory handle

(context_ptr: *mut Context)

Source from the content-addressed store, hash-verified

837
838/// Get a list of mounted paths in a memory handle
839fn sys_listmounts(context_ptr: *mut Context) {
840 if let Some(mut thread) = process::take_current_thread() {
841 thread.set_context(context_ptr);
842 let context = unsafe {&mut (*context_ptr)};
843
844 // Get a JSON string containing VFS mounts
845 let json = thread.vfs().to_json();
846
847 // No longer need thread, needed
848 // by process::new_memory_chunk
849 process::set_current_thread(thread);
850
851 // Allocate memory chunk to hold the data
852 let num_bytes = json.len() as u64;
853 let num_pages = (num_bytes >> 12) +
854 if (num_bytes & 4095) != 0 {1} else {0};
855
856 match process::new_memory_chunk(
857 num_pages,
858 0xFFFF_FFFF_FFFF_FFFF) {
859 Ok((virtaddr, _physaddr)) => {
860 // Copy string into memory chunk
861 unsafe {
862 ptr::copy_nonoverlapping(json.as_ptr(),
863 virtaddr.as_u64() as *mut u8,
864 json.len());
865 }
866
867 context.rax = 0; // No error
868 context.rdi = virtaddr.as_u64() as usize;
869 context.rsi = json.len();
870 }
871 Err(code) => {
872 context.rax = code;
873 context.rdi = 0;
874 context.rsi = 0;
875 }
876 }
877 }
878}
879
880/// Remove a mount point.
881/// Most of this code is the same as `sys_mount`

Callers 1

dispatch_syscallFunction · 0.85

Calls 9

take_current_threadFunction · 0.85
set_current_threadFunction · 0.85
new_memory_chunkFunction · 0.85
set_contextMethod · 0.80
to_jsonMethod · 0.80
vfsMethod · 0.80
as_ptrMethod · 0.80
lenMethod · 0.45
as_u64Method · 0.45

Tested by

no test coverage detected