C/C++ codefd=open("test.txt",O_CREAT|O_RDWR|O_TRUNC,S_IRWXU|S_IRGRP|S_IWGRP|S_IRWXO);
这样创建的一个test.txt却是rwxrw-r-x这样的权限,不是应该是rwxrw-rwx吗????
C/C++ codenantian5:/home/train/priv/67/test02>ls
filetest filetest.c
nantian5:/home/train/priv/67/test02>./filetest
open test.txt fd=3
currops=0
nantian5:/home/train/priv/67/test02>ls
filetest filetest.c test.txt
nantian5:/home/train/priv/67/test02>ls -l
total 24
-rwxrwxr-x 1 train train 5077 Jun 9 20:55 filetest
-rw-rw-r-- 1 train train 469 Jun 9 20:55 filetest.c
-rwxrw-r-x 1 train train 0 Jun 9 21:57 test.txt
nantian5:/home/train/priv/67/test02>
open设置文件权限是同你当前用户的umask掩码值共同决定的。你可先设置umask值为000,然后再用open设置文件权限