blob: 196b8b99afbe0043c600e64ec6e2ee3569c32120 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#pragma once
#include <fbl/unique_fd.h>
#include <fbl/unique_ptr.h>
#include <lib/fdio/namespace.h>
#include <lib/zx/channel.h>
#include <loader-service/loader-service.h>
namespace devmgr {
// A loader service for devhosts that restricts access to dynamic libraries.
class DevhostLoaderService {
public:
// Create a new loader service for devhosts. The |dispatcher| must have a
// longer lifetime than |out|.
static zx_status_t Create(async_dispatcher_t* dispatcher,
fbl::unique_ptr<DevhostLoaderService>* out);
~DevhostLoaderService();
// Connect to the loader service.
zx_status_t Connect(zx::channel* out);
// Return the file descriptor for the root namespace of the loader service.
const fbl::unique_fd& root() const { return root_; }
private:
fbl::unique_fd root_;
loader_service_t* svc_ = nullptr;
};
} // namespace devmgr