Safer ABI for O_TMPFILE

[suggested by Rasmus Villemoes] make O_DIRECTORY | O_RDWR part of O_TMPFILE;
that will fail on old kernels in a lot more cases than what I came up with.
And make sure O_CREAT doesn't get there...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro
2013-07-13 13:26:37 +04:00
parent 4fbeb19d53
commit bb458c644a
6 changed files with 12 additions and 8 deletions

View File

@@ -84,10 +84,14 @@
#define O_PATH 010000000
#endif
#ifndef O_TMPFILE
#define O_TMPFILE 020000000
#ifndef __O_TMPFILE
#define __O_TMPFILE 020000000
#endif
/* a horrid kludge trying to make sure that this will fail on old kernels */
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY | O_RDWR)
#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT | O_ACCMODE)
#ifndef O_NDELAY
#define O_NDELAY O_NONBLOCK
#endif