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
939 B
C
43 lines
939 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdbool.h>
|
|
#include <string.h>
|
|
#include <grp.h>
|
|
|
|
void test_getgrnam(const char *gr_name) {
|
|
struct group* out = getgrnam(gr_name);
|
|
|
|
if (out == NULL) {
|
|
printf("Did not find a group '%s'\n", gr_name);
|
|
return;
|
|
}
|
|
|
|
printf("getgrnam\n");
|
|
|
|
printf(" '%s' = %d\n", gr_name, out->gr_gid);
|
|
}
|
|
|
|
void test_getgrnam_r(const char *gr_name) {
|
|
char buf[100];
|
|
|
|
struct group grp;
|
|
struct group* out = &grp;
|
|
|
|
int status = getgrnam_r(gr_name, &grp, buf, sizeof(buf), &out);
|
|
|
|
if (out == NULL) {
|
|
const char *reason = (status != 0) ? strerror(status) : "(not found)";
|
|
printf("Did not find a group %s: %s\n", gr_name, reason);
|
|
return;
|
|
}
|
|
|
|
printf("getgrnam_r\n");
|
|
|
|
printf(" '%s' = %d\n", gr_name, out->gr_gid);
|
|
}
|
|
|
|
int main(void) {
|
|
test_getgrnam("lcake");
|
|
test_getgrnam_r("lcake");
|
|
}
|