Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Manage executable path in darlingserver #1150

Merged
merged 3 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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