42 lines
797 B
C
42 lines
797 B
C
#define _GNU_SOURCE
|
|
#include <sys/socket.h>
|
|
|
|
#include <fcntl.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
#include "pipe_utils.c"
|
|
|
|
#define LKM_DEVICE "/dev/lkm"
|
|
|
|
// where does this come from?
|
|
#define OBJS_PER_SLAB 42
|
|
#define PIPE_BUFFER (OBJS_PER_SLAB * 10)
|
|
|
|
int pipes[PIPE_BUFFER][2];
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
printf("main: start\n");
|
|
FILE *device = fopen(LKM_DEVICE, "r+");
|
|
|
|
printf("main: draining lower page free lists: %u objects\n",
|
|
PIPE_BUFFER);
|
|
for (size_t i = 0; i < PIPE_BUFFER; i++) {
|
|
allocation_primitive(pipes[i]);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
fclose(device);
|
|
printf("main: done\n");
|
|
}
|