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.
46 lines
878 B
C
46 lines
878 B
C
#include <pthread.h>
|
|
#include <signal.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include "../test_helpers.h"
|
|
|
|
//test with pthread_kill to kill a child process
|
|
|
|
void * thread_function(void *arg)
|
|
{
|
|
/* Does nothing */
|
|
(void) arg;
|
|
pthread_exit((void*)0);
|
|
|
|
/* To please some compilers */
|
|
return NULL;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
pthread_t child_thread;
|
|
pthread_t invalid_tid;
|
|
|
|
int rc;
|
|
|
|
rc = pthread_create(&child_thread, NULL,
|
|
thread_function, NULL);
|
|
ERROR_IF(pthread_create, rc, != 0);
|
|
|
|
rc = pthread_join(child_thread, NULL);
|
|
ERROR_IF(pthread_join, rc, != 0);
|
|
|
|
// Now the child_thread exited, it is an invalid tid
|
|
memcpy(&invalid_tid, &child_thread,
|
|
sizeof(pthread_t));
|
|
usleep(300);
|
|
|
|
int status;
|
|
status = pthread_kill(invalid_tid, 0);
|
|
ERROR_IF(pthread_kill, status, != ESRCH);
|
|
|
|
exit(EXIT_SUCCESS);
|
|
} |