open
システムコールを使用して完全なアクセス許可(777)でファイルを作成していますが、作成すると、ls -l
アクセス許可のみが(755)として表示されます。ファイルパーミッションが777ではない理由を教えてください。
コード
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
int main()
{
int fd;
/* Creates a file with full permission*/
fd = open("test", O_CREAT | O_RDWR | O_APPEND, 0777);
if (fd = -1)
{
return -1;
}
close(fd);
}
出力
$ ls -l
-rwxr-xr-x 1 ubuntu ubuntu 0 2012-09-19 11:55 test