Re: [PATCH] vfs: new O_NODE open flag

From: Miklos Szeredi
Date: Mon Sep 28 2009 - 06:25:41 EST


On Fri, 25 Sep 2009, Valdis.Kletnieks wrote:
> On Fri, 25 Sep 2009 19:35:23 BST, "Dr. David Alan Gilbert" said:
>
> > I know it's not possible without this flag, my interest is whether
> > it would be possible WITH this flag to promote an fd opened with the
> > O_NODE to a normal fd, guaranteeing that it's still operating on the
> > same object.
>
> Well, maybe the question is if we should treat "promote" differently than
> "re-open"?
>
> (And now I'm wondering what happens if you dup() one of these beasts....)

dup() only duplicates _references_ to an open file, it does not create
a new file. The same applies to fork().

BTW I just checked, and it is possible to re-open or promote an fd
opened with O_NODE like this:

char tmp[64];

fd = open(filename, O_NODE | O_NOACCESS);
/* ... */
sprintf(tmp, "/proc/self/fd/%i", fd);
fd_rw = open(tmp, O_RDWR);

Now fd_rw is guaranteed to refer to the same inode as fd.

Thanks,
Miklos
--
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/