From: Al Viro <viro@ZenIV.linux.org.uk>
To: Jesper Juhl <jj@chaosbits.net>
Cc: Richard Weinberger <richard@nod.at>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
linux-fsdevel@vger.kernel.org, linux-man@vger.kernel.org
Subject: Re: st_size of a symlink
Date: Mon, 23 Jul 2012 21:22:24 +0100 [thread overview]
Message-ID: <20120723202224.GH31729@ZenIV.linux.org.uk> (raw)
In-Reply-To: <alpine.LNX.2.00.1207231959410.1922@swampdragon.chaosbits.net>
On Mon, Jul 23, 2012 at 08:09:14PM +0200, Jesper Juhl wrote:
> So, from my point of view it looks like procfs is the one who has got it
> wrong.
> We should probably fix that (IMVHO).
Fix it _how_? Try to rename a binary you have running in a process.
Or rename its cwd. Or rename an opened file. Watch the corresponding
procfs symlink (still pointing to the swame object) change. With
no way to tell that some sucker had looked at st_size some time ago
and might get surprised by the change.
The fact is, st_size is just a useful hint for symlink target length.
It tells you the likely sufficient size of buffer. There's a reason
why readlink(2) returns what it returns; you *can't* rely on the
earlier lstat() results or, for that matter, any prior information.
If nothing else, I could rm that symlink and create a new one in
the meanwhile. You need to check what it had returned and deal with
insufficient buffer size. By retrying readlink() with bigger buffer.
With procfs there's just a few more ways the readlink() output can
change, that's all.
next prev parent reply other threads:[~2012-07-23 20:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-23 15:55 st_size of a symlink Richard Weinberger
[not found] ` <500D73FF.1070504-/L3Ra7n9ekc@public.gmane.org>
2012-07-23 18:09 ` Jesper Juhl
2012-07-23 20:22 ` Al Viro [this message]
[not found] ` <20120723202224.GH31729-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2012-07-23 20:47 ` Jesper Juhl
2012-07-23 22:07 ` Richard Weinberger
2012-07-23 23:13 ` Guillem Jover
[not found] ` <20120723231333.GA1299-v62vTE6/wQGgM1MOaoewpti2O/JbrIOy@public.gmane.org>
2012-07-24 10:16 ` Richard Weinberger
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=20120723202224.GH31729@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=jj@chaosbits.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=richard@nod.at \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).