| // Copyright 2016 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. |
| library fuchsia.sys; |
| |
| using zx; |
| |
| /// An FDIO file descriptor. |
| // TODO(abarth): Use the real FDIO declaration once FDIO converts to FIDL2. |
| type FileDescriptor = resource struct { |
| /// The FDIO types of the handle (e.g., `FA_FDIO_REMOTE`). |
| type0 int32; |
| type1 int32; |
| type2 int32; |
| |
| /// The handles for the file descriptor (e.g., a channel). |
| handle0 zx.handle:optional; |
| handle1 zx.handle:optional; |
| handle2 zx.handle:optional; |
| }; |
| |
| /// Information used to create an instance of a component and obtain |
| /// services from it. |
| type LaunchInfo = resource struct { |
| /// The location from which to retrieve this component. |
| /// |
| /// This field will probably be replaced with a stronger notion of identity, |
| /// such as an unforgeable token. This field is included in this iteration to |
| /// ease the transition from the previous component interfaces. |
| url component_url; |
| |
| /// The arguments to be provided to the component. |
| arguments vector<string:MAX>:<MAX, optional>; |
| |
| /// The file descriptor to use for stdout. |
| /// |
| /// If null, the component will use the default stdout for the environment. |
| out box<FileDescriptor>; |
| |
| /// The file descriptor to use for stderr. |
| /// |
| /// If null, the component will use the default stderr for the environment. |
| err box<FileDescriptor>; |
| |
| /// The interface request for a Directory that points at the "svc/" subdirectory |
| /// of the component's outgoing directory channel. The channel CANNOT be used |
| /// to connect to other directories (such as "debug/" or "diagnostics/") the component |
| /// publishes in their outgoing directory. |
| directory_request zx.handle:<CHANNEL, optional>; |
| |
| /// A custom namespace that can be appended to the namespace generated by |
| /// appmgr and provided to this component. |
| /// Adding a mount point at standard paths like 'pkg' or 'svc' will be ignored. |
| /// HACK(alhaad): Adding mount points for deprecated default directories like |
| /// '/data' will override the default. |
| flat_namespace box<FlatNamespace>; |
| |
| /// A list of services to be added to this component's svc namespace. These |
| /// services are in addition to those coming from Environment. |
| additional_services box<ServiceList>; |
| }; |
| |
| type ServiceList = resource struct { |
| /// A list of services that can be requested from `provider`. |
| names vector<string>; |
| |
| /// A service provider to get the services listed in `names` from. |
| provider client_end:<ServiceProvider, optional>; |
| |
| /// A channel to the directory hosting the services in `names`. |
| // TODO(fxbug.dev/31262): Support `host_directory` for CreateComponent and deprecate |
| // `provider`. |
| host_directory zx.handle:<CHANNEL, optional>; |
| }; |
| |
| /// An interface for creating component instances. |
| /// |
| /// Typically obtained via `Environment.GetLauncher`. |
| @discoverable |
| protocol Launcher { |
| /// Creates a new instance of the component described by `launch_info`. |
| /// |
| /// The component instance is created in the `Environment` |
| /// associated with this `Launcher`. When creating the component, |
| /// the environment requests the environment services for this component from |
| /// its `EnvironmentHost`. |
| /// |
| /// The `controller` can be used to control the lifecycle of the created |
| /// component instance. If an `ComponentController`'s interface is |
| /// requested, the component instance is killed when the interface is closed. |
| CreateComponent(resource struct { |
| launch_info LaunchInfo; |
| controller server_end:<ComponentController, optional>; |
| }); |
| }; |