This commit is contained in:
Jan Schär 2022-03-31 10:24:28 +02:00
parent 9750a752c3
commit 042a4187ed
4 changed files with 9 additions and 9 deletions

View File

@ -63,7 +63,7 @@ struct spawninfo {
struct aos_rpc_server rpc_server;
};
struct spawninfo *sawn_get_process_list(void);
struct spawninfo *spawn_get_process_list(void);
// parse a commandline into arguments
void spawn_parse_cmd(char *cmdline, int *argc, char **argv);

View File

@ -189,7 +189,7 @@ aos_rpc_process_get_name(struct aos_rpc *rpc, domainid_t pid, char **name) {
*name = malloc(name_len);
if (*name == NULL) return LIB_ERR_MALLOC_FAIL;
memcpy(*name, rpc->shared_mem, name_len);
assert((*name)[name_len] == '\0');
assert(name_len != 0 && (*name)[name_len - 1] == '\0');
return err;
}

View File

@ -139,7 +139,7 @@ static errval_t handle_rpc_serial_getchar(
) {
grading_rpc_handler_serial_getchar();
// MARKER SHELL: Replace with UART call
*ret0 = getchar();
@ -211,7 +211,7 @@ static errval_t handle_rpc_process_get_name(
// search for the pid
char *name = NULL;
for (struct spawninfo *si = sawn_get_process_list(); si != NULL; si = si->next) {
for (struct spawninfo *si = spawn_get_process_list(); si != NULL; si = si->next) {
if (si->pid == pid) {
name = si->binary_name;
break;
@ -239,13 +239,13 @@ static errval_t handle_rpc_process_get_all_pids(
struct capref *ret_cap, size_t *ret_size, uintptr_t *ret0, uintptr_t *ret1
) {
grading_rpc_handler_process_get_all_pids();
// size in bytes
size_t list_size = 0;
domainid_t *buf = rpc->shared_mem;
// get all PIDs that fit into the given space
for (struct spawninfo *si = sawn_get_process_list(); si != NULL; si = si->next) {
for (struct spawninfo *si = spawn_get_process_list(); si != NULL; si = si->next) {
if (list_size + sizeof(domainid_t) > RPC_SHARED_SIZE) {
return AOS_ERR_RPC_RET_TOO_BIG;
}
@ -254,7 +254,7 @@ static errval_t handle_rpc_process_get_all_pids(
++buf;
list_size += sizeof(domainid_t);
}
*ret_size = list_size;
return SYS_ERR_OK;

View File

@ -20,7 +20,7 @@ struct spawninfo *spawn_process_list = NULL;
// TODO: handle "freeing" of PIDs in case we learn how to detect stopped child processes
domainid_t spawn_last_pid = 1;
struct spawninfo *sawn_get_process_list(void) {
struct spawninfo *spawn_get_process_list(void) {
return spawn_process_list;
}
@ -337,7 +337,7 @@ errval_t spawn_load_argv(int argc, char *argv[], struct spawninfo *si,
// - Initialize the spawn_info struct
// TODO
// copy name to spawninfo struct
size_t binary_name_len = strlen(argv[0]);
size_t binary_name_len = strlen(argv[0]) + 1;
si->binary_name = malloc(binary_name_len);
if (si->binary_name == NULL) {
return LIB_ERR_MALLOC_FAIL;