4 ms·
ununlink is link() on a /proc/<pid>/fd/<fd> entry. Assuming some process still has the file open, that is.
by marcan_42 7y ago
ununlink is link() on a /proc/<pid>/fd/<fd> entry. Assuming some process still has the file open, that is.
- coldtea 7y agoDoes that mean that one could implement "undelete" by changing open() so that some central process (let's call it "recycle-bin") also opens a copy at the same time a process opens them (but keeps it open until you send it a "empty" signal), and then calling that link()?
- wichert 7y agoYou could use LD_PRELOAD to replace unlink with a version that passes an fd to a running recycle-bin daemon. That approach doesn't really have much, or any, advantage over just moving files to a recycle-bin folder and keeping track of items in there.
- jwilk 7y agolink() doesn't work for this use case. You need linkat() with the AT_SYMLINK_FOLLOW flag enabled.