Re: Is there a reason hard links from /proc/$PID/fd/$NUM aredisallowed?

From: Al Viro
Date: Sun Dec 04 2011 - 16:00:27 EST


On Sun, Dec 04, 2011 at 03:40:44PM -0500, George Spelvin wrote:
> I was trying to save a large file that was in mid-download that I had
> accidentally deleted (as part of making space in /tmp to hold the file!).
>
> Since it was being held open by the download process, I tried
>
> ln /proc/$PID/fd/$FD /tmp/bigfile.mp4

You do realize that link(2) does *NOT* follow links, do you? linkat(2)
does, if you explicitly ask for that:

linkat(AT_FDCWD, "/proc/42/fd/1", AT_FDCWD, "/tmp/foo", AT_SYMLINK_FOLLOW)

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