Skip to main content

Crate zub

Crate zub 

Source
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§

fs
ops
high-level operations on zub repositories
transport
transport layer for remote operations
types

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

Type Aliases§

Result