summaryrefslogtreecommitdiff
path: root/inotify.c
blob: 03689b50c28493d633030fd79957c4888cdcc9f6 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "defs.h"
#include <fcntl.h>
#include <linux/inotify.h>

static const struct xlat inotify_flags[] = {
	XLAT(IN_ACCESS),
	XLAT(IN_MODIFY),
	XLAT(IN_ATTRIB),
	XLAT(IN_CLOSE),
	XLAT(IN_CLOSE_WRITE),
	XLAT(IN_CLOSE_NOWRITE),
	XLAT(IN_OPEN),
	XLAT(IN_MOVE),
	XLAT(IN_MOVED_FROM),
	XLAT(IN_MOVED_TO),
	XLAT(IN_CREATE),
	XLAT(IN_DELETE),
	XLAT(IN_DELETE_SELF),
	XLAT(IN_MOVE_SELF),
	XLAT(IN_UNMOUNT),
	XLAT(IN_Q_OVERFLOW),
	XLAT(IN_IGNORED),
	XLAT(IN_ONLYDIR),
	XLAT(IN_DONT_FOLLOW),
	XLAT(IN_EXCL_UNLINK),
	XLAT(IN_MASK_ADD),
	XLAT(IN_ISDIR),
	XLAT(IN_ONESHOT),
	XLAT_END
};

static const struct xlat inotify_init_flags[] = {
	XLAT(O_NONBLOCK),
	XLAT(O_CLOEXEC),
	XLAT_END
};

int
sys_inotify_add_watch(struct tcb *tcp)
{
	if (entering(tcp)) {
		/* file descriptor */
		printfd(tcp, tcp->u_arg[0]);
		tprints(", ");
		/* pathname */
		printpath(tcp, tcp->u_arg[1]);
		tprints(", ");
		/* mask */
		printflags(inotify_flags, tcp->u_arg[2], "IN_???");
	}
	return 0;
}

int
sys_inotify_rm_watch(struct tcb *tcp)
{
	if (entering(tcp)) {
		/* file descriptor */
		printfd(tcp, tcp->u_arg[0]);
		/* watch descriptor */
		tprintf(", %d", (int) tcp->u_arg[1]);
	}
	return 0;
}

int
sys_inotify_init1(struct tcb *tcp)
{
	if (entering(tcp))
		printflags(inotify_init_flags, tcp->u_arg[0], "IN_???");
	return 0;
}