error handling for non-loaded module

This commit is contained in:
twoneis 2025-04-04 00:43:22 +02:00
parent c80333a19f
commit c73b587078

View file

@ -9,9 +9,10 @@
#include "pipe_utils.c" #include "pipe_utils.c"
#define LKM_DEVICE "/dev/lkm"
// where does this come from? // where does this come from?
#define OBJS_PER_SLAB 42 #define OBJS_PER_SLAB 42
#define PIPE_BUFFER (OBJS_PER_SLAB * 10) #define PIPE_BUFFER (OBJS_PER_SLAB * 10)
int pipes[PIPE_BUFFER][2]; int pipes[PIPE_BUFFER][2];
@ -20,9 +21,15 @@ int
main(void) main(void)
{ {
printf("main: start\n"); printf("main: start\n");
FILE *device = fopen("/dev/lkm", "r+"); FILE *device = fopen(LKM_DEVICE, "r+");
printf("main: fopen: %p\n", device); printf("main: fopen: %p\n", device);
if (!device) {
printf(
"main: fopen: Error opening %s. Make sure the kernel module is loaded\n",
LKM_DEVICE);
exit(1);
}
printf("main: draining lower page free lists: %u objects\n", printf("main: draining lower page free lists: %u objects\n",
PIPE_BUFFER); PIPE_BUFFER);