Open ("/ tmp", O_RDWR | O_TMPFILE, 0) fails with Permission

I am trying to open a temporary file using

fd = open("/tmp", O_RDWR | O_TMPFILE, 0);
if (fd == -1) {
    perror("open()");
    exit(1);
}

and I get "open (): Permission denied".

I have permissions in / tmp:

drwxrwxrwt  13 root root 1.2K Apr 23 13:55 /tmp/

and I believe that my kernel is fairly new to O_TMPFILE:

Linux frosties 3.14-1-amd64 #1 SMP Debian 3.14.2-1 (2014-04-28) x86_64 GNU/Linux

What am I missing?

+4
source share
1 answer

The call failed because you specified a mode 0, which means no permissions. See this LWN article for a discussion of this Linux kernel behavior and an obvious fix.

+2
source

Source: https://habr.com/ru/post/1584249/


All Articles