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.
30 lines
620 B
C
30 lines
620 B
C
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "test_helpers.h"
|
|
|
|
int main(void) {
|
|
FILE *fp = fopen("stdio/fread.in", "rb");
|
|
ERROR_IF(fopen, fp, == NULL);
|
|
|
|
char buf[33] = { 0 };
|
|
for (int i = 1; i <= 32; ++i) {
|
|
size_t nread = fread(buf, 1, i, fp);
|
|
if (nread == 0) {
|
|
if (feof(fp)) {
|
|
fprintf(stderr, "early EOF\n");
|
|
return EXIT_FAILURE;
|
|
} else {
|
|
perror("fread");
|
|
return EXIT_FAILURE;
|
|
}
|
|
}
|
|
buf[i] = 0;
|
|
|
|
printf("%s\n", buf);
|
|
}
|
|
|
|
fclose(fp);
|
|
}
|