if (stat("./test.txt", &buf) == -1) {
perror("fail to stat");
exit(1);
}
if ( buf.st_mode & S_IRGRP != 0)
printf("user of the group can read\n");
else
printf("user of the group can't read\n");
return 0;
}
程序运行结果为:user of the grouop can't read
但是在终端上用命令ls -l test.txt时,显示
-rwxr----- 1 wl wl 12 2009-09-22 09:42 test.txt
照理说应该显示user of the group can read.
这是为什么呢?