我正在尝试使用
打开一个临时文件fd = open("/tmp", O_RDWR | O_TMPFILE, 0);
if (fd == -1) {
perror("open()");
exit(1);
}
我得到“open(): Permission denied”。
我在/tmp 中有权限:
drwxrwxrwt 13 root root 1.2K Apr 23 13:55 /tmp/
而且我相信我的内核对于 O_TMPFILE 来说已经足够新了:
Linux frosties 3.14-1-amd64 #1 SMP Debian 3.14.2-1 (2014-04-28) x86_64 GNU/Linux
我错过了什么?
最佳答案
调用失败,因为您指定了模式0
,这意味着没有权限。参见 this LWN article用于讨论 Linux 内核的这种行为,以及明显的错误修复。
关于c - 打开 ("/tmp", O_RDWR | O_TMPFILE, 0) 失败,权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29822827/