Expand description
zub - git-like object tree
a content-addressed filesystem store for rootfs fragments with git-like semantics. similar in spirit to ostree but simpler, designed for composing Linux system images.
§Core concepts
- Blob: content-addressed file data (compressed with zstd)
- Tree: a serialized directory structure (CBOR + zstd)
- Commit: a snapshot of a tree with metadata (CBOR + zstd)
- Ref: a named pointer to a commit (hierarchical, like git branches)
§Hash format
blob hash = SHA256(uid | gid | mode | xattr_count | xattrs… | content)
where xattrs are sorted by name and each is: name_len | name | value_len | value
§Example usage
use zub::{Repo, ops};
use std::path::Path;
// initialize a repository
let repo = Repo::init(Path::new("/path/to/repo")).unwrap();
// commit a directory
let hash = ops::commit(&repo, Path::new("/source"), "my/ref", Some("initial commit"), None).unwrap();
// checkout to a directory
ops::checkout(&repo, "my/ref", Path::new("/destination"), ops::CheckoutOptions::default()).unwrap();Re-exports§
pub use ops::du;pub use ops::stats;pub use ops::truncate_history;pub use ops::RefSize;pub use ops::RepoStats;pub use ops::TruncateStats;pub use types::ChangeKind;pub use types::Commit;pub use types::DiffEntry;pub use types::EntryKind;pub use types::SparseRegion;pub use types::Tree;pub use types::TreeEntry;pub use types::Xattr;
Modules§
Structs§
- Config
- repository configuration stored in config.toml
- Hash
- SHA-256 hash used for content addressing
- MapEntry
- a single range in a uid/gid mapping
- NsConfig
- namespace configuration with uid and gid mappings
- Repo
- a zub repository
Enums§
- Error
- error type for zuboperations
Functions§
- blob_
exists - check if a blob exists in the object store
- commit_
path - get the filesystem path to a commit object
- compute_
blob_ hash - compute blob hash over (uid, gid, mode, xattrs, content)
- current_
gid_ map - read current process gid map from /proc/self/gid_map
- current_
uid_ map - read current process uid map from /proc/self/uid_map
- delete_
ref - delete a ref
- delete_
refs_ matching - delete refs matching a glob pattern, returns list of deleted refs
- inside_
to_ outside - convert inside (logical namespace) id to outside (on-disk) id
- list_
refs - list all refs
- list_
refs_ matching - list refs matching a glob pattern
- mappings_
equal - check if two namespace configs are equivalent (same mappings)
- outside_
to_ inside - convert outside (on-disk) id to inside (logical namespace) id
- parse_
id_ map - parse /proc/self/uid_map or gid_map format format: “inside_start outside_start count” per line, whitespace separated
- read_
blob - read blob content
- read_
commit - read a commit from the object store
- read_
ref - read a ref
- read_
tree - read a tree from the object store
- ref_
exists - check if a ref exists
- remap
- remap an id from one namespace to another old_outside -> inside (via old_map) -> new_outside (via new_map)
- resolve_
ref - resolve a ref or hash string to a hash
- tree_
path - get the filesystem path to a tree object
- write_
blob - write a blob to the object store
- write_
commit - write a commit to the object store
- write_
ref - write a ref (create or update)
- write_
tree - write a tree to the object store