From: "George Spelvin" <linux@horizon.com>
To: linux@horizon.com, viro@ZenIV.linux.org.uk
Cc: linux-kernel@vger.kernel.org
Subject: Re: Is there a reason hard links from /proc/$PID/fd/$NUM are disallowed?
Date: 4 Dec 2011 16:38:16 -0500 [thread overview]
Message-ID: <20111204213816.12121.qmail@science.horizon.com> (raw)
In-Reply-To: <20111204210027.GA2203@ZenIV.linux.org.uk>
> 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.
Thank you very much! What's embarrassing is that I actually *knew* that once.
That seems to change the error message.
cd /run/shm # A tmpfs directory
echo foo > foo
sleep 10000 < foo &
pid=$!
rm foo
strace ln -L /proc/$pid/fd/0 bar
produces:
stat64("/run/shm/bar", 0xbfb7b46c) = -1 ENOENT (No such file or directory)
stat64("/proc/25098/fd/0", {st_mode=S_IFREG|0644, st_size=4, ...}) = 0
linkat(AT_FDCWD, "/proc/25098/fd/0", AT_FDCWD, "/run/shm/bar", 1024) = -1 ENOENT
(No such file or directory)
(1024 is indeed AT_SYMLINK_FOLLOW)
It seems to work, however, if the file is *not* deleted first.
prev parent reply other threads:[~2011-12-04 21:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-04 20:40 Is there a reason hard links from /proc/$PID/fd/$NUM are disallowed? George Spelvin
2011-12-04 21:00 ` Al Viro
2011-12-04 21:38 ` George Spelvin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111204213816.12121.qmail@science.horizon.com \
--to=linux@horizon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.