pub struct Transaction { /* private fields */ }Expand description
A set of staged objects and queued writes to one repository.
Repo::transaction and Repo::transaction_with_lock begin a
transaction. The transaction holds the repository lock and its own staging
directory until it ends. commit publishes the
staged objects and writes the queued refs and detached metadata.
abort discards them.
If a transaction drops without commit or abort, it removes its staging
directory with each staged object and releases the lock. So an abandoned
transaction leaves nothing behind.
§Concurrency
One process can hold many transactions at once, each with its own staging
directory. The repository lock coordinates them. It also excludes other
processes and the ostree command, as LockKind
states.
&Transaction is Send + Sync, so concurrent writers can stage objects
through one shared reference. A mutex guards the state that the writers
share: the set of staged objects for the dedup, the free-space budget, and
the archive size records.
§Staging directory
A transaction stages its objects in tmp/staging-<boot-id>-XXXXXX. It
creates the directory when it begins and removes it when it ends. While the
transaction lives, it holds an exclusive record lock on the sibling file
staging-<boot-id>-XXXXXX-lock.
The boot id separates the directories of the current boot from the directories of earlier boots. The owner of a directory of the current boot can still be alive. The owner of a directory of an earlier boot is gone.
When a transaction begins, it removes these stale entries at the top level
of tmp/:
- A staging directory whose lock it can take, because no live holder has the lock.
- A staging directory with no lock file, if the directory is older than
tmp-expiry-secs. The age test is necessary because another process can be in the middle of the creation of the directory. - Each other entry whose mtime is older than
tmp-expiry-secs, as theostreecommand does. A directory goes as a whole tree, by its own mtime. A symlink goes as the link itself.
It never touches tmp/cache, and it never removes a staging directory that
this process owns. A staging lock file has no age test, because a
transaction can live longer than tmp-expiry-secs and still hold the lock.
A ref write, a detached-metadata write, and a tombstone write create a temp
entry at the top level of tmp/ and rename it over the target. The entry
of a ref write is named .ostrya-ref-<pid>-<n>-XXXXXX. The entry of the
other two writes is named .ostrya-meta-<pid>-<n>-XXXXXX. The age test
applies to such an entry.
If tmp-expiry-secs is very small or negative, a transaction that begins
can remove the entry before its rename. The write then fails with ENOENT,
and the ref or the object stays unchanged.
§Examples
Commit the directory /srv/rootfs and point a ref at the new commit:
use std::os::fd::AsFd;
use std::path::Path;
use ostrya::{CommitOptions, MutableTree, Ref, Repo};
let repo = Repo::open(Path::new("/srv/repo")).await?;
let txn = repo.transaction().await?;
let parent = std::fs::File::open("/srv")?;
let mut mtree = MutableTree::new();
txn.write_dfd_to_mtree(parent.as_fd(), Path::new("rootfs"), &mut mtree, None)
.await?;
let root = txn.write_mtree(&mut mtree).await?;
let opts = CommitOptions {
subject: Some("Build 1".into()),
..CommitOptions::default()
};
let commit = txn.write_commit(opts, &root).await?;
txn.set_ref(&Ref::local("exampleos/stable"), Some(&commit));
let stats = txn.commit().await?;
println!("{} content objects written", stats.content_written);Implementations§
Source§impl Transaction
Methods that set the options of a transaction, read its staged trees, queue
detached metadata, and end it.
impl Transaction
Methods that set the options of a transaction, read its staged trees, queue detached metadata, and end it.
Sourcepub fn set_fsync(&mut self, enabled: bool)
pub fn set_fsync(&mut self, enabled: bool)
Overrides the [core] fsync value for this transaction alone.
The value applies to the whole transaction: the per-object writes, the
publication step, the detached-metadata writes, and the ref writes. It
changes the durability of the writes and no byte that the repository
stores.
commit states the sync sequence.
Sourcepub fn set_per_object_fsync(&mut self, enabled: bool)
pub fn set_per_object_fsync(&mut self, enabled: bool)
Overrides the [core] per-object-fsync value for this transaction alone.
If the value is true, the transaction syncs the file of each content
object when it stages the object, before publication. It never syncs a
metadata object on its own. It does not sync an object imported by
hardlink.
The value has no effect while fsync is off, from the config or from
set_fsync. It changes the durability of the
writes and no byte that the repository stores.
commit states the sync sequence.
Sourcepub fn set_generate_sizes(&mut self, enabled: bool)
pub fn set_generate_sizes(&mut self, enabled: bool)
Sets if each commit of this transaction carries the ostree.sizes key.
A file system ingest under
GENERATE_SIZES turns the
key on. This call serves an ingest that runs no commit modifier, for
example the tar import. The value holds for the whole transaction and
overrides the flag of each ingest, so false turns the key off again.
Outside archive mode the call has no effect, because no other mode writes the key.
Sourcepub fn begin_tree_source(&self)
pub fn begin_tree_source(&self)
Starts a new tree source for the ostree.sizes key.
The ostree command limits the key to the objects that the last tree
source added, plus the directory objects that the tree serialization
writes. So a content object from an earlier source leaves the key, and a
directory object stays.
A caller that builds a commit from several sources calls this method
before each source. Then the key that ostrya writes is the key that the
ostree command writes. If a caller never calls this method, the key
covers each object that the commit reaches.
The --base layer of a commit goes in before the first call, so it adds
nothing to the key. The ostree command records the same key.
Sourcepub fn is_commit_staged(&self, commit: &Checksum) -> bool
pub fn is_commit_staged(&self, commit: &Checksum) -> bool
Returns true if the commit object commit is staged in this
transaction.
write_commit stages a new commit. A
commit that the repository holds before the write, complete or
partial, is not staged. A caller that attaches the image of a new
commit alone with
attach_composefs_image checks
the commit with this call. The call reads the staged set of this
transaction, so another writer under the shared lock does not change
its result. A Repo::has_object check after the write reads the
object store, and another transaction can publish the same commit
before that check.
Sourcepub async fn read_dir(&self, tree: &RepoTree) -> Result<Vec<TreeEntry>>
pub async fn read_dir(&self, tree: &RepoTree) -> Result<Vec<TreeEntry>>
Lists one directory of a tree that this transaction staged.
The call reads the objects that this transaction staged first, and then
objects/. A caller can use it to derive commit metadata from a tree
before the transaction commit.
RepoTree::read_dir reads objects/
alone, so it sees a tree only after the transaction commit. The order of
the entries is the same in both calls: files first, then subdirectories,
each group sorted by name.
Before the transaction commit, RepoTree::read_dir on a
TreeEntry::Dir of a staged tree fails with
Error::ObjectNotFound. This method reads such an entry.
§Errors
Error::ObjectNotFoundif the dirtree oftreeis not staged and not inobjects/.Error::Ioif the read of the dirtree fails, or if the dirtree is larger thanMAX_METADATA_SIZE.Error::Coreif the dirtree does not parse.
Sourcepub fn set_commit_detached_metadata(&self, checksum: &Checksum, meta: Value)
pub fn set_commit_detached_metadata(&self, checksum: &Checksum, meta: Value)
Queues the detached metadata of a commit that this transaction writes.
meta is an a{sv} dict. It replaces the detached metadata that the
repository stores for checksum. The write happens at
commit, after the staged objects publish and
before the queued ref writes. So the commit and its detached metadata are
durable before a ref names them.
If the call runs twice for one checksum, the last dict stays. The call
also drops the signatures that sign_commit
queued before it, and the build sources that
add_detached_related queued
before it.
The call does not check meta, and it cannot fail. commit checks
each ostrya.related entry of the queued dict, as
Repo::write_commit_detached_metadata does. If an entry is
defective, commit fails with Error::InvalidRelated and publishes
nothing.
Queues the build source name with the checksum source for the
detached metadata of the commit commit.
The write at commit adds the entry to the
first ostrya.related entry of the detached metadata, as
Repo::add_detached_related does: it removes each element with the
name name, adds the new element, and keeps the elements sorted by
name in byte order. The write adds the entries of all calls for one
commit in one step. The result is the same as one add for each call,
in call order, after the dict that
set_commit_detached_metadata
queued, or else after the stored dict. The signatures that
sign_commit queues come after the adds.
The call does not check that the transaction or the repository holds
commit or source, and it writes nothing to the file system.
If the stored value of the first ostrya.related entry is defective,
the write at commit fails with
Error::InvalidRelated. The commit fails after it publishes the
staged objects. It then writes no ref, and the .commitmeta file of
commit stays as it was. The detached-metadata edits of other commits
that the queue holds before this one stay written.
§Errors
Error::InvalidRelated with commit and
RelatedField::BuildSources if
name is empty. The call then queues nothing.
Sourcepub async fn sign_commit(
&self,
checksum: &Checksum,
signer: &dyn Signer,
) -> Result<()>
pub async fn sign_commit( &self, checksum: &Checksum, signer: &dyn Signer, ) -> Result<()>
Signs a commit that this transaction wrote and queues the signature.
The signature goes into the detached metadata of the commit. The
payload is the canonical bytes of the commit object. The call reads them
from the staging directory if the object is staged, and from objects/
if the repository holds the object already.
The signature appends to the aay array of the engine, in the first of
these dicts that exists:
- The dict that
set_commit_detached_metadataqueued. - The dict that the repository stores at the time of the write.
- An empty dict.
The call writes nothing to the file system. The signing step comes before the object publication and the ref writes. So a signer failure fails the transaction before it publishes an object or moves a ref.
§Concurrent signers
The queue step takes one lock and holds no await. The call makes the signature here, before it takes a lock of the commit.
The write at commit reads, merges, and replaces
the file under the update lock. So each signature that tasks or
processes make for one commit reaches the file: from one transaction,
from concurrent transactions, and from Repo::sign_commit. The
ostree command can lose a signature in that case.
§Errors
Error::ObjectNotFoundif the commit is not staged and not inobjects/.Error::Ioif the read of the commit object fails, or if the object is larger thanMAX_METADATA_SIZE.Error::Signatureifsignercannot make a signature. An error of a signer can also convert toError::InvalidFormatorError::Core.
Sourcepub async fn commit(self) -> Result<TransactionStats>
pub async fn commit(self) -> Result<TransactionStats>
Publishes the staged objects into objects/ and writes the queued refs.
§Sequence
- The call checks each queued refspec. If a refspec is malformed, the
call fails before it publishes an object, and it writes nothing.
The call then checks each
ostrya.relatedentry of each dict thatset_commit_detached_metadataqueued, asRepo::write_commit_detached_metadatadoes. On a refusal the call publishes no object and writes nothing. - If
[ex-ostrya] generate-composefsistrue, the call builds the composefs image of each commit that the writer recorded as complete, as# Composefs imagesstates. If a build fails, the call publishes no object and writes nothing. - The call renames each staged object into
objects/<xx>/, and then each staged composefs image intoextensions/ostrya/composefs/<xx>/. So an image is in place only after each object of the transaction. The rename of an image replaces a stored image of the same commit. - The call writes the queued detached-metadata edits.
- The call writes the queued refs. Each ref write is atomic: a temp file, then a rename. The set of ref writes is not atomic as a whole.
- The call removes the staging directory and releases the repository lock.
Steps 4 and 5 run in one trip to the blocking pool.
§Composefs images
Each writer of a complete commit records the commit for the build of
step 2: write_commit,
write_commit_checked, a pull
from a remote, a local pull, a receive with ref updates, and
Repo::apply_static_delta. The commit writes and
Repo::apply_static_delta record a commit only if they stage its
object, so a commit that the repository holds already, complete or
partial, gets no image from them. A pull records each commit that it
completes: the targets, the parents within the depth, the
dependencies, and each held partial commit. A partial commit is not
recorded. write_metadata records no
commit. Repo::commit_add_composefs_metadata and the server commit
of a receive build the image of their commit themselves, and stage it
if the transaction stages the commit. So step 2 does not build it
again.
The build reads each recorded commit, staged first. It skips a commit
that the transaction did not stage and that has no .commitpartial
marker, so a commit that the repository holds complete before the
transaction gets no image. It also skips a commit with no
ostree.composefs.digest.v0 key and a commit whose image is staged.
For each other commit, it makes the steps of
write_composefs_image. The
build reads the fs-verity digest of a sealed object from the kernel.
It reads and hashes each other object one time, and uses that digest
for each commit and each path that names the object.
§Durability
One fsync policy applies to all steps: the value from
set_fsync, or else [core] fsync of the
repository config. With fsync on, the call syncs as follows:
- Before the renames of step 3, it runs
syncfson the repository. - After the renames of the objects, it runs
fsyncon each fanout directory that got an object, and onobjects/. - After the renames of the images, it runs
fsyncon eachextensions/ostrya/composefs/<xx>/directory that got an image, and onextensions/ostrya/composefs/. It syncs each directory that the call creates into its parent. - Before the rename of each ref, it runs
fdatasyncon the temp file. - After the last ref rename, it runs
fsynconce on each directory that gained or lost a ref name, deepest first.
With this sequence, a commit and its .commitmeta are durable before a
ref names them. Each ref is durable when the call returns. With fsync
off, no step syncs.
§Locks
The transaction holds the repository lock from its begin to the end of
this call, in the LockKind of its begin. Steps 2
and 3 run with no update lock.
If the transaction writes a ref, a ref removal included, or detached
metadata, the call takes the update lock for steps 4 and 5. The update
lock excludes the other writers of refs and detached metadata, as
UpdateGuard states. The wait is for the update
lock alone, because the transaction holds the repository lock already. A
transaction that writes neither does not take the update lock.
§Cancellation
The update lock, the repository lock, and the staging directory move into the blocking closure of steps 4 and 5. The closure releases them when its writes end. If a caller drops the returned future, the writes complete, and the locks and the staged files stay until the writes end.
§Errors
Error::InvalidRefspecif a queued refspec is malformed, or if the collection id of a queued collection ref does not passis_collection_idor is longer than 255 bytes. The call publishes no object and writes no ref.Error::InvalidRelatedif anostrya.relatedentry of a queued detached-metadata dict is not a variant of typea(say), or if one of its elements has an empty name or a checksum that is not 32 bytes. The call publishes no object and writes nothing.Error::InvalidRelatedif a build source thatadd_detached_relatedqueued meets a defective storedostrya.relatedvalue. The published objects stay, and the call writes no ref.- Under
[ex-ostrya] generate-composefs, the errors ofwrite_composefs_imagefor a recorded commit. Among them,Error::InvalidFormatif the value of the digest key of the commit is malformed, andError::ComposefsDigestMismatchif the image of its tree does not have the digest that the key records. The call publishes no object and writes nothing. - The errors of
RepoConfig::generate_composefsif a writer recorded a commit. Error::InvalidFormatif a staged composefs image meets a component ofextensions/ostrya/composefs/<xx>/that is a symlink or no directory. The objects and the images that the call renamed before stay, and the call writes no detached metadata and no ref.Error::LockTimeoutif the wait for the update lock passes[core] lock-timeout-secs. The published objects stay, and the call writes no detached metadata and no ref.Error::Coreif[core] fsync,[core] per-object-fsync, or[core] lock-timeout-secshas a value that does not parse.Error::Coreif the stored detached metadata of a commit does not parse.Error::InvalidFormatif[core] lock-timeout-secsis less than-1, or if a signature entry of the stored detached metadata is not an array.Error::Ioif a rename, a sync, or a write of a ref or of the detached metadata fails.
Source§impl Transaction
Methods that read the kernel version of a staged tree.
impl Transaction
Methods that read the kernel version of a staged tree.
Sourcepub async fn kernel_version(
&self,
root: &RepoTree,
) -> Result<Result<String, BootableRefusal>>
pub async fn kernel_version( &self, root: &RepoTree, ) -> Result<Result<String, BootableRefusal>>
Returns the kernel version of a tree that this transaction staged.
The version is the value of ostree.linux. The search reads each
dirtree with read_dir, so it sees the objects
that this transaction staged and the objects in objects/. A caller can
derive the metadata of a commit before the transaction commit.
The search rules are the same as in RepoTree::kernel_version. The
inner Result holds the version or a BootableRefusal. A refusal is
an outcome of the search. The outer Result holds the errors of the
object reads.
§Errors
Error::ObjectNotFoundif a dirtree on the search path is not staged and not inobjects/.Error::Ioif the read of a dirtree fails, or if a dirtree is larger thanMAX_METADATA_SIZE.Error::Coreif a dirtree does not parse.
Source§impl Transaction
Methods that write a commit object.
impl Transaction
Methods that write a commit object.
Sourcepub async fn write_commit(
&self,
opts: CommitOptions,
root: &RepoTree,
) -> Result<Checksum>
pub async fn write_commit( &self, opts: CommitOptions, root: &RepoTree, ) -> Result<Checksum>
Stages a commit object over the tree root and returns its checksum.
The call stages the commit in the same way as other metadata objects.
The root dirtree and the root dirmeta come from root. The other
fields come from opts.
The metadata dict is opts.metadata, or an empty dict if it is None.
The call adds no key of its own except ostree.sizes. The binding keys
ostree.ref-binding and ostree.collection-binding are normal
metadata entries that the caller supplies.
§ostree.sizes
The commit gets the ostree.sizes key if the transaction generates
sizes and the repository is in archive mode. A file system ingest under
GENERATE_SIZES turns
size generation on. set_generate_sizes
sets it for the whole transaction.
The key is the last metadata entry, as in a commit of the ostree
command. Its records cover the objects that the committed root reaches,
and no other objects:
- the root dirmeta
- each dirtree
- each subdirectory dirmeta
- each file entry
The commit object is not in the list, because the walk starts below it.
If a transaction stages more than one commit, the key of each commit
holds the objects that this commit reaches. If the caller uses
begin_tree_source, the key holds the
objects of the last tree source and the directory objects.
The call walks the committed tree at commit time. An object that the
transaction staged uses the size record that the transaction kept. An
object that deduplicated against objects/ gets its sizes from its
loose object. As in a commit of the ostree command, an incremental
commit also lists the objects that existed before.
In each other mode the call writes no key. The bytes of the commit are the same with and without the request.
§Composefs image
If the call stages the commit object, it records the commit as
complete. If [ex-ostrya] generate-composefs is true and the commit
carries ostree.composefs.digest.v0, commit
then builds and stores the composefs image of the commit. A commit that
the repository holds already, complete or partial, is not staged, so it
gets no image.
§Dependencies
Field 2 of the commit object holds the entries of opts.related,
sorted by name in byte order. The call refuses an entry with an empty
name and two entries with the same name. It checks nothing else in a
name.
Each dependency must be complete: this transaction stages its commit
object or the repository holds it, and the repository holds no
state/<checksum>.commitpartial marker for it. A dependency that this
transaction writes must be staged before the call that names it. A
dependency must have no dependency of its own, so a dependency names
no dependency. It can have a parent and build sources.
The call checks the dependencies as
check_related does, after the timestamp
and before it serializes the commit. On a refusal, it writes nothing
and the transaction stays open.
A caller that checks the dependencies before it builds the tree calls
check_related and then
write_commit_checked. Then each
dependency is checked one time.
§Errors
Error::Unsupportedif the repository mode isbare-split-xattrs.Error::InvalidRelatedif an entry ofopts.relatedhas an empty name, if two entries have the same name, or if a dependency is absent, partial, or has a dependency of its own.Error::Coreif the commit tuple of a dependency does not frame, or if its field 2 does not decode.Error::Unsupportedif[ex-integrity] fsverityisyesand the fs-verity seal fails.Error::InvalidFormatifopts.timestampisNoneandSOURCE_DATE_EPOCHis not a count of seconds.Error::InvalidFormatif the call reads the system clock and the clock is before the Unix epoch.Error::InvalidFormatif the call addsostree.sizesandopts.metadatais not an array value.Error::InvalidFormatif[ex-integrity] fsverityor[ex-integrity] composefsin the repository config is malformed.Error::Coreif the commit does not serialize:opts.metadatais not ana{sv}dict, a string holds an interior NUL byte, or the metadata nests too deep.Error::Coreif[core] fsyncor[core] per-object-fsyncin the repository config is malformed.Error::Coreif the call addsostree.sizesand a dirtree that the commit reaches does not parse.Error::ObjectNotFoundif the call addsostree.sizesand an object that the commit reaches is in neither the staging directory norobjects/.- The errors of
load_fileif the call addsostree.sizesand a file object fromobjects/does not load. Error::InsufficientFreeSpaceif the commit object needs more space than the free-space budget of the transaction holds.Error::Ioif the call addsostree.sizesand a dirtree that the commit reaches is larger thanMAX_METADATA_SIZE.Error::Ioif a file system operation fails.
Sourcepub async fn write_commit_checked(
&self,
opts: CommitOptions,
related: CheckedRelated<'_>,
root: &RepoTree,
) -> Result<Checksum>
pub async fn write_commit_checked( &self, opts: CommitOptions, related: CheckedRelated<'_>, root: &RepoTree, ) -> Result<Checksum>
Stages a commit object over the tree root with the dependencies
related, and returns its checksum.
The call writes the commit as write_commit
does. Field 2 of the commit object holds the entries of related,
sorted by name in byte order. opts.related must be empty. For the
same inputs, the call and write_commit give the same commit.
The call records the commit for the composefs image as write_commit
does.
The call does not check the dependencies again.
check_related checked them. A process
outside the transaction can make a dependency partial or absent after
that check: for example, an fsck, which takes no repository lock, or a
prune in a repository with [core] locking=false. The call does not
refuse such a dependency, and an fsck reports it.
§Errors
The call checks the origin of related, then opts.related, then the
repository mode, then the timestamp. On these refusals, it writes
nothing and the transaction stays open.
Error::InvalidInputifrelatedcomes from another transaction.Error::InvalidInputifopts.relatedis not empty.Error::Unsupportedif the repository mode isbare-split-xattrs.Error::Unsupportedif[ex-integrity] fsverityisyesand the fs-verity seal fails.Error::InvalidFormatifopts.timestampisNoneandSOURCE_DATE_EPOCHis not a count of seconds.Error::InvalidFormatif the call reads the system clock and the clock is before the Unix epoch.Error::InvalidFormatif the call addsostree.sizesandopts.metadatais not an array value.Error::InvalidFormatif[ex-integrity] fsverityor[ex-integrity] composefsin the repository config is malformed.Error::Coreif the commit does not serialize:opts.metadatais not ana{sv}dict, a string holds an interior NUL byte, or the metadata nests too deep.Error::Coreif[core] fsyncor[core] per-object-fsyncin the repository config is malformed.Error::Coreif the call addsostree.sizesand a dirtree that the commit reaches does not parse.Error::ObjectNotFoundif the call addsostree.sizesand an object that the commit reaches is in neither the staging directory norobjects/.- The errors of
load_fileif the call addsostree.sizesand a file object fromobjects/does not load. Error::InsufficientFreeSpaceif the commit object needs more space than the free-space budget of the transaction holds.Error::Ioif the call addsostree.sizesand a dirtree that the commit reaches is larger thanMAX_METADATA_SIZE.Error::Ioif a file system operation fails.
Checks the dependencies related of a new commit, as
write_commit checks
CommitOptions::related.
The call refuses an entry with an empty name and two entries with the
same name. Then it checks each dependency in the byte order of the
names: the dependency must be complete in the repository or in this
transaction, and it must have no dependency of its own.
write_commit states the rules and runs
the same checks. The call does not change related and writes
nothing.
The call reads no tree. A caller can call it before it builds a large tree, so that a refused dependency stops the work before the build.
Returns the checked entries, sorted by name in byte order.
write_commit_checked takes them
and writes the commit with no second check.
§Errors
Error::InvalidRelatedwith no commit, if an entry ofrelatedhas an empty name, if two entries have the same name, or if a dependency is absent, partial, or has a dependency of its own.Error::Coreif the commit tuple of a dependency does not frame, or if its field 2 does not decode.Error::Ioif the commit object of a dependency with no partial marker is larger thanMAX_METADATA_SIZE, or if a file system operation fails.
Source§impl Transaction
Methods that compute the composefs digest of a staged tree and stage the
composefs image of a commit.
impl Transaction
Methods that compute the composefs digest of a staged tree and stage the composefs image of a commit.
Sourcepub async fn composefs_digest(&self, root: &RepoTree) -> Result<[u8; 32]>
pub async fn composefs_digest(&self, root: &RepoTree) -> Result<[u8; 32]>
Returns the composefs image digest of a tree that this transaction staged.
The value is the one that ostree.composefs.digest.v0 holds: the
fs-verity digest of the image that an export with
ComposefsOptions::RECORDED writes for the same tree.
Repo::export_composefs describes the image.
The call reads each object that this transaction staged from the
staging directory, and each other object from objects/. The digest is
available before the transaction commit, so it can go into the metadata
of the commit that the tree belongs to. The value depends on the tree
alone, so a repository of any mode that holds the tree gives the same
digest.
The image goes to std::io::sink, so the digest needs no image-sized
buffer.
§Errors
Error::ObjectNotFoundif a dirtree, dirmeta, or file object of the tree is in neither the staging directory nor the object store.Error::Coreif a dirtree object, a dirmeta object, or the header of a file object does not parse.Error::InvalidFormatif a file object does not have the form of the repository mode.Repo::load_filelists the cases.Error::Unsupportedif the tree does not fit a limit of the image.Repo::export_composefslists the limits.Error::Ioif a file system operation fails, if a metadata object is larger thanMAX_METADATA_SIZE, or if anarchivepayload does not inflate.
Sourcepub async fn build_composefs_image(
&self,
root: &RepoTree,
) -> Result<StagedComposefsImage<'_>>
pub async fn build_composefs_image( &self, root: &RepoTree, ) -> Result<StagedComposefsImage<'_>>
Writes the composefs image of a tree to the staging directory of this transaction.
The image is the image that an export with
ComposefsOptions::RECORDED writes for the same tree, so
StagedComposefsImage::digest is the value of
composefs_digest. The call reads the
objects of the tree as composefs_digest reads them. A caller that
writes a new commit takes the digest for the key
ostree.composefs.digest.v0 of the commit, writes the commit, and then
gives the image to attach_composefs_image.
The tree is then read one time.
The writer computes the fs-verity digest as it writes the image, and
it holds no image-sized buffer. The image file has the mode 0644. If
[ex-integrity] fsverity is not no, the call seals the file and
compares the digest that the kernel reads with the digest of the
writer. If the fsync and per-object-fsync values of the
transaction are both on, the call syncs the file. Each value comes from
set_fsync or
set_per_object_fsync if the
transaction has an override, and else from [core] fsync or
[core] per-object-fsync.
§Errors
Error::Unsupportedif the repository mode isbare-split-xattrs.- The errors of
composefs_digest. Error::Unsupportedif[ex-integrity] fsverityisyesand the seal fails.Error::InvalidFormatif the digest that the kernel reads for the sealed file is not the digest of the writer.Error::Coreif[core] fsyncor[core] per-object-fsyncin the repository config is malformed.Error::InvalidFormatif[ex-integrity] fsverityin the repository config is malformed.Error::Ioif a write to the image file or another file system operation fails.
Sourcepub async fn attach_composefs_image(
&self,
commit: &Checksum,
image: StagedComposefsImage<'_>,
) -> Result<ComposefsImageAdd>
pub async fn attach_composefs_image( &self, commit: &Checksum, image: StagedComposefsImage<'_>, ) -> Result<ComposefsImageAdd>
Stages image as the composefs image of commit.
The commit comes from the staged set of this transaction, or else from
objects/. The call checks the digest of the image against the key
ostree.composefs.digest.v0 of the commit, and refuses a mismatch. It
then compares the stored image of the commit with the key, if the
repository holds one. The call streams the stored image through the
fs-verity hasher.
- With no stored image, the call stages the image and returns
ComposefsImageAdd::Added. - With a stored image whose digest is the key, the call drops the image
and returns
ComposefsImageAdd::AlreadyValid. - With a stored image whose digest is not the key, or a stored image
that does not read, the call stages the image and returns
ComposefsImageAdd::Replaced.
If the call does not stage the image, it removes the image file.
commit renames a staged image into
extensions/ostrya/composefs/<xx>/ after it renames the objects of the
transaction into objects/. The rename replaces the stored image in
one step. No field of TransactionStats
counts the image, and ostree.sizes has no entry for it. The image
takes its size from the free-space budget of the transaction.
§Errors
Error::InvalidInputifimagecomes from another transaction.Error::InvalidInputif the commit does not carryostree.composefs.digest.v0.Error::InvalidFormatif the first entry of that key is not a variant of typeaywith 32 bytes.Error::ComposefsDigestMismatchif the digest of the image is not the value of the key.Error::ObjectNotFoundif the commit object is not staged and not in the object store.Error::Coreif the commit object does not parse.Error::InsufficientFreeSpaceif the image needs more space than the free-space budget of the transaction holds.Error::Ioif a file system operation fails, or if the commit object is larger thanMAX_METADATA_SIZE.
Sourcepub async fn write_composefs_image(
&self,
commit: &Checksum,
) -> Result<ComposefsImageAdd>
pub async fn write_composefs_image( &self, commit: &Checksum, ) -> Result<ComposefsImageAdd>
Builds and stages the composefs image of commit.
The call runs build_composefs_image
over the root of the commit and
attach_composefs_image with
the result. If the repository holds a valid image of the commit
already, the call builds nothing and returns
ComposefsImageAdd::AlreadyValid.
The call does not refuse a partial commit. If an object of the tree is absent, the build fails.
§Errors
Error::InvalidInputif the commit does not carryostree.composefs.digest.v0.Error::ComposefsDigestMismatchif the image of the tree does not have the digest that the commit records.- The errors of
build_composefs_imageand ofattach_composefs_image.
Source§impl Transaction
Methods that read a directory on disk into a mutable tree.
impl Transaction
Methods that read a directory on disk into a mutable tree.
Sourcepub async fn write_dfd_to_mtree(
&self,
dfd: BorrowedFd<'_>,
path: &Path,
mtree: &mut MutableTree,
modifier: Option<&mut CommitModifier>,
) -> Result<()>
pub async fn write_dfd_to_mtree( &self, dfd: BorrowedFd<'_>, path: &Path, mtree: &mut MutableTree, modifier: Option<&mut CommitModifier>, ) -> Result<()>
Walks the directory at path under dfd and adds its tree to mtree.
The metadata of the walk root becomes the dirmeta of mtree. The walk
adds each entry below the root to mtree:
- The payload of a regular file streams into a content object.
- A symlink and the metadata of each directory become objects.
- A directory merges with a directory of the same name in
mtree. - A regular file or a symlink replaces a file of the same name in
mtree.
write_mtree writes the dirtree of each
directory later. If path is empty or ., the walk root is dfd
itself. The walk does not follow a symlink at the last component of
path.
§Modifier
Without a modifier, each entry records the ownership, the mode, and the
xattrs that it has on disk. A CommitModifier applies its steps to
each entry in this order:
- The
CANONICAL_PERMISSIONSreduction: owner 0:0, no xattrs, andperm & 0o755on a regular file or a directory. A symlink keeps its mode. SKIP_XATTRS: the walk reads no xattrs from the disk, and the entry has no xattrs.- The declared ownership (
owner_uidandowner_gid). - The filter. It gets the metadata of steps 1 to 3. If it returns
FilterResult::Skipfor a directory, the walk skips the whole subtree. - The mode callback.
- The
CANONICAL_PERMISSIONSreduction again, on the mode that the callback returns. The file type stays the type that the walk found. A symlink keeps its mode. - The xattr callback.
- The SELinux label callback. The walk drops the
security.selinuxxattr of the entry, then adds the label that the callback returns. If the callback returns no label, the entry has no label.
Steps 5 to 8 run only for an entry that the filter keeps. The walk root goes through each step except the filter.
If the modifier holds a DevInoCache, the walk
looks up each regular file and symlink in it, and never a directory.
The walk does not read a source file that the cache knows. Without
DEVINO_CANONICAL, a hit
takes its metadata from the stored object. For this reason, a
user.ostreemeta xattr on a file of a bare-user checkout does not
enter the commit.
§Consume
Under CONSUME, the walk removes each
source entry after it records the entry. It also removes each entry
that the filter skips, with its whole subtree. Then the call removes the
walk root.
The test for the walk root is on the bytes of path. If path is
exactly ., the call keeps the root. For each other spelling, ./
included, the call tries to remove the root and ignores a failure.
§File system access
The walk reads each directory in one pass on the blocking pool. The pass
reads the entry list, the statat of each entry, the xattrs, and the
symlink targets. The walk reads the xattrs of a symlink from the link itself. The
calls that open and remove entries run on the calling task.
The walk holds at most two directory descriptors at a time, at any
depth of the source.
§Errors
Error::Unsupportedif the repository mode isbare-split-xattrs, or if an entry is not a directory, a regular file, or a symlink.Error::Unsupportedif[ex-integrity] fsverityisyesand the fs-verity seal of an object fails.Error::InvalidFormatif an entry name or a symlink target is not valid UTF-8.Error::InvalidFormatif the label callback returns no label andERROR_ON_UNLABELEDis set.Error::InvalidFormatif[ex-integrity] fsverityor[ex-integrity] composefsin the repository config is malformed.Error::InvalidFormatif the stored object of a devino-cache hit does not have the form of the repository mode.Error::ConsumeUnlinkifCONSUMEis set and the removal of a source entry fails.Error::ReplaceDirWithFileif a regular file or a symlink has the name of a directory inmtree.Error::ReplaceFileWithDirif a directory has the name of a file inmtree.Error::InsufficientFreeSpaceif an object needs more space than the free-space budget of the transaction holds.Error::ObjectNotFoundif a devino-cache hit or a lazy subdirectory ofmtreenames an object that the repository does not hold.Error::Coreif a stored object does not parse, or if the xattr set with a label is not valid.Error::Coreif a[core]or[archive]value in the repository config is malformed.Error::Ioif a file system operation fails, for example if the walk root is not a directory.
Source§impl Transaction
Methods that read a committed tree into a mutable tree.
impl Transaction
Methods that read a committed tree into a mutable tree.
Sourcepub async fn overlay_tree_to_mtree(
&self,
dirtree: &Checksum,
dirmeta: &Checksum,
mtree: &mut MutableTree,
modifier: Option<&mut CommitModifier>,
) -> Result<()>
pub async fn overlay_tree_to_mtree( &self, dirtree: &Checksum, dirmeta: &Checksum, mtree: &mut MutableTree, modifier: Option<&mut CommitModifier>, ) -> Result<()>
Merges the committed tree of dirtree and dirmeta into mtree.
The merge obeys the rules of
write_dfd_to_mtree, so a committed
tree and a walk of the file system can build one tree under one
modifier. dirmeta becomes the dirmeta of mtree. A directory merges
with a directory of the same name, and a file replaces a file of the
same name.
If modifier is None, the merge records the committed checksums
unchanged. It reads only the dirtrees on the paths where mtree
already holds a directory. It records each other subdirectory with no
read.
If modifier is set, the merge reads each entry and applies the steps
of the modifier to its metadata, in the order that
write_dfd_to_mtree states. If the
result differs from the stored metadata, the merge writes a new object
from the stored payload. Otherwise it records the stored checksum. The
merge does not use CONSUME, GENERATE_SIZES, DEVINO_CANONICAL, or
the devino cache.
The transaction can write ostree.sizes in an archive repository
after a call to begin_tree_source.
Then each object of the committed tree enters the scope of that key,
also an object that the merge does not write.
§Errors
Error::ObjectNotFoundifdirtree,dirmeta, or an object that the merge reads is not in the repository.Error::ReplaceDirWithFileif a file of the committed tree has the name of a directory inmtree.Error::ReplaceFileWithDirif a directory of the committed tree has the name of a file inmtree.Error::InvalidFormatif the label callback returns no label andERROR_ON_UNLABELEDis set.Error::InvalidFormatif a stored file object does not have the form of the repository mode.Error::InvalidFormatif[ex-integrity] fsverityor[ex-integrity] composefsin the repository config is malformed.Error::Unsupportedif the merge writes an object and the repository mode isbare-split-xattrs.Error::Unsupportedif[ex-integrity] fsverityisyesand the fs-verity seal of an object fails.Error::InsufficientFreeSpaceif an object needs more space than the free-space budget of the transaction holds.Error::Coreif a stored object does not parse, or if the xattr set with a label is not valid.Error::Coreif a[core]or[archive]value in the repository config is malformed.Error::Ioif a file system operation fails.
Source§impl Transaction
Methods that write a mutable tree as dirtree objects.
impl Transaction
Methods that write a mutable tree as dirtree objects.
Sourcepub async fn write_mtree(&self, mtree: &mut MutableTree) -> Result<RepoTree>
pub async fn write_mtree(&self, mtree: &mut MutableTree) -> Result<RepoTree>
Writes the changed subtrees of mtree as dirtree objects.
The call stages each new dirtree as an object of GVariant type
(a(say)a(sayay)), and returns the root as a RepoTree. The walk is
post-order: it writes the children of a directory before the directory.
A subtree with no change keeps its committed dirtree checksum, and the
call does not serialize or stage it again, as
MutableTree states.
Each directory that the call writes must have a dirmeta checksum.
The returned root reads back through this transaction alone, as
read_dir states. Before the
transaction commit, RepoTree::read_dir
on a dirtree that this call staged fails with
Error::ObjectNotFound.
§Errors
Error::MutableTreeif a directory that the call writes has no dirmeta checksum. The message names the path of the directory, with/for the root.Error::Coreif an entry name holds a NUL byte, or if[core] fsyncor[core] per-object-fsyncin the repository config is malformed.Error::Unsupportedif the repository mode isbare-split-xattrs, or if[ex-integrity] fsverityisyesand the fs-verity seal fails.Error::InsufficientFreeSpaceif a dirtree needs more space than the free-space budget of the transaction holds.Error::InvalidFormatif[ex-integrity] fsverityor[ex-integrity] composefsin the repository config is malformed.Error::Ioif a file system operation fails.
Source§impl Transaction
Methods that merge an overlayfs upper directory into a mutable tree.
impl Transaction
Methods that merge an overlayfs upper directory into a mutable tree.
Sourcepub async fn merge_overlay_dfd_to_mtree(
&self,
dfd: BorrowedFd<'_>,
mtree: &mut MutableTree,
modifier: Option<&mut CommitModifier>,
) -> Result<()>
pub async fn merge_overlay_dfd_to_mtree( &self, dfd: BorrowedFd<'_>, mtree: &mut MutableTree, modifier: Option<&mut CommitModifier>, ) -> Result<()>
Merges the overlayfs upper directory at dfd into mtree.
dfd is the root of the upper directory (the upperdir of the mount).
mtree holds the lower layer that the overlay was mounted over. The
merge applies the upper directory to mtree as a changeset. The overlay
must be unmounted, and the call does not check this.
Each upper entry other than a whiteout becomes an object, and the entry
replaces or extends the base tree. The merge is an ostrya extension
with no counterpart in the ostree command. It changes no on-disk
format, because a deletion acts on the in-memory tree during the walk.
§Overlay rules
- A whiteout (a character device with device number 0:0) removes its path from the base tree. If the base tree has no entry at the path, the whiteout has no effect.
- An opaque directory (
trusted.overlay.opaqueoruser.overlay.opaqueset toy) clears the base subtree at its name. The merge then reads the upper entries. An opaque root clears the whole base tree. - The merge reads both xattr namespaces. A rootless
userxattroverlay writesuser.*, and an unprivileged reader cannot seetrusted.*. - A merged (non-opaque) directory takes its dirmeta from the upper inode, because overlayfs copies a directory up with its metadata. The root of the upper directory is a merged directory too.
- The merge removes each xattr whose name starts with
trusted.overlay.oruser.overlay.from each file, symlink, and directory that it records, dirmeta included. It keeps every other xattr, also an xattr whose name containsoverlayat another position. - An entry with an
overlay.metacopyoroverlay.redirectxattr is an error, because such an entry is not self-contained. The overlay must be mounted with these features off (metacopy=offandredirect_dir=off). - An upper entry replaces a base entry of a different type. An upper file or symlink over a base directory removes the directory. An upper directory over a base file or symlink removes the leaf and creates a new directory.
A usrmerge migration changes a directory to a symlink. Overlayfs records this change as a plain leaf with no whiteout and no opaque marker. A non-directory upper entry hides a lower entry of any type.
§Modifier
A CommitModifier applies to each recorded entry the steps that
write_dfd_to_mtree lists under
its Modifier heading. The root of the upper directory goes through
each step except the filter. The merge does not use a
DevInoCache or
CONSUME.
Whiteouts and opaque markers are merge mechanics, and the modifier does not see them. The other rules for a modifier are these:
- If the filter returns
FilterResult::Skipfor an upper entry, the base entry stays as it is. For a directory, the merge skips the whole upper subtree. - The merge removes the overlay xattrs before the filter and the callbacks see the xattr set of an entry. The xattr callback can add a removed name again, and the merge does not remove it a second time.
- Under
SKIP_XATTRS, the merge still reads the xattrs of each entry for the overlay rules. The recorded entry has no xattrs. - The merge checks for
overlay.metacopyandoverlay.redirectbefore the filter, so an entry that the filter skips can cause the error.
§Errors
Error::Unsupportedif the repository mode isbare-split-xattrs, or if an upper entry is not a directory, a regular file, a symlink, or a whiteout.Error::Unsupportedif[ex-integrity] fsverityisyesand the fs-verity seal of an object fails.Error::UnsupportedOverlayFeatureif an upper entry has anoverlay.metacopyoroverlay.redirectxattr in one of the two namespaces.Error::InvalidFormatif an entry name or a symlink target is not valid UTF-8.Error::InvalidFormatif the label callback returns no label andERROR_ON_UNLABELEDis set.Error::InvalidFormatif[ex-integrity] fsverityor[ex-integrity] composefsin the repository config is malformed.Error::InvalidFormatif the repository is inbaremode and an xattr name of a symlink is not valid UTF-8.Error::InsufficientFreeSpaceif an object needs more space than the free-space budget of the transaction holds.Error::ObjectNotFoundif a lazy subdirectory ofmtreenames a dirtree that the repository does not hold.Error::Coreif the dirtree of a lazy subdirectory does not parse, or if the xattr set with a label is not valid.Error::Coreif the mode callback returns a file type that the object writer refuses for the entry.Error::Coreif a[core]or[archive]value in the repository config is malformed.Error::Coreifdfdis not a directory: the dirmeta writer refuses the file type of the root.Error::Ioif a file system operation fails.
Source§impl Transaction
Methods that queue ref writes for the transaction commit.
impl Transaction
Methods that queue ref writes for the transaction commit.
Sourcepub fn set_ref(&self, r: &Ref, checksum: Option<&Checksum>)
pub fn set_ref(&self, r: &Ref, checksum: Option<&Checksum>)
Queues a ref write for the transaction commit.
commit writes the ref after it publishes the
objects. If checksum is None, the commit removes the ref.
The ref gives the path, as
set_ref_immediate states. A collection
ref of the [core] collection-id of the repository is at
refs/heads/<name>, so the commit writes or removes that file, and it
does not touch refs/mirrors/<collection>/.
The call itself does not check the ref. If the ref fails
Ref::validate, the commit fails with Error::InvalidRefspec,
which holds the text of the ref. The commit then publishes no object
and writes no ref.
If a directory of refs/mirrors/ has a name that fails the rule, a
ref under it cannot be written or removed through this call. Remove
such a ref by hand.
Source§impl Transaction
Methods that create a staging tree.
impl Transaction
Methods that create a staging tree.
Sourcepub async fn staging_tree(
&self,
source: Option<&Commit>,
) -> Result<StagingTree<'_>>
pub async fn staging_tree( &self, source: Option<&Commit>, ) -> Result<StagingTree<'_>>
Creates a staging tree over this transaction, empty or from a commit.
With a source commit, the call reads the root dirtree of the commit,
and the tree loads each subdirectory when an operation first reaches
it. With None, the tree is empty and its root has no dirmeta.
write_mtree refuses a root with no
dirmeta, so ensure_dir on the path .
sets one.
§Errors
Error::ObjectNotFoundif the root dirtree ofsourceis not in the repository.Error::Coreif the root dirtree is malformed.Error::Ioif the read of the root dirtree fails.
Sourcepub fn staging_tree_from_mutable_tree(
&self,
source: MutableTree,
) -> StagingTree<'_>
pub fn staging_tree_from_mutable_tree( &self, source: MutableTree, ) -> StagingTree<'_>
Creates a staging tree over this transaction from an existing mutable tree.
Source§impl Transaction
Methods that stage objects.
impl Transaction
Methods that stage objects.
Sourcepub async fn content_writer(
&self,
expected: Option<&Checksum>,
meta: &FileMeta,
) -> Result<ContentWriter<'_>>
pub async fn content_writer( &self, expected: Option<&Checksum>, meta: &FileMeta, ) -> Result<ContentWriter<'_>>
Creates a streaming writer for the payload of one regular file.
meta holds the logical uid, gid, mode, and xattrs that the object
header records. meta.mode must name a regular file. The call refuses
only a mode that names neither a regular file nor a symlink.
If expected is given, finish verifies the
computed identity against it. ContentWriter states the identity and
the storage form.
§Errors
Error::Unsupportedif the repository mode isbare-split-xattrs, which ostrya does not write.Error::Coreif the file-type bits ofmeta.modename neither a regular file nor a symlink.Error::Coreif the repository is in archive mode and[archive] zlib-levelin the repository config is malformed.Error::Ioif the temp file cannot be created or written.
Sourcepub async fn write_content(
&self,
expected: Option<&Checksum>,
meta: &FileMeta,
reader: impl AsyncRead + Unpin,
) -> Result<Checksum>
pub async fn write_content( &self, expected: Option<&Checksum>, meta: &FileMeta, reader: impl AsyncRead + Unpin, ) -> Result<Checksum>
Streams the payload of a regular file from reader into a content
object.
The call copies reader into a ContentWriter in chunks of 64 KiB,
so it never holds the whole payload in memory. meta and expected
are as for content_writer. The call
returns the checksum of the object.
§Errors
Error::Unsupportedif the repository mode isbare-split-xattrs, or if[ex-integrity] fsverityisyesand the fs-verity seal fails.Error::ChecksumMismatchifexpectedis given and differs from the computed checksum.Error::InsufficientFreeSpaceif the object needs more space than the free-space budget of the transaction holds.Error::Coreif the file-type bits ofmeta.modename neither a regular file nor a symlink.Error::Coreif a[core]or[archive]value in the repository config is malformed.Error::InvalidFormatif[ex-integrity] fsverityor[ex-integrity] composefsin the repository config is malformed.Error::InvalidFormatif the repository is inbaremode and an xattr name inmetais not valid UTF-8.Error::Ioif a read fromreaderfails, or if a file system operation fails.
Sourcepub async fn write_regfile_inline(
&self,
expected: Option<&Checksum>,
meta: &FileMeta,
data: &[u8],
) -> Result<Checksum>
pub async fn write_regfile_inline( &self, expected: Option<&Checksum>, meta: &FileMeta, data: &[u8], ) -> Result<Checksum>
Writes a regular file whose content the caller holds in memory.
write_content streams a payload from a
reader. meta and expected are as for
content_writer. The call returns the
checksum of the object.
§Errors
Error::Unsupportedif the repository mode isbare-split-xattrs, or if[ex-integrity] fsverityisyesand the fs-verity seal fails.Error::ChecksumMismatchifexpectedis given and differs from the computed checksum.Error::InsufficientFreeSpaceif the object needs more space than the free-space budget of the transaction holds.Error::Coreif the file-type bits ofmeta.modename neither a regular file nor a symlink.Error::Coreif a[core]or[archive]value in the repository config is malformed.Error::InvalidFormatif[ex-integrity] fsverityor[ex-integrity] composefsin the repository config is malformed.Error::InvalidFormatif the repository is inbaremode and an xattr name inmetais not valid UTF-8.Error::Ioif a file system operation fails.
Sourcepub async fn write_symlink(
&self,
target: &str,
meta: &FileMeta,
expected: Option<&Checksum>,
) -> Result<Checksum>
pub async fn write_symlink( &self, target: &str, meta: &FileMeta, expected: Option<&Checksum>, ) -> Result<Checksum>
Writes a symlink content object and returns its checksum.
A symlink object has no payload, so its identity is the SHA-256 of the framed header alone. The storage form follows the repository mode:
- In
bareandbare-user-only, a symlink. - In
bare-userandbare-user-shared, a regular file with mode0644that holds the target and one NUL. Theuser.ostreemetaxattr holds the logical metadata. - In
archive, a framed archive header with no payload.
§Mode
If meta.mode names a symlink, the object records it unchanged, with
its permission bits. If meta.mode names a regular file or no file
type, the object records S_IFLNK | 0o777. Any other file type fails
the write.
§Errors
Error::Unsupportedif the repository mode isbare-split-xattrs, which ostrya does not write.Error::Unsupportedif[ex-integrity] fsverityisyes, the object is stored as a regular file, and the fs-verity seal fails.Error::ChecksumMismatchifexpectedis given and differs from the computed checksum.Error::InsufficientFreeSpaceif the object needs more space than the free-space budget of the transaction holds.Error::Coreifmeta.modenames a file type other than a symlink or a regular file, or iftargetholds a NUL byte.Error::Coreif[core] fsyncor[core] per-object-fsyncin the repository config is malformed.Error::InvalidFormatif[ex-integrity] fsverityor[ex-integrity] composefsin the repository config is malformed.Error::InvalidFormatif the repository is inbaremode and an xattr name inmetais not valid UTF-8.Error::Ioif a file system operation fails.
Sourcepub async fn write_dirmeta(&self, meta: &DirMeta) -> Result<Checksum>
pub async fn write_dirmeta(&self, meta: &DirMeta) -> Result<Checksum>
Writes a directory-metadata object for meta and returns its checksum.
The object records what the repository mode stores for a directory.
bare-user-only discards the ownership and the xattrs, and it reduces
the permission bits as for a regular file. A commit into such a
repository records this canonical form, and the identity of the
dirmeta covers it. Each other mode records meta unchanged.
A commit uses this path for its own directories. A caller that builds a tree uses it too.
A caller can serialize a DirMeta and give the bytes to
write_metadata. The object then stores
the form that meta states, with the checksum of that form. In a
bare-user-only repository, this checksum differs from the checksum
that the repository records for the same directory.
A dirmeta from another source, for example a pull or a static delta,
keeps the bytes that its checksum names. It goes through
write_metadata.
§Errors
Error::Unsupportedif the repository mode isbare-split-xattrs, or if[ex-integrity] fsverityisyesand the fs-verity seal fails.Error::InsufficientFreeSpaceif the object needs more space than the free-space budget of the transaction holds.Error::Coreif the file-type bits ofmeta.modeare not the directory type, or if a[core]value in the repository config is malformed.Error::InvalidFormatif[ex-integrity] fsverityor[ex-integrity] composefsin the repository config is malformed.Error::Ioif a file system operation fails.
Sourcepub async fn write_metadata(
&self,
ty: ObjectType,
expected: Option<&Checksum>,
bytes: &[u8],
) -> Result<Checksum>
pub async fn write_metadata( &self, ty: ObjectType, expected: Option<&Checksum>, bytes: &[u8], ) -> Result<Checksum>
Writes a metadata object from its serialized bytes in normal form.
The identity is the SHA-256 of bytes. The call returns the checksum
of the object.
The call checks no entry of field 2 of a commit.
write_commit checks them, and
write_commit_checked writes the
entries that check_related checked.
The call does not record a commit as complete, because a pull writes
partial commits through it. So a commit that it writes gets no
composefs image under [ex-ostrya] generate-composefs. A caller that
writes a complete commit uses
write_commit_checked.
§Errors
Error::Unsupportedif the repository mode isbare-split-xattrs, or iftyis not a metadata object type.Error::Unsupportedif[ex-integrity] fsverityisyesand the fs-verity seal fails.Error::ChecksumMismatchifexpectedis given and differs from the computed checksum.Error::InsufficientFreeSpaceif the object needs more space than the free-space budget of the transaction holds.Error::Coreif[core] fsyncor[core] per-object-fsyncin the repository config is malformed.Error::InvalidFormatif[ex-integrity] fsverityor[ex-integrity] composefsin the repository config is malformed.Error::Ioif a file system operation fails.
Auto Trait Implementations§
impl !Freeze for Transaction
impl Forget for Transaction
impl RefUnwindSafe for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnsafeUnpin for Transaction
impl UnwindSafe for Transaction
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.