#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc, const char *argv[])
{
int fd = open("./3.txt", O_RDWR|O_CREAT|O_TRUNC, 0777);
if(fd < 0)
{
perror("open");
return -1;
}
printf("%d\n", fd);
return 0;
}
结果:无法创建
-rwxrwxr-x 1 ubuntu ubuntu 0 一月 30 19:03 3.txt