|
列出文件访问权限的函数
char *get_perms(struct stat *sbuf ,char* perms)
{static char*modes[]={
"---","-- x","-w-","-wx","r- -","r-x","rw-","rwx"}
int i,j;
*perms='\0';
for(i=2;i>0;i--)
{j=(sbuf->st_mode>>(i*3))&7;
strcat(perms,modes[j]);
}
if((sbuf->stmode&S_ISUID)!=0)
perms[2]='s';
if((sbuf->stmode&S_ISGID)!=0)
perms[5]='s';
if((sbuf->stmode&S_ISUID)!=0)
perms[8]='t';
}
请给我解释一下这个程序
特别是for循环我没看懂
谢谢 |
|