From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Mike Frysinger <vapier@gentoo.org>
Cc: linux-man@vger.kernel.org, viro@zeniv.linux.org.uk,
Richard Weinberger <richard@nod.at>,
lkml <linux-kernel@vger.kernel.org>,
Michael Kerrisk <mtk.manpages@gmail.com>
Subject: Re: [PATCH] open(2): document O_PATH
Date: Mon, 30 Apr 2012 13:09:05 +0530 [thread overview]
Message-ID: <877gwxacti.fsf@skywalker.in.ibm.com> (raw)
In-Reply-To: <CAKgNAkgykZJV59WJXW9c9gVwXhn=WNYKxo_W1GM7ocHEEFqEXg@mail.gmail.com>
"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com> writes:
> Hi Mike,
>
> [Al, Aneesh, there is a question for you below]
>
> On Sun, Apr 29, 2012 at 3:25 PM, Mike Frysinger <vapier@gentoo.org> wrote:
>> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
>> ---
>> man2/open.2 | 16 +++++++++++++++-
>> 1 file changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/man2/open.2 b/man2/open.2
>> index a655fae..61689cf 100644
>> --- a/man2/open.2
>> +++ b/man2/open.2
>> @@ -47,7 +47,6 @@
>> .\" FIXME . Apr 08: The next POSIX revision has O_EXEC, O_SEARCH, and
>> .\" O_TTYINIT. Eventually these may need to be documented. --mtk
>> .\" FIXME Linux 2.6.33 has O_DSYNC, and a hidden __O_SYNC.
>> -.\" FIXME: Linux 2.6.39 added O_PATH
>> .\"
>> .TH OPEN 2 2012-02-27 "Linux" "Linux Programmer's Manual"
>> .SH NAME
>> @@ -428,6 +427,21 @@ For a discussion of the effect of
>> in conjunction with mandatory file locks and with file leases, see
>> .BR fcntl (2).
>> .TP
>> +.B O_PATH
>> +The path is opened for accessing its file attributes only. Since the file
>> +itself is not opened, most operations (such as
>> +.BR read (2)
>> +or
>> +.BR write (2))
>> +will return
>> +.BR EBADF .
>> +You may however use functions that operate on the file descriptor itself
>> +such as
>> +.BR close (2),
>> +functions that duplicate file descriptors, and as the dirfd argument with
>> +all the *at style of functions (e.g.
>> +.BR openat (2)).
>> +.TP
>> .B O_SYNC
>> The file is opened for synchronous I/O.
>> Any
>
> Thanks for the prod. Adding this has been on my list for a while.
> There's actually quite a lot more to say, and I've written the patch
> below. Could you check it over.
>
> Al, Aneesh, there is one question for you in a FIXME below. Could you
> take a look please?
>
> Thanks,
>
> Michael
>
>
> --- a/man2/open.2
> +++ b/man2/open.2
> @@ -428,6 +427,66 @@ For a discussion of the effect of
> in conjunction with mandatory file locks and with file leases, see
> .BR fcntl (2).
> .TP
> +.BR O_PATH " (since Linux 2.6.39)"
> +.\" commit 1abf0c718f15a56a0a435588d1b104c7a37dc9bd
> +Obtain a file descriptor that is used only for fetching file attributes.
> +The file itself is not opened, and most file operations (e.g.,
> +.BR read (2),
> +.BR write (2))
> +fail with the error
> +.BR EBADF .
> +The following operations
> +.I can
> +be performed on the resulting file descriptor:
> +.RS
> +.IP * 3
> +Closing the file descriptor
> +.RB ( close (2)).
> +.\" FIXME Commit 1abf0c718f15a56a0a435588d1b104c7a37dc9bdcw
> +.\" message says that closing the file descriptor does not affect
> +.\" POSIX locks or dnotify.
> +.\" However, my testing shows that it DOES affect dnotify (and inotify).
> +.\" Does close() affect POSIX locks?
> +.IP *
IIUC what an O_PATH descritor doesn't do is to flush dnotify markers
if (likely(!(filp->f_mode & FMODE_PATH))) {
dnotify_flush(filp, id);
locks_remove_posix(filp, id);
}
I don't know much about markers, but as per fsnotify_backend.h
/*
* a mark is simply an object attached to an in core inode which allows an
* fsnotify listener to indicate they are either no longer interested in events
* of a type matching mask or only interested in those events.
*
* these are flushed when an inode is evicted from core and may be flushed
* when the inode is modified (as seen by fsnotify_access). Some fsnotify users
* (such as dnotify) will flush these when the open fd is closed and not at
* inode eviction or modification.
*/
struct fsnotify_mark {
It also doesn't remove posix locks. I tested this with a test prg
struct flock flock;
flock.l_type = F_WRLCK;
flock.l_whence = SEEK_SET;
flock.l_start = 0;
flock.l_len = 0;
fd = open(argv[1], O_RDWR);
fcntl(fd, F_SETLKW, &flock);
fd = open(argv[1], O_PATH);
close(fd);
The close doesn't result in lock release.
> +Duplicating the file descriptor
> +.RB ( dup (2),
> +.BR fcntl (2)
> +.BR F_DUPFD ,
> +etc.).
> +.IP *
-aneesh
next prev parent reply other threads:[~2012-04-30 7:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-29 3:25 [PATCH] open(2): document O_PATH Mike Frysinger
[not found] ` <1335669917-23970-1-git-send-email-vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
2012-04-29 21:39 ` Michael Kerrisk (man-pages)
2012-04-30 7:39 ` Aneesh Kumar K.V [this message]
2012-04-30 11:44 ` Ted Ts'o
[not found] ` <20120430114410.GB28308-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2012-05-03 6:48 ` Michael Kerrisk (man-pages)
2012-05-03 8:27 ` Aneesh Kumar K.V
[not found] ` <87fwbhhdp2.fsf-6yE53ggjAfyqSkle7U1LjlaTQe2KTcn/@public.gmane.org>
2012-05-03 13:07 ` Ted Ts'o
[not found] ` <20120503130707.GF18002-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2012-05-03 13:20 ` Al Viro
2012-05-06 1:00 ` H. Peter Anvin
[not found] ` <877gwxacti.fsf-6yE53ggjAfyqSkle7U1LjlaTQe2KTcn/@public.gmane.org>
2012-05-03 6:47 ` Michael Kerrisk (man-pages)
[not found] ` <CAKgNAkiRH8p=Dp1tqkb3D9oRVCOSnj2bofgFN5x2svntN7vtPg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-05-03 14:04 ` Aneesh Kumar K.V
[not found] ` <87bom5xswc.fsf-6yE53ggjAfyqSkle7U1LjlaTQe2KTcn/@public.gmane.org>
2012-05-03 14:11 ` Al Viro
[not found] ` <20120503141156.GP6871-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2012-05-05 11:31 ` Michael Kerrisk (man-pages)
2013-01-08 18:52 ` Al Viro
-- strict thread matches above, loose matches on Subject: below --
2013-03-14 9:35 Michael Kerrisk (man-pages)
[not found] ` <CAKgNAkgWiANFA1Z7o2EQmKmsMzzpa1ga2ggLeX3Bo58QmjDx6g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-04-13 2:17 ` Geoffrey Thomas
[not found] ` <alpine.DEB.2.02.1304121917230.29639-TW+ixCjnw15HKceWYcIGBEp/09x8KikSkwxctJ+8KrKSEQKx1GYgKAC/G2K4zDHf@public.gmane.org>
2013-07-20 21:07 ` Michael Kerrisk
2013-07-20 11:40 ` Al Viro
[not found] ` <20130720114017.GA2118-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2013-07-20 20:56 ` Michael Kerrisk
[not found] ` <51EAF997.2090300-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-07-22 8:46 ` Peter Schiffer
[not found] ` <51ECF166.4080007-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-07-22 10:45 ` Michael Kerrisk (man-pages)
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=877gwxacti.fsf@skywalker.in.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=mtk.manpages@gmail.com \
--cc=richard@nod.at \
--cc=vapier@gentoo.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 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).