Question: How do i do this in C ? Create a program filestat that takes as a command line parameter thename of a directory, and for

How do i do this in C ?

Create a program filestat that takes as a command line parameter thename of a directory, and for every file or directory in the passed directory print outthe contents of the stat structure associated in the following sample format:

...var

permissions: 0755

file type: directory -> private/var

major device: 1

minor device: 1

number of links: 24

user ID: 0

group ID: 0 size (bytes): 816

last access: Sat Dec 6 07:05:17 2014

last modification: Sun Nov 10 13:55:43 2013

last inode change: Sun Nov 10 13:55:43 2013

block size: 4096

number disk blocks: 0

Volumes permissions: 0777

file type: directory

major device: 1

minor device: 1

number of links: 4

user ID: 0

group ID: 80 size (bytes): 136

last access: Fri Dec 5 11:50:45 2014

last modification: Fri Dec 5 08:04:25 2014

last inode change: Fri Dec 5 08:04:25 2014

block size: 4096

number disk blocks: 0...

You may want to make use of sprintf(3), strcpy(3), and ctime(3). Note thatdisplaying symbolic links correctly is a little tricky. Print all output to thestdout -- it is not necessary to open an output file as the shell makes it easy toredirect the output to a file:$ filestat /dir > stat.out

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!