-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_help.c
More file actions
40 lines (33 loc) · 776 Bytes
/
my_help.c
File metadata and controls
40 lines (33 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <unistd.h>
#include <assert.h>
#include <fcntl.h>
#include <time.h>
#include <sys/ioctl.h>
#define TRACER_ADD_PROCESS _IOW(_IOC_WRITE, 42, pid_t)
#define TRACER_REMOVE_PROCESS _IOW(_IOC_WRITE, 43, pid_t)
int main(int argc, char *argv[])
{
int rc;
pid_t pid;
int fd;
if (argc != 3) {
printf("aiurea argumente\n");
return 1;
}
fd = open("/dev/tracer", O_RDONLY);
pid = atoi(argv[2]);
if (!strncmp(argv[1], "ADD", 3))
rc = ioctl(fd, TRACER_ADD_PROCESS, pid);
else if (!strncmp(argv[1], "DEL", 3))
rc = ioctl(fd, TRACER_REMOVE_PROCESS, pid);
if (rc < 0) {
printf("helper-ul a crapat. n-a putut ioctl()\n");
return rc;
}
return 0;
}