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.
43 lines
922 B
C
43 lines
922 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdbool.h>
|
|
#include <string.h>
|
|
#include <grp.h>
|
|
|
|
void test_getgrgid(gid_t gid) {
|
|
struct group *out = getgrgid(gid);
|
|
|
|
if (out == NULL) {
|
|
printf("Did not find a group %d\n", gid);
|
|
return;
|
|
}
|
|
|
|
printf("getgrgid\n");
|
|
|
|
printf(" %d = %s, GID: %d\n", gid, out->gr_name, out->gr_gid);
|
|
}
|
|
|
|
void test_getgrgid_r(gid_t gid) {
|
|
char buf[100];
|
|
|
|
struct group grp;
|
|
struct group *tmp;
|
|
|
|
int status = getgrgid_r(gid, &grp, buf, sizeof(buf), &tmp);
|
|
|
|
if (tmp == NULL) {
|
|
const char *reason = status != 0 ? strerror(status) : "(not found)";
|
|
printf("Did not find a group %d: %s\n", gid, reason);
|
|
return;
|
|
}
|
|
|
|
printf("getgrgid_r\n");
|
|
|
|
printf(" %d = %s, GID: %d\n", gid, grp.gr_name, grp.gr_gid);
|
|
}
|
|
|
|
int main(void) {
|
|
test_getgrgid(1050);
|
|
test_getgrgid_r(1050);
|
|
}
|