mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* O_TMPFILE detection
@ 2014-02-11 16:03 Christoph Hellwig
  2014-02-11 17:54 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Hellwig @ 2014-02-11 16:03 UTC (permalink / raw)
  To: Alexander Viro, Linus Torvalds; +Cc: linux-fsdevel, linux-man, linux-kernel

I've started implementing support for O_TMPFILE in xfs_io in preparation
for proper testcases and found something rather annoying:

Given that we implicitly pass O_DIRECTORY as part of the full O_TMPFILE
flag an open using O_TMPFILE will simply succeed on a kernel old enough
to not have O_TMPFILE support, and give you a file descriptor for the
directory passed in.  Of course this only works if you open the fd
read-only which isn't all that useful for real temporary files, but it
would be the natural choice for a feature test.

I guess we can't really fix this up any more, but does anyone have a
good idea how to document this properly in the man page?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: O_TMPFILE detection
  2014-02-11 16:03 O_TMPFILE detection Christoph Hellwig
@ 2014-02-11 17:54 ` Linus Torvalds
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2014-02-11 17:54 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Alexander Viro, linux-fsdevel, linux-man, Linux Kernel Mailing List

On Tue, Feb 11, 2014 at 8:03 AM, Christoph Hellwig <hch@infradead.org> wrote:
> I've started implementing support for O_TMPFILE in xfs_io in preparation
> for proper testcases and found something rather annoying:
>
> Given that we implicitly pass O_DIRECTORY as part of the full O_TMPFILE
> flag an open using O_TMPFILE will simply succeed on a kernel old enough
> to not have O_TMPFILE support, and give you a file descriptor for the
> directory passed in.  Of course this only works if you open the fd
> read-only which isn't all that useful for real temporary files, but it
> would be the natural choice for a feature test.

But O_TMPFILE without write access fails on modern kernels, so what
you test doesn't make sense.

In fact, that "O_TMPFILE fails with O_RDONLY" was done exactly so that
you could not have a program that works on kernels with O_TMPFILE
support _and_ opens a directory on old kernels without it. Basically
"O_TMPFILE | O_RDONLY" is an insane thing to do, and will never create
a temporary file.

              Linus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-11 17:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-11 16:03 O_TMPFILE detection Christoph Hellwig
2014-02-11 17:54 ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®