Skip to main content

CfsctlService

Struct CfsctlService 

Source
pub(crate) struct CfsctlService {
    repos: HashMap<u64, HandleEntry>,
    next_handle: u64,
    open_opts: OpenOptions,
}
Expand description

Varlink service implementation backing the org.composefs.Repository (and, with the oci feature, org.composefs.Oci) interfaces.

Holds a table of opened repositories keyed by opaque handle. The zlink server serializes calls to a single service, so the table is a plain HashMap with no interior locking.

Fields§

§repos: HashMap<u64, HandleEntry>

Open repositories keyed by opaque handle.

§next_handle: u64

Monotonically increasing handle counter; 0 is reserved as “none”.

§open_opts: OpenOptions

Repository open options fixed at startup.

Implementations§

Source§

impl CfsctlService

Source

async fn init_repository( &mut self, path: String, algorithm: Option<String>, insecure: Option<bool>, ) -> Result<InitRepositoryReply, RepositoryError>

Initialize a new repository at the given path, or verify that an existing one matches the requested algorithm (idempotent).

Creates the directory (and any parents) if they do not exist. algorithm must be a valid fs-verity algorithm string such as "fsverity-sha512-12" (the default) or "fsverity-sha256-12". When omitted the service default (fsverity-sha512-12) is used. The insecure flag mirrors cfsctl init --insecure: when true, fs-verity is not required on meta.json.

Source

async fn close_repository(&mut self, handle: u64) -> Result<(), RepositoryError>

Close a previously opened repository handle.

Source

async fn fsck( &self, handle: u64, metadata_only: Option<bool>, ) -> Result<FsckReply, RepositoryError>

Check repository integrity and return the structured result.

When metadata_only is true, the expensive per-object fs-verity verification is skipped; only metadata and symlink structure are checked.

Source

async fn gc( &self, handle: u64, dry_run: bool, roots: Vec<String>, ) -> Result<GcReply, RepositoryError>

Run garbage collection (or a dry run) and return what was removed.

Source

async fn image_objects( &self, handle: u64, name: String, ) -> Result<ImageObjectsReply, RepositoryError>

List the objects referenced by a single image.

Source

async fn mount( &self, handle: u64, name: String, options: MountParams, fds: Vec<OwnedFd>, ) -> (Result<MountReply, RepositoryError>, Vec<OwnedFd>)

Create a detached mount of an image and return the mount fd.

If overlay upper/work directories are needed, pass them as two fds (upperdir, workdir) via SCM_RIGHTS. The returned fd is a detached mount that the caller can attach with move_mount().

Source

async fn list_images( &self, handle: u64, filter: Option<String>, ) -> Result<ListImagesReply, OciError>

List tagged OCI images in the repository.

When filter is given, only images whose name contains that substring are returned.

Source

async fn oci_fsck( &self, handle: u64, image: Option<String>, ) -> Result<OciFsckReply, OciError>

Run an OCI-aware consistency check on the repository.

Renamed on the wire to Check so it does not collide with the repository-level Fsck method (the dispatch enum keys on the wire method name, which must be globally unique across both interfaces).

Source

async fn inspect( &self, handle: u64, image: String, ) -> Result<OciInspectReply, OciError>

Inspect a single OCI image.

Source

async fn tag( &self, handle: u64, manifest_digest: String, name: String, ) -> Result<(), OciError>

Tag a manifest digest with a name.

Source

async fn untag(&self, handle: u64, name: String) -> Result<(), OciError>

Remove a tag.

Source

async fn compute_id( &self, handle: u64, image: String, verity: Option<String>, bootable: bool, ) -> Result<OciComputeIdReply, OciError>

Compute the composefs image ID for an OCI image.

Source

async fn pull( &self, more: bool, handle: u64, image: String, name: Option<String>, local_fetch: String, storage_root: Option<String>, bootable: bool, ) -> impl Stream<Item = Result<Reply<PullProgress>, OciError>> + Send + 'static

Pull an OCI image into the repository, streaming progress.

Emits zero or more intermediate PullProgress frames describing fetch progress (only when more is true), followed by exactly one terminal frame whose completed field is set, carrying the pull result.

Source

async fn oci_mount( &self, handle: u64, image: String, bootable: bool, options: MountParams, fds: Vec<OwnedFd>, ) -> (Result<MountReply, OciError>, Vec<OwnedFd>)

Mount an OCI image and return the detached mount fd.

Resolves the image by ref name or sha256: digest, finds its EROFS image (or boot variant if bootable is true), and creates a composefs mount. If options.overlay is true, the fd array must contain upperdir and workdir fds.

Source§

impl CfsctlService

Source

fn with_open_opts(open_opts: OpenOptions) -> Self

Construct an empty service with the given repository open options.

No repository is opened at startup: a client must explicitly select one with OpenRepository and pass the returned handle to every subsequent call.

Source

pub(crate) fn from_app(args: &App) -> Self

Construct a service from parsed CLI arguments.

The open flags (--insecure/--require-verity/--no-upgrade) carry into repositories opened later via OpenRepository; the repository selection flags (--repo/--user/--system) do not apply, since the varlink service opens repositories on demand rather than at startup.

Source

pub(crate) fn activated() -> Self

Construct a service for the socket-activated entry point, which serves before CLI parsing and so has no App to consult. Uses default open options; the client supplies repository paths via OpenRepository.

Source

fn next_handle(&mut self) -> u64

Allocate a fresh, never-reused handle. Starts at 1 (0 is “none”).

Source

fn lookup_repo(&self, handle: u64) -> Result<OpenRepo, RepositoryError>

Look up an open repository by handle for the Repository interface.

Returns an owned OpenRepo (a cheap Arc clone) so callers do not hold a borrow of self across the subsequent .await.

Source

fn lookup_oci(&self, handle: u64) -> Result<OpenRepo, OciError>

Look up an open repository by handle for the OCI interface.

Like Self::lookup_repo but reports the OCI-interface error so the wire error name is org.composefs.Oci.InvalidHandle.

Source

fn do_open( &mut self, path: &Path, owner: Option<usize>, ) -> Result<u64, RepositoryError>

Resolve, open and register a repository at path, returning its handle.

The digest algorithm is detected from the repository metadata; both resolution and open failures are reported as RepositoryError::RepoNotFound.

Source

fn resolve_selector( path: Option<String>, user: Option<bool>, system: Option<bool>, ) -> Result<PathBuf, RepositoryError>

Resolve a repository selector (path/user/system) to a path.

Exactly one of the three must be set; otherwise RepositoryError::InvalidSpec is returned.

Trait Implementations§

Source§

impl Debug for CfsctlService

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Sock> Service<Sock> for CfsctlService
where Sock: Socket,

Source§

type MethodCall<'de> = __CfsctlServiceMethodCall<'de>

The type of method call that this service handles. Read more
Source§

type ReplyParams<'ser> = __CfsctlServiceReplyParams<'ser> where Self: 'ser

The type of the successful reply. Read more
Source§

type ReplyStream = Box<dyn Stream<Item = (Result<Reply<__CfsctlServiceReplyStreamParams>, __CfsctlServiceReplyStreamError>, Vec<OwnedFd>)> + Unpin>

The type of the multi-reply stream. Read more
Source§

type ReplyStreamParams = __CfsctlServiceReplyStreamParams

The type of the item that [Service::ReplyStream] will be expected to yield. Read more
Source§

type ReplyStreamError = __CfsctlServiceReplyStreamError

The type of an error reply produced by a streaming method. Read more
Source§

type ReplyError<'ser> = __CfsctlServiceReplyError<'ser> where Self: 'ser

The type of the error reply. Read more
Source§

async fn handle<'__zlink_ser>( &'__zlink_ser mut self, __zlink_call: &'__zlink_ser Call<Self::MethodCall<'_>>, __zlink_conn: &mut Connection<Sock>, __zlink_fds: Vec<OwnedFd>, ) -> HandleResult<Self::ReplyParams<'__zlink_ser>, Self::ReplyStream, Self::ReplyError<'__zlink_ser>>

Handle a method call.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> MaybeSend for T
where T: Send,