【发布时间】:2012-04-28 10:09:10
【问题描述】:
使用 open syscall 写入和创建文件,文件没有属性。 fedora16 gcc-4.6.3
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
int main()
{
char * str= "helloworld";
int fd = open("test.db",O_WRONLY|O_CREAT|O_TRUNC|O_APPEND);
write(fd,str,10);
close(fd);
return 0;
}
ll test.db
---------。 1 jiamo jiamo 14 Apr 17 11:34 test.db
虽然它不会创建具有默认文件属性的文件,例如touch test.db
umask : 0002
如果删除 O_TRUNC
int fd = open("test1.db",O_WRONLY|O_CREAT|O_APPEND)
文件属性是:
----rwx---。 1 jiamo jiamo 14 Apr 17 12:29 test1.db
【问题讨论】:
-
你的 shell 中的 umask 是什么?
-
umask 0002(我已经更新问题)
标签: linux file system-calls