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.
83 lines
1.5 KiB
C
83 lines
1.5 KiB
C
#include <signal.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <sys/wait.h>
|
|
#include "signals_list.h"
|
|
#include "../test_helpers.h"
|
|
|
|
// test killing a child process
|
|
|
|
void sig_handler (int signo) {
|
|
(void) signo;
|
|
exit(EXIT_SUCCESS);
|
|
}
|
|
|
|
int killpg_test2(int signum)
|
|
{
|
|
int child_pid, child_pgid;
|
|
printf("we are on signal %d\n ", signum);
|
|
|
|
if ((child_pid = fork()) == 0) {
|
|
/* child here */
|
|
struct sigaction act;
|
|
act.sa_handler=sig_handler;
|
|
act.sa_flags=0;
|
|
sigemptyset(&act.sa_mask);
|
|
sigaction(signum, &act, 0);
|
|
|
|
/* change child's process group id */
|
|
setpgrp();
|
|
|
|
sigpause(SIGABRT);
|
|
|
|
return EXIT_FAILURE;
|
|
} else {
|
|
/* parent here */
|
|
int i;
|
|
sigignore(signum);
|
|
|
|
usleep(100000);
|
|
|
|
child_pgid = getpgid(child_pid);
|
|
ERROR_IF(getpgid, child_pgid, == -1);
|
|
|
|
int status;
|
|
status = killpg(child_pgid, signum);
|
|
ERROR_IF(killpg, status, != 0);
|
|
|
|
status = wait(&i);
|
|
ERROR_IF(wait, status, == -1);
|
|
|
|
if (WEXITSTATUS(i) == EXIT_SUCCESS) {
|
|
printf("Child exited normally\n");
|
|
printf("Test PASSED\n");
|
|
return EXIT_SUCCESS;
|
|
} else {
|
|
printf("Child did not exit normally.\n");
|
|
printf("Test FAILED\n");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
}
|
|
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
int main(){
|
|
int x;
|
|
for (unsigned int i = 1; i < sizeof(signals_list)/sizeof(signals_list[0]); i++)
|
|
{
|
|
int sig = signals_list[i].signal;
|
|
if (sig == SIGKILL || sig == SIGSTOP || sig == SIGCHLD || sig == SIGINT || sig == SIGQUIT)
|
|
{
|
|
continue;
|
|
}
|
|
x = killpg_test2(sig);
|
|
if (x == EXIT_FAILURE){
|
|
return EXIT_FAILURE;
|
|
}
|
|
}
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|