C program that takes one or more file or directory names as command line input and reports the following information on the file: i)File type ii)Number of links iii)Read, write and execute permissions iv)Time of last access

void main()
{ int fd;
struct stat buf;
{ if(fstat(fd,&buf)==0)
{ printf("mode of fileis %u",buf.st_mode);
printf("\n size of the file is %u",buf.st_size);
printf("\n device name %u",buf.st_dev);
printf("\n inode of file is %u",buf.st_ino);
printf("\n no. of links are %u",buf.st_nlink);
printf("\n owner oof a file is %u",buf.st_uid);
printf("\n no.of blocks is %u",buf.st_blocks);
printf("\n group owner is %u",buf.st_gid);
printf("\n blocks size of the file is %u",buf.st_blksize);
printf("\n time of last modifiedis %u",buf.st_ctime);
printf("error in fstat() syscall");
printf("error in open() sys call");

Leave a Reply