Re: rm-ing files with open file descriptors

Matthias Schniedermeyer (ms@citd.de)
Sat, 19 Jan 2002 13:16:00 +0100


> > Well no. new_fd will refer to a completely new, empty file
> > which has no relation to the old file at all.
> >
> > There is no way to recreate a file with a nlink count of 0,
> > well that is until someone adds flink(fd, newpath) to the kernel.
> >
>
> This *might* work:
>
> link("/proc/self/fd/40", newpath);

cat /proc/<id>/fd/<nr> > whatever
actually works.

"Even Better(tm)" would be if
ln /proc/<id>/fd/<nr> whatever
or
ln <Inode> whatever (lsof delivers the needed Inode-nr)
would work.

Otherwise you have a problem to recover files when you have insufficent
disc space. Imagine a file that is 1GB in size and you have 512MB left
on the hdd. Currently i don't see a chance to recover such a file
without problems.

Bis denn

-- 
Real Programmers consider "what you see is what you get" to be just as 
bad a concept in Text Editors as it is in women. No, the Real Programmer
wants a "you asked for it, you got it" text editor -- complicated, 
cryptic, powerful, unforgiving, dangerous.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/