#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>

int main(int argc, char * argv[])
{
	struct stat info;
	if(argc<2)
	{
		printf("error usage!\n");
		printf("usage:mystat filename\n");
		exit(EXIT_FAILURE);
	}
	if(stat(argv[1],&info)==-1)
	{
		perror("stat");
		exit(EXIT_FAILURE);
	}
	printf("   mode:%o\n",info.st_mode);
	printf("  links:%d\n",info.st_nlink);
	printf("   user:%d\n",info.st_uid);
	printf("  group:%d\n",info.st_gid);
	printf("   size:%d\n",info.st_size);
	printf("modtime:%d\n",info.st_mtime);
	printf("   name:%s\n",argv[1]);
	return 0;
}
