[musl][dl] provide dl_clone_loader_service()

If there is an active loader service and it supports obtaining
a new connection, this function will return a new connection.

Change-Id: I58fe4d2450dc656340ed352424ef095ad19227fe
Esse commit está contido em:
Brian Swetland
2017-09-11 14:19:36 -07:00
commit de CQ bot account: commit-bot@chromium.org
commit 685a2f5e3b
2 arquivos alterados com 23 adições e 0 exclusões
+6
Ver Arquivo
@@ -15,6 +15,12 @@ void* dlopen_vmo(mx_handle_t, int);
// in the return value.
mx_handle_t dl_set_loader_service(mx_handle_t new_svc);
// Ask the active "loader service" (if there is one), to return
// a new connection. Not all loader services need support this.
// On success, a channel handle to the new connection is returned
// via out.
mx_status_t dl_clone_loader_service(mx_handle_t* out);
#ifdef __cplusplus
}
#endif
+17
Ver Arquivo
@@ -2252,6 +2252,23 @@ __NO_SAFESTACK static mx_status_t get_library_vmo(const char* name,
MX_HANDLE_INVALID, result);
}
__NO_SAFESTACK mx_status_t dl_clone_loader_sevice(mx_handle_t* out) {
if (loader_svc == MX_HANDLE_INVALID) {
return MX_ERR_UNAVAILABLE;
}
mx_handle_t h0, h1;
mx_status_t status;
if ((status = _mx_channel_create(0, &h0, &h1)) != MX_OK) {
return status;
}
if ((status = loader_svc_rpc(LOADER_SVC_OP_CLONE, NULL, 0, h1, NULL)) != MX_OK) {
_mx_handle_close(h0);
} else {
*out = h0;
}
return status;
}
__NO_SAFESTACK static void log_write(const void* buf, size_t len) {
// The loader service prints "header: %s\n" when we send %s,
// so strip a trailing newline.