Skip to content

Commit

Permalink
Merge pull request #1150 from trungnt2910/darlingserver
Browse files Browse the repository at this point in the history
feat: Manage executable path in darlingserver
  • Loading branch information
facekapow authored Apr 5, 2022
2 parents 0fe24ac + 268a948 commit 7da8f61
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
21 changes: 11 additions & 10 deletions src/kernel/emulation/linux/misc/proc_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,20 +645,21 @@ static bool parse_smaps_firstline(

static long _proc_pidinfo_pathinfo(int32_t pid, void* buffer, int32_t bufsize)
{
char path[64];
struct vchroot_unexpand_args args;
uint64_t fullLength;

__simple_sprintf(path, "/proc/%d/exe", pid);

memset(buffer, 0, bufsize);
int rv = sys_readlink(path, buffer, bufsize - 1);

if (rv < 0)
return rv;
int rv = dserver_rpc_get_executable_path(pid, args.path, sizeof(args.path), &fullLength);

((char*)buffer)[rv] = 0;
if (rv < 0)
{
__simple_printf("dserver_rpc_get_executable_path failed internally: %d\n", rv);
__simple_abort();
}
else if (rv > 0)
{
return -rv;
}

strcpy(args.path, buffer);
rv = vchroot_unexpand(&args);
if (rv != 0)
return rv;
Expand Down
5 changes: 5 additions & 0 deletions src/startup/mldr/mldr.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ int main(int argc, char** argv, char** envp)
exit(1);
}

if (dserver_rpc_set_executable_path(filename, strlen(filename)) < 0) {
fprintf(stderr, "Failed to tell darlingserver about our executable path\n");
exit(1);
}

start_thread(&mldr_load_results);

__builtin_unreachable();
Expand Down

0 comments on commit 7da8f61

Please sign in to comment.