#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include <pwd.h>
int main(int argc, char **argv[])
{
int fa;
struct stat myls;
uid_t uid;
if(stat(argv[1],&myls)<0)
{
printf("stat failed!\n");
exit(-1);
}
if(S_ISREG(myls.st_mode))
{
printf("pu tong wen jian!");
}
if(S_ISDIR(myls.st_mode))
{
printf("d");
}
if(S_ISCHR(myls.st_mode))
{
printf("zi fu she bei");
}
if(S_ISBLK(myls.st_mode))
{
printf("kuai she bei");
}
printf(" ");
if(myls.st_mode & S_IRUSR)//判断权限
{
printf("r ");
}
printf("%d ",myls.st_nlink);//硬链接
printf("%s",ctime(&(myls.st_mtim)));//时间转换
struct passwd * yuan=getpwuid(myls.st_uid);
printf("%s",yuan->pw_name);
}