b9874d0941
Add redbear-usb-storage-check in-guest binary that validates USB mass storage read and write I/O: discovers /scheme/disk/ devices, writes a test pattern to sector 2048, reads it back, verifies match, restores original content. Updates test-usb-storage-qemu.sh with write-proof verification step. Includes all accumulated Red Bear OS work: kernel patches, relibc patches, driver infrastructure, DRM/GPU, KDE recipes, firmware, validation tooling, build system hardening, and documentation.
32 lines
697 B
C
32 lines
697 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <malloc.h>
|
|
#include <string.h>
|
|
#include <assert.h>
|
|
|
|
int main(void) {
|
|
size_t request_size = 27;
|
|
char *ptr = (char *)malloc(request_size);
|
|
|
|
if (!ptr) {
|
|
fprintf(stderr, "Allocation failed\n");
|
|
return 1;
|
|
}
|
|
|
|
size_t actual_size = malloc_usable_size(ptr);
|
|
|
|
printf("malloc: %zu bytes\n", request_size);
|
|
printf("malloc_usable_size: %zu bytes\n", actual_size);
|
|
|
|
assert(actual_size >= request_size);
|
|
memset(ptr, 'A', actual_size);
|
|
ptr[actual_size - 1] = '\0';
|
|
|
|
assert(ptr[0] == 'A');
|
|
assert(ptr[actual_size - 2] == 'A');
|
|
assert(ptr[actual_size - 1] == '\0');
|
|
free(ptr);
|
|
|
|
return 0;
|
|
}
|