使用open系統調用來編寫和創建文件,文件沒有屬性。 fedora16 GCC-4.6.3linux文件屬性
#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的
----------。 17年4月14日11:34 test.db的
1個謨謨雖然它不創建默認文件的文件屬性,例如像touch test.db
的umask:0002
如果跌落O_TRUNC int fd = open("test1.db",O_WRONLY|O_CREAT|O_APPEND)
文件attributs是:
---- rwx ---。 1個謨謨17年4月14日12:29 test1.db
什麼是你在你的shell的umask? – mjbnz 2012-04-17 04:24:16
umask 0002(我已更新問題) – jiamo 2012-04-17 04:37:21