inotify: implement inotify fd I/O decoding support

* defs.h (decode_inotify_read): New declaration.
* inotify.c: Include "print_fields.h".
(decode_inotify_read): New function.
* io.c (decode_readbuf) <decoders>: Add decoder for anon_inode:inotify.
This commit is contained in:
Eugene Syromyatnikov
2018-09-25 12:18:23 +02:00
parent 78fd3aa2b8
commit 8015a74269
3 changed files with 62 additions and 0 deletions

3
defs.h
View File

@ -418,6 +418,9 @@ extern bool decode_fanotify_read(struct tcb *tcp, int fd, const char *fdpath,
extern bool decode_fanotify_write(struct tcb *tcp, int fd, const char *fdpath,
enum fileops op, kernel_ulong_t addr,
kernel_ulong_t addrlen);
extern bool decode_inotify_read(struct tcb *tcp, int fd, const char *fdpath,
enum fileops op, kernel_ulong_t addr,
kernel_ulong_t addrlen);
enum iov_decode {
IOV_DECODE_ADDR,

View File

@ -29,9 +29,67 @@
#include "defs.h"
#include <fcntl.h>
#include "print_fields.h"
#include "xlat/inotify_flags.h"
#include "xlat/inotify_init_flags.h"
bool
decode_inotify_read(struct tcb *tcp, int fd, const char *fdpath,
enum fileops op, kernel_ulong_t addr,
kernel_ulong_t addrlen)
{
struct iev_hdr {
int32_t wd;
uint32_t mask;
uint32_t cookie;
uint32_t len;
} iev_hdr;
kernel_ulong_t pos = 0;
if (addrlen < sizeof(iev_hdr))
return false;
tprints("[");
do {
if (pos)
tprints(", ");
if (umove(tcp, addr + pos, &iev_hdr)) {
printaddr_comment(addr + pos);
break;
}
PRINT_FIELD_D("{", iev_hdr, wd);
PRINT_FIELD_FLAGS(", ", iev_hdr, mask, inotify_flags, "IN_???");
PRINT_FIELD_U(", ", iev_hdr, cookie);
PRINT_FIELD_U(", ", iev_hdr, len);
pos += sizeof(iev_hdr);
if (iev_hdr.len) {
tprints(", name=");
printstrn(tcp, addr + pos, iev_hdr.len);
pos += iev_hdr.len;
}
tprints("}");
} while (pos <= addrlen - sizeof(iev_hdr));
if (pos < addrlen) {
if (pos)
tprints(", ");
printstrn(tcp, addr + pos, addrlen - pos);
}
tprints("]");
return true;
}
SYS_FUNC(inotify_add_watch)
{
/* file descriptor */

1
io.c
View File

@ -74,6 +74,7 @@ decode_readbuf(struct tcb *const tcp, const int fd, const kernel_ulong_t addr,
{
static const struct filebuf_decoder_desc decoders[] = {
{ "anon_inode:\\[fanotify\\]", decode_fanotify_read },
{ "anon_inode:inotify", decode_inotify_read },
};
decode_filebuf(tcp, fd, addr, addrlen, ARRSZ_PAIR(decoders),