fatrace icon indicating copy to clipboard operation
fatrace copied to clipboard

Failed to add watch for /: No such device

Open step- opened this issue 10 months ago • 0 comments

Running fatrace -C touch as root on kernel 6.1.46:

fatrace: Failed to add watch for /: No such device

Running strace fatrace I can better see the error:

fanotify_mark(3, FAN_MARK_ADD|FAN_MARK_FILESYSTEM, FAN_ACCESS|FAN_MODIFY|FAN_CLOSE_WRITE|FAN_CLOSE_NOWRITE|FAN_OPEN|FAN_MOVED_FROM|FAN_MOVED_TO|FAN_CREATE|FAN_DELETE|FAN_ONDIR|FAN_EVENT_ON_CHILD, AT_FDCWD, "/") = -1 ENODEV (No such device)

On this system, "/" is a mount point which using aufs file system. cat /proc/mounts:

proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
devtmpfs /dev devtmpfs rw,relatime,size=8030144k,nr_inodes=2007536,mode=755 0 0
/dev/loop0 /aufs/kernel-modules squashfs ro,relatime,errors=continue 0 0
/dev/loop1 /aufs/pup_ro squashfs ro,relatime,errors=continue 0 0
/dev/sdc2 /aufs/devsave ext4 rw,relatime 0 0
aufs / aufs rw,relatime,si=736d9d04cb017ae1 0 0
devpts /dev/pts devpts rw,relatime,gid=3,mode=620,ptmxmode=000 0 0
tmpfs /dev/shm tmpfs rw,relatime,mode=777 0 0
tmpfs /tmp tmpfs rw,relatime 0 0
cgroup /sys/fs/cgroup cgroup rw,relatime,cpuset,cpu,cpuacct,blkio,memory,devices,freezer,net_cls,perf_event,net_prio,pids,misc 0 0
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
/dev/sdb3 /mnt/l ext4 rw,relatime 0 0

So I tried changing https://github.com/martinpitt/fatrace/blob/12b9db2d53e4912bb24a692ebd7932ba2dc5ff02/fatrace.c#L347

from

    if (res < 0 && errno == EINVAL && mark_mode & FAN_MARK_FILESYSTEM)

to

    if (res < 0 && ((errno == EINVAL && mark_mode & FAN_MARK_FILESYSTEM) || errno == ENODEV))

Then ran fatrace -C touch again but things got worse. In addition to "/", now aufs and ext4 mounted file systems (their mount points) and device loops are reported:

fatrace: Failed to add watch for /: Invalid argument
fatrace: Failed to add watch for /aufs/kernel-modules: Invalid argument
fatrace: Failed to add watch for /aufs/pup_ro: Invalid argument
fatrace: Failed to add watch for /aufs/devsave: Invalid argument
fatrace: Failed to add watch for /mnt/l: Invalid argument

step- avatar Apr 17 '24 14:04 step-