4 ms·
ununlink would be pretty useful. Then again, this kind of exists; I have fond memories of a panicky younger me struggling with undelete in DOS.
by ultrarunner 7y ago
ununlink would be pretty useful. Then again, this kind of exists; I have fond memories of a panicky younger me struggling with undelete in DOS.
- marcan_42 7y agoununlink 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.