Re: [RFC PATCH] fs: allow open(dir, O_TMPFILE|..., 0) with mode 0

From: Linus Torvalds
Date: Mon Nov 03 2014 - 14:04:34 EST


On Mon, Nov 3, 2014 at 10:49 AM, Eric Rannaud <e@xxxxxxxxxxxxxxxx> wrote:
>
> Isn't it because they are essentially emulating an atomic open()
> capable of creating a file with inherited ACLs, according to
> relatively complex rules? open *can* be used with O_CREAT|O_RDONLY
> (touch(1) might do that), which would naively translate into:

Oh, so you don't actually need any file contents at all?

If that is actually a real usage, then maybe we should just say that
"O_TMPFILE|O_RDONLY" is fine, and remove the check that it has to be
writable.

That check was always a sanity-check, because people felt that a
temp-file you can't write to is an insane concept. But if there is a
real use case for it, then clearly it's not completely insane. Just
odd.

It's just that single

if (!(acc_mode & MAY_WRITE))
return -EINVAL;

test in build_open_flags(), right?

I'd take a tested patch to remove that (where "tested" means: "yes, I
actually did that unwritable file descriptor thing, and it actually
solved the problem and worked for samba or whatever")

Linus
--
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/