feat(gpt): gpt_write_one -- a new disk of one partition, for the real Zuse's stick (#92, 4.3) [skip ci]
The old MBR zeroed first, the backup header and entries, the primary, the protective MBR last: a write torn anywhere leaves no table. Builds clean on amd64, aarch64, riscv64; checked on the host against blank 600 MiB and 32 MiB images and a used Zuse stick (sfdisk --verify clean, gpt_read reads it back). Not yet called. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GE3SDvQn5EoxdGufk84zz2
This commit is contained in:
@@ -49,6 +49,16 @@ uint64_t gpt_alternate_lba(void);
|
||||
* sector); GPT_BAD or GPT_EIO otherwise. */
|
||||
int gpt_grow_last(blkio_dev_t *disk, const uint8_t type[16], uint64_t max_part_sectors, uint64_t *new_last_lba);
|
||||
|
||||
/* Write a new GPT on `disk` with one partition of `type` (plan
|
||||
* 2026-10-29-stick-5, Task 4: the real Zuse's stick): at LBA 2048, at most
|
||||
* `part_sectors` long (on a whole MiB, no further than the disk allows), a
|
||||
* fresh DiskGUID (into `disk_guid`) and partition GUID from the RNG, 128
|
||||
* entries, the backup header and entries at the disk's end, the protective
|
||||
* MBR written last (the old one zeroed first, so a write torn anywhere leaves
|
||||
* no table). Nothing inside the partition is written. GPT_OK; GPT_BAD for a
|
||||
* disk whose sectors are not 512 bytes or that is too small; GPT_EIO. */
|
||||
int gpt_write_one(blkio_dev_t *disk, const uint8_t type[16], uint64_t part_sectors, uint8_t disk_guid[16]);
|
||||
|
||||
/* The index of the first partition of `type`, or -1. */
|
||||
int gpt_find(const gpt_part_t *parts, unsigned count, const uint8_t type[16]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user