jacereda / fsatrace

Filesystem access tracer
ISC License
78 stars 12 forks source link

Removing a symlink looks like removing its target #41

Open fangism opened 3 years ago

fangism commented 3 years ago

Removing a symbolic link looks like removing the link's destination (but perhaps should not?).

Demonstration:

$ touch foo
$ ln -s foo bar
$ fsatrace erwdtmq /dev/stdout -- rm -f bar
r|/usr/bin/rm
q|/home/fangism/foo
d|/home/fangism/foo

Destination foo is unaffected.

I expected something more like:

r|/usr/bin/rm
q|/home/fangism/bar
d|/home/fangism/bar
fangism commented 3 years ago

This is on linux. Not sure if it looks the same on other platforms.

jacereda commented 3 years ago

What would be the expected behaviour from a build system perspective? I would assume queries/reads should follow symlinks but deletes shouldn't, what do you think?

jacereda commented 3 years ago

@fangism ping

fangism commented 3 years ago

[Sorry, I've been out for a few weeks.]

From the original comment, this might seem more reasonable:

$ touch foo
$ ln -s foo bar
$ fsatrace erwdtmq /dev/stdout -- rm -f bar
r|/usr/bin/rm
q|/home/fangism/bar
d|/home/fangism/bar

But I haven't dug into the details of how operations on symlinks are traced.

jacereda commented 3 years ago

If queries/reads don't follow symlinks that would put a burden on the build system. The one I'm using would certainly need to be modified to take into account this fact.

I propose to report the symlink only when deleting, reporting the linked file elsewhere. Do you have any example of a situation where this would be a problem in a build system?

fangism commented 3 years ago

Using the above rm example, what would your proposed trace look like?

jacereda commented 3 years ago
r|/usr/bin/rm
q|/home/fangism/foo
d|/home/fangism/bar
fangism commented 3 years ago
r|/usr/bin/rm
q|/home/fangism/foo
d|/home/fangism/bar

This is an improvement, and should let us proceed further.