doos 1.0.0: images, size cap, subuid ids, working apt in host mode

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-23 21:41:28 +02:00
co-authored by Claude Sonnet 5.5
parent fdb96c7b1c
commit d446c29372
24 changed files with 1709 additions and 142 deletions
+26
View File
@@ -1,8 +1,10 @@
#pragma once
#include <cerrno>
#include <cstdint>
#include <filesystem>
#include <stdexcept>
#include <string>
#include <vector>
namespace doos {
@@ -45,7 +47,31 @@ private:
Fd fd_;
};
// Parses "512m", "2g", "1t" (k/m/g/t, optional trailing b) into bytes; throws on garbage.
std::uint64_t parseSize(const std::string& text);
std::string formatSize(std::uint64_t bytes);
struct ProcResult {
int code = -1;
std::string out; // stdout, only when captured
};
// fork+exec without a shell. Captured output is capped; stderr is inherited unless quiet.
ProcResult runProcess(const std::vector<std::string>& argv, bool capture = false, bool quiet = false);
namespace fsutil {
struct SeedStats {
std::size_t made = 0;
std::size_t skipped = 0; // unreadable or unsupported entries, never silent
std::uint64_t bytes = 0;
};
// Creates every directory of `lower` in `upper` (owner rwx added) so a unmapped-owner lower stays writable.
SeedStats mirrorDirs(const std::filesystem::path& lower, const std::filesystem::path& upper);
// Copies dirs, regular files and symlinks readable by the caller. Capped by spec.hpp limits.
SeedStats copyTree(const std::filesystem::path& from, const std::filesystem::path& to);
// Copies only the regular files directly inside `from` (readable ones) into `to`; existing targets stay.
SeedStats copyFiles(const std::filesystem::path& from, const std::filesystem::path& to);
// Sum of allocated bytes (st_blocks) below p, lstat only. `skipped` counts unreadable dirs.
std::uint64_t diskUsage(const std::filesystem::path& p, std::size_t& skipped);
void mkdirs(const std::filesystem::path& p, mode_t mode = 0755);
void writeFile(const std::filesystem::path& p, const std::string& content);
std::string readFile(const std::filesystem::path& p);