fsatrace icon indicating copy to clipboard operation
fsatrace copied to clipboard

Removing a symlink looks like removing its target

Open fangism opened this issue 3 years ago • 8 comments

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 avatar Mar 15 '21 16:03 fangism

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

fangism avatar Mar 15 '21 17:03 fangism

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 avatar Mar 25 '21 21:03 jacereda

@fangism ping

jacereda avatar Apr 04 '21 20:04 jacereda

[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.

fangism avatar Apr 04 '21 23:04 fangism

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?

jacereda avatar Apr 05 '21 08:04 jacereda

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

fangism avatar Apr 05 '21 16:04 fangism

r|/usr/bin/rm
q|/home/fangism/foo
d|/home/fangism/bar

jacereda avatar Apr 05 '21 16:04 jacereda

r|/usr/bin/rm
q|/home/fangism/foo
d|/home/fangism/bar

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

fangism avatar Apr 05 '21 17:04 fangism