| // Copyright 2021 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.device.fs; |
| |
| using fuchsia.io; |
| |
| using zx; |
| |
| /// A protocol that lets a client connect to another protocol. |
| protocol Connector { |
| /// Connect to the underlying protocol. |
| Connect(resource struct { |
| server zx.handle:CHANNEL; |
| }); |
| }; |
| |
| type ExportOptions = strict bits : uint32 { |
| /// If present, the exported service will be invisible. |
| INVISIBLE = 0x00000001; |
| }; |
| |
| /// Protocol through which a driver can export services to devfs. |
| @discoverable |
| protocol Exporter { |
| /// Export `service_path` from `service_dir` to `devfs_path`. If `protocol_id` |
| /// matches a known protocol, `service_path` will also be accessible through |
| /// a class path. |
| Export(resource struct { |
| service_dir client_end:fuchsia.io.Directory; |
| service_path string:fuchsia.io.MAX_PATH; |
| devfs_path string:fuchsia.io.MAX_PATH; |
| protocol_id uint32; |
| }) -> () error zx.status; |
| |
| /// Export `service_path` from `service_dir` to `devfs_path`. If `protocol_id` |
| /// matches a known protocol, `service_path` will also be accessible through |
| /// a class path. |
| ExportOptions(resource struct { |
| service_dir client_end:fuchsia.io.Directory; |
| service_path string:fuchsia.io.MAX_PATH; |
| devfs_path string:fuchsia.io.MAX_PATH; |
| protocol_id uint32; |
| options ExportOptions; |
| }) -> () error zx.status; |
| |
| /// Export a device in devfs. |
| /// |
| /// * error `ZX_ERR_ALREADY_EXISTS` if `topological_path` already exists. |
| /// * error `ZX_ERR_NOT_FOUND` if `class_name` doesn't match a valid class name. |
| ExportV2(resource struct { |
| /// This is the connector that will have Connect called on it when a client opens the |
| /// device. If the server end of this connection is dropped the export will automatically be |
| /// cleaned up. |
| open_client client_end:Connector; |
| |
| /// If this is present, then the device will be exported at this topological path. |
| topological_path string:<fuchsia.io.MAX_PATH, optional>; |
| |
| /// If this is present, then the device will be exported into "/dev/class/{class_name}/". |
| class_name string:<fuchsia.io.MAX_NAME_LENGTH, optional>; |
| |
| /// The options for the device being exported. |
| options ExportOptions; |
| }) -> () error zx.status; |
| |
| /// Make a `devfs_path` visible. Will return ZX_ERR_NOT_FOUND if the path |
| /// does not exist or ZX_ERR_BAD_STATE if the path is not invisible. |
| MakeVisible(struct { |
| devfs_path string:fuchsia.io.MAX_PATH; |
| }) -> () error zx.status; |
| }; |