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: u64Monotonically increasing handle counter; 0 is reserved as “none”.
open_opts: OpenOptionsRepository open options fixed at startup.
Implementations§
Source§impl CfsctlService
impl CfsctlService
Sourceasync fn init_repository(
&mut self,
path: String,
algorithm: Option<String>,
insecure: Option<bool>,
) -> Result<InitRepositoryReply, RepositoryError>
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.
Sourceasync fn close_repository(&mut self, handle: u64) -> Result<(), RepositoryError>
async fn close_repository(&mut self, handle: u64) -> Result<(), RepositoryError>
Close a previously opened repository handle.
Sourceasync fn fsck(
&self,
handle: u64,
metadata_only: Option<bool>,
) -> Result<FsckReply, RepositoryError>
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.
Sourceasync fn gc(
&self,
handle: u64,
dry_run: bool,
roots: Vec<String>,
) -> Result<GcReply, RepositoryError>
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.
Sourceasync fn image_objects(
&self,
handle: u64,
name: String,
) -> Result<ImageObjectsReply, RepositoryError>
async fn image_objects( &self, handle: u64, name: String, ) -> Result<ImageObjectsReply, RepositoryError>
List the objects referenced by a single image.
Sourceasync fn mount(
&self,
handle: u64,
name: String,
options: MountParams,
fds: Vec<OwnedFd>,
) -> (Result<MountReply, RepositoryError>, Vec<OwnedFd>)
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().
Sourceasync fn list_images(
&self,
handle: u64,
filter: Option<String>,
) -> Result<ListImagesReply, OciError>
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.
Sourceasync fn oci_fsck(
&self,
handle: u64,
image: Option<String>,
) -> Result<OciFsckReply, OciError>
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).
Sourceasync fn inspect(
&self,
handle: u64,
image: String,
) -> Result<OciInspectReply, OciError>
async fn inspect( &self, handle: u64, image: String, ) -> Result<OciInspectReply, OciError>
Inspect a single OCI image.
Sourceasync fn tag(
&self,
handle: u64,
manifest_digest: String,
name: String,
) -> Result<(), OciError>
async fn tag( &self, handle: u64, manifest_digest: String, name: String, ) -> Result<(), OciError>
Tag a manifest digest with a name.
Sourceasync fn compute_id(
&self,
handle: u64,
image: String,
verity: Option<String>,
bootable: bool,
) -> Result<OciComputeIdReply, OciError>
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.
Sourceasync 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
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.
Sourceasync fn oci_mount(
&self,
handle: u64,
image: String,
bootable: bool,
options: MountParams,
fds: Vec<OwnedFd>,
) -> (Result<MountReply, OciError>, Vec<OwnedFd>)
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
impl CfsctlService
Sourcefn with_open_opts(open_opts: OpenOptions) -> Self
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.
Sourcepub(crate) fn from_app(args: &App) -> Self
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.
Sourcepub(crate) fn activated() -> Self
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.
Sourcefn next_handle(&mut self) -> u64
fn next_handle(&mut self) -> u64
Allocate a fresh, never-reused handle. Starts at 1 (0 is “none”).
Sourcefn lookup_repo(&self, handle: u64) -> Result<OpenRepo, RepositoryError>
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.
Sourcefn lookup_oci(&self, handle: u64) -> Result<OpenRepo, OciError>
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.
Sourcefn do_open(
&mut self,
path: &Path,
owner: Option<usize>,
) -> Result<u64, RepositoryError>
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.
Sourcefn resolve_selector(
path: Option<String>,
user: Option<bool>,
system: Option<bool>,
) -> Result<PathBuf, RepositoryError>
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
impl Debug for CfsctlService
Source§impl<Sock> Service<Sock> for CfsctlServicewhere
Sock: Socket,
impl<Sock> Service<Sock> for CfsctlServicewhere
Sock: Socket,
Source§type MethodCall<'de> = __CfsctlServiceMethodCall<'de>
type MethodCall<'de> = __CfsctlServiceMethodCall<'de>
Source§type ReplyParams<'ser> = __CfsctlServiceReplyParams<'ser>
where
Self: 'ser
type ReplyParams<'ser> = __CfsctlServiceReplyParams<'ser> where Self: 'ser
Source§type ReplyStream = Box<dyn Stream<Item = (Result<Reply<__CfsctlServiceReplyStreamParams>, __CfsctlServiceReplyStreamError>, Vec<OwnedFd>)> + Unpin>
type ReplyStream = Box<dyn Stream<Item = (Result<Reply<__CfsctlServiceReplyStreamParams>, __CfsctlServiceReplyStreamError>, Vec<OwnedFd>)> + Unpin>
Source§type ReplyStreamParams = __CfsctlServiceReplyStreamParams
type ReplyStreamParams = __CfsctlServiceReplyStreamParams
Service::ReplyStream] will be expected to yield. Read moreSource§type ReplyStreamError = __CfsctlServiceReplyStreamError
type ReplyStreamError = __CfsctlServiceReplyStreamError
Source§type ReplyError<'ser> = __CfsctlServiceReplyError<'ser>
where
Self: 'ser
type ReplyError<'ser> = __CfsctlServiceReplyError<'ser> where Self: 'ser
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>>
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>>
Auto Trait Implementations§
impl Freeze for CfsctlService
impl !RefUnwindSafe for CfsctlService
impl Send for CfsctlService
impl Sync for CfsctlService
impl Unpin for CfsctlService
impl UnsafeUnpin for CfsctlService
impl !UnwindSafe for CfsctlService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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