# HG changeset patch # User Paul Boddie # Date 1678407710 -3600 # Node ID 2bab05fdeee5c723a5feac6dbfe2ca4d42835569 # Parent 2c665b78888284d49897536bb62676e04fa43460 Provide the filesystem capability to the new process. diff -r 2c665b788882 -r 2bab05fdeee5 libexec/lib/src/process_creating.cc --- a/libexec/lib/src/process_creating.cc Fri Mar 10 01:20:57 2023 +0100 +++ b/libexec/lib/src/process_creating.cc Fri Mar 10 01:21:50 2023 +0100 @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -189,7 +190,7 @@ struct exec_region rm_regions[_program_payload->segments() + 2]; /* Define capabilities for mapping, including region dataspace capabilities, - the stack dataspace capability, and the server capability. */ + the stack dataspace capability, plus the pager capability. */ struct ipc_mapped_cap rm_mapped_caps[_program_payload->segments() + 3]; @@ -223,7 +224,10 @@ /* Map these additional capabilities. */ - _process.map_capabilities(rm_mapped_caps, false); + long err = _process.map_capabilities(rm_mapped_caps, false); + + if (err) + return err; /* Define the IPC gate as an initial capability to be acquired by the region mapper via the l4re_env API. The capability index is assigned above when @@ -242,7 +246,7 @@ exception handler plus region mapper). */ l4_cap_idx_t mapped_pager = L4_INVALID_CAP; - long err = _process.configure_thread(pager, &mapped_pager); + err = _process.configure_thread(pager, &mapped_pager); if (err) return err; @@ -289,12 +293,41 @@ if (err) return err; + /* Obtain the filesystem capability for exporting to the task. */ + + l4_cap_idx_t fsserver_cap = _process.allocate_cap(); + l4_cap_idx_t fsserver = l4re_env_get_cap(ENV_FILESYSTEM_SERVER_NAME); + + /* Define the capabilities to be mapped for the filesystem. */ + + struct ipc_mapped_cap program_mapped_caps[] = { + {fsserver_cap, fsserver, L4_CAP_FPAGE_RWS, L4_FPAGE_C_OBJ_RIGHTS}, + {0, L4_INVALID_CAP, 0, 0}, + }; + + /* Map these additional capabilities. */ + + err = _process.map_capabilities(program_mapped_caps, false); + + if (err) + return err; + + /* Define initial capabilities to be acquired by the region mapper via the + l4re_env API. Each capability index is assigned above when mapping the + capability and encoded in the entry below. */ + + l4re_env_cap_entry_t program_init_caps[] = { + l4re_env_cap_entry_t(ENV_FILESYSTEM_SERVER_NAME, fsserver_cap, L4_CAP_FPAGE_RWS), + l4re_env_cap_entry_t() + }; + /* Populate a thread stack with argument and environment details for the actual program. The server capability should be assigned to the region mapper capability slot already. */ Stack program_st(*_program_stack); + program_st.set_init_caps(program_init_caps); program_st.populate(argc, argv, envp); /* Start the program thread in the appropriate stack. */