From: Jamie Lokier <jamie@shareable.org>
To: Oleg Drokin <green@linuxhacker.ru>
Cc: linux-fsdevel@vger.kernel.org
Subject: VFS "stat light" fstatat, inconsistent *at() function interfaces
Date: Tue, 21 Apr 2009 11:20:44 +0100 [thread overview]
Message-ID: <20090421102044.GA566@shareable.org> (raw)
In-Reply-To: <C7E35AFE-52D3-436E-AC15-152EA33A007B@linuxhacker.ru>
Oleg Drokin wrote:
> Also it adds AT_STAT_SELF flag to mean that the stat should be
> executed not on a path, but on the passed filedecriptor itself.
Ok. See below.
> Jamie Lokier wrote:
>> ret = fstatat(fd, 0, &stat, AT_STAT_TYPE|AT_STAT_SIZE);
>> Where 0 in the path automatically means AT_STAT_SELF.
>> Or this?
>> ret = fstatat(fd, AT_STAT_SELF, &stat, AT_STAT_TYPE|AT_STAT_SIZE);
>> Where AT_STAT_SELF is defined as (const char *)-1 in system headers,
>> to better catch null pointer application bugs.
>
> While I think the last one might be attractive, we also need to think
> about compatibility, unaware kernels would return -EFAULT if you pass
> some nonsense as a path, which is much less useful than say nice EINVAL.
About compatibility, you might look at this in "man utimensat":
On Linux, futimens() is a library function implemented on top of the
utimensat() system call. To support this, the Linux utimensat() system
call implements a non-standard feature: if pathname is NULL, then the
call modifies the timestamps of the file referred to by the file
descriptor dirfd (which may refer to any type of file). Using this
feature, the call futimens(fd, times) is implemented as:
utimensat(fd, NULL, times, 0);
It's inconsistent to have AT_STAT_SELF for the stat-light call, but
NULL path for the utimensat() call (system call; Glibc hides it)
to mean the same thing, which is act on the passed file descriptor.
I think your scheme is better :-) And safer when an application passes
NULL due to programming eror. But it is inconsistent.
It would be nice if they weren't, or if they used a common flag, in
the same way that other flags like AT_SYMLINK_NOFOLLOW have the same
meaning for all the *at() calls.
Then again, the *at() system calls are somewhat inconsistent anyway.
fchmodat() doesn't accept AT_SYMLINK_NOFOLLOW according to the man
page I have here.
-- Jamie
prev parent reply other threads:[~2009-04-21 10:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-07 23:15 [PATCH 1/3] VFS "stat light" out of fstatat, and fine grained flags Oleg Drokin
2009-04-07 23:25 ` Jeff Garzik
2009-04-08 6:56 ` forwarding -fsdevel to -kernel (was Re: [PATCH 1/3] VFS "stat ...) flags Miklos Szeredi
2009-04-08 7:35 ` David Miller
2009-04-12 20:50 ` [PATCH 1/3] VFS "stat light" out of fstatat, and fine grained flags Jamie Lokier
2009-04-12 21:46 ` Oleg Drokin
2009-04-21 10:20 ` Jamie Lokier [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=20090421102044.GA566@shareable.org \
--to=jamie@shareable.org \
--cc=green@linuxhacker.ru \
--cc=linux-fsdevel@vger.kernel.org \
/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).