wip(kernel): Artemis grows to fill the stick at its first boot -- metadata only, capped at 256 GiB (#92, Task 2) [skip ci]
Not yet accepted (plan 2026-10-29-stick-5, Task 2, step 3). - gpt.c: the writer, gpt_grow_last() -- the backup entry array and header to the disk's end, the last partition to the last usable sector (whole MiB, capped), both headers' CRCs, the backup before the primary, the protective MBR's size; gpt_alternate_lba(). - sk_v4_grow.c: the volume grown to its partition -- its fence (the Artemis signature, Zuse's genesis marker) moved to the new top, the header last; the partition grown no further than the BAM tracks (the block subsystem places the fence by the device's size, so a volume must fill it). - sk_v4_identity.c: a stick of 8 GB or more whose GPT ends short of the disk is grown before its partitions are opened; "Artemis: grown to fill the stick" / "under 8 GB -- not grown" / "past 256 GiB ... left unused". - block_subsystem: blk_volume_compute_totals() (compute_totals_from_B, public) and blk_subsys_set_format_bam_for(); v3's behaviour unchanged. - mkartemis --bam-for, mkdiskimage.sh --bam-for, kernel/Makefile STICK_GROW_MIN_BYTES / STICK_ARTEMIS_CAP_GIB: the stick's and data stick's Artemis BAM sized for 256 GiB (6144 devblocks). STICK.md 5a: 256 GiB (R1). After: stick_grow PASS (16 GiB: 12129370 user blocks, 8 s POST to prompt; second boot not grown, recognised; sfdisk --verify: no errors), stick_small PASS, check_images.sh PASS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GE3SDvQn5EoxdGufk84zz2
This commit is contained in:
+22
-6
@@ -10,10 +10,14 @@
|
||||
* kernel writes. Zuse's genesis marker is not written: the first boot does
|
||||
* that. docs/v4.0.0/plans/2026-10-27-stick-3-images.md.
|
||||
*
|
||||
* mkartemis --format IMG --first-lba L --sectors N
|
||||
* mkartemis --format IMG --first-lba L --sectors N [--bam-for M]
|
||||
* mkartemis --check IMG --first-lba L --sectors N
|
||||
*
|
||||
* L and N count 512-byte sectors; both must be even (1 KiB blocks).
|
||||
* L, N and M count 512-byte sectors; L and N must be even (1 KiB blocks).
|
||||
* --bam-for M sizes the volume's BAM as for a volume of M sectors, so it can
|
||||
* grow that far on a larger stick with no BAM to move (docs/v4.0.0/STICK.md
|
||||
* 5a; plan 2026-10-29-stick-5, R1 and Task 2). --check reports the BAM's
|
||||
* size in 4 KiB devblocks.
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
@@ -111,7 +115,7 @@ static uint8_t g_ram[(size_t)BLK_RAM_BLOCKS * BLK_FORTH_SIZE];
|
||||
|
||||
static int usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: mkartemis --format|--check IMG --first-lba L --sectors N\n");
|
||||
fprintf(stderr, "usage: mkartemis --format|--check IMG --first-lba L --sectors N [--bam-for M]\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -140,6 +144,8 @@ static int attach(blkio_dev_t *dev, uint32_t *start_lbn, uint32_t *count)
|
||||
* header is read from the disk itself and judged as attach judges it
|
||||
* (block_subsystem.c blk_format_or_load_disk): blk_get_volume_meta would give
|
||||
* the geometry computed in memory for a blank disk, magic and all. */
|
||||
static uint32_t g_bam_devblocks; /* the BAM's size, as check_volume read it */
|
||||
|
||||
static int check_volume(blkio_dev_t *dev, uint32_t *count, artemis_sig_t *sig)
|
||||
{
|
||||
static uint8_t hdr[BLK_DEVICE_SECTOR];
|
||||
@@ -160,6 +166,7 @@ static int check_volume(blkio_dev_t *dev, uint32_t *count, artemis_sig_t *sig)
|
||||
fprintf(stderr, "mkartemis: the Artemis signature does not check out (%d)\n", (int)src);
|
||||
else
|
||||
rc = 0;
|
||||
g_bam_devblocks = meta.bam_devblocks;
|
||||
blk_subsys_shutdown();
|
||||
return rc;
|
||||
}
|
||||
@@ -167,7 +174,7 @@ static int check_volume(blkio_dev_t *dev, uint32_t *count, artemis_sig_t *sig)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *mode, *img;
|
||||
unsigned long long first_lba, sectors;
|
||||
unsigned long long first_lba, sectors, bam_for = 0;
|
||||
range_t r;
|
||||
blkio_dev_t dev;
|
||||
blkio_params_t params;
|
||||
@@ -175,7 +182,8 @@ int main(int argc, char **argv)
|
||||
artemis_sig_t sig;
|
||||
int i, format;
|
||||
|
||||
if (argc != 7 || strcmp(argv[3], "--first-lba") != 0 || strcmp(argv[5], "--sectors") != 0) return usage();
|
||||
if ((argc != 7 && argc != 9) || strcmp(argv[3], "--first-lba") != 0 || strcmp(argv[5], "--sectors") != 0)
|
||||
return usage();
|
||||
mode = argv[1];
|
||||
img = argv[2];
|
||||
if (strcmp(mode, "--format") == 0) format = 1;
|
||||
@@ -185,6 +193,12 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "mkartemis: --first-lba and --sectors take a number of sectors\n");
|
||||
return 1;
|
||||
}
|
||||
if (argc == 9) {
|
||||
if (!format || strcmp(argv[7], "--bam-for") != 0 || parse_count(argv[8], &bam_for) != 0 || bam_for < sectors) {
|
||||
fprintf(stderr, "mkartemis: --bam-for takes a number of sectors, at least --sectors, with --format\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (first_lba % 2u != 0u || sectors % 2u != 0u || sectors == 0u || sectors / 2u > 0xFFFFFFFFull) {
|
||||
fprintf(stderr, "mkartemis: the partition must start and end on a 1 KiB block (even LBA and sector count)\n");
|
||||
return 1;
|
||||
@@ -202,6 +216,7 @@ int main(int argc, char **argv)
|
||||
|
||||
sf_time_init();
|
||||
if (format) {
|
||||
blk_subsys_set_format_bam_for(bam_for / 8u); /* sectors -> 4 KiB devblocks */
|
||||
if (attach(&dev, &start_lbn, &count) != 0) return 1;
|
||||
if (artemis_sig_check(&dev, &sig) != ARTEMIS_SIG_BLANK) {
|
||||
fprintf(stderr, "mkartemis: the partition is not blank -- not formatted\n");
|
||||
@@ -221,7 +236,8 @@ int main(int argc, char **argv)
|
||||
printf("mkartemis: formatted %u blocks, STFR v2, signature stamped, read back ok\n", r.blocks);
|
||||
} else {
|
||||
if (check_volume(&dev, &count, &sig) != 0) return 1;
|
||||
printf("mkartemis: STFR v2, %u user blocks, signature ok, disk_uuid ", count);
|
||||
printf("mkartemis: STFR v2, %u user blocks, bam %u devblocks, signature ok, disk_uuid ",
|
||||
count, g_bam_devblocks);
|
||||
for (i = 0; i < 16; i++) printf("%02x", sig.disk_uuid[i]);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user