Zupt v2.1.2: add full-disk backup/restore, expand test suite, improve compression handling

- Introduced full-disk backup/restore (src/zupt_disk.c, ~530 LOC)
  - Backup: streams 4MB blocks with sparse detection and all codecs
  - Restore: per-block checksum validation for integrity
  - Supports password (-p), PQ hybrid (--pq), or no encryption
  - Real-time progress bar with throughput reporting (stderr)

- Implemented sparse detection (8-byte zero scan)
  - Zero blocks stored as STORE (near-zero overhead)

- Added disk-aware safeguards
  - ZUPT_FLAG_DISK_IMAGE prevents misuse with extract
  - Immediate failure on wrong password during first block decrypt

- Cross-platform device size detection
  - Linux: BLKGETSIZE64
  - macOS: DKIOCGETBLOCKCOUNT
  - Fallback: lseek

- Compression behavior
  - ~2928:1 on highly repetitive data
  - ~1.33:1 on random data (auto STORE fallback)

- Expanded test suite to 77 tests:
  - 11 VV unit
  - 13 NIST/RFC vectors
  - 22 regression
  - 14 multi-threaded
  - 10 post-quantum
  - 7 disk (normal, encrypted, PQ, sparse, LZHP, extreme compression, wrong-password)

Release stats:
- 74 files, 168KB, zero .o artifacts
- 77/77 tests passing
- Fully clean under ASAN + UBSan
This commit is contained in:
Cristian Cezar Moisés 2026-04-06 19:25:24 -03:00
commit 5fcb9977ad
7 changed files with 1010 additions and 9 deletions

View file

@ -30,7 +30,7 @@
#define zupt_mkdir(p) mkdir(p, 0755)
#endif
#define ZUPT_VERSION_STRING "2.1.1"
#define ZUPT_VERSION_STRING "2.1.2"
#define ZUPT_FORMAT_MAJOR 1
#define ZUPT_FORMAT_MINOR 4
@ -333,4 +333,18 @@ void zupt_format_size(uint64_t bytes, char *buf, size_t cap);
* Decompression of ALL codecs works on ALL architectures. */
uint16_t zupt_resolve_auto_codec(void);
/* ─── Full-Disk Backup/Restore ─── */
#define ZUPT_FLAG_DISK_IMAGE (1u << 6) /* Archive contains a raw disk/partition image */
/* Compress a raw block device or file as a disk image.
* Reads source in block_size chunks, detects zero/sparse regions,
* compresses non-zero blocks. Supports encryption + PQ. */
zupt_error_t zupt_disk_backup(const char *output_path, const char *source_path,
zupt_options_t *opts);
/* Restore a disk image archive to a block device or file.
* Writes blocks sequentially, restoring sparse regions as zeros. */
zupt_error_t zupt_disk_restore(const char *archive_path, const char *target_path,
zupt_options_t *opts);
#endif