Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//filestat.c #include #include #include #include #include int main(int argc, char *argv[]) { mode_t file_perm; /* File permissions */ struct stat file_details; /* Detailed file info

image text in transcribed

image text in transcribed

//filestat.c

#include

#include

#include

#include

#include

int main(int argc, char *argv[])

{

mode_t file_perm; /* File permissions */

struct stat file_details; /* Detailed file info */

/* Retrieve the file details */

//write your code here

/* Get the file type */

//write your code here

/* Get the time of last access of the file */

//write your code here

/* Get the file permissions */

printf("File Permissions: ");

//write your code here

}

Overview Write a program that takes one file/directory name as command line input and reports the following information on the file: (a) File type (b) Time of last access (c) Read, write and execute permissions Requirements You will write a program (filestat) which will perform the following functions It will run from the command line as shown below: > filestat filename //This will display the following properties of filename: 1) File type, 2) Time of last access, 3) Read, write, and execute permissions for User, Group, and Others. > filestat directory //This will display the following properties of directory: 1) File type, 2) Time of last access, 3) Read, write, and execute permissions for User, Group, and Others.. Arguments: Expects one file name or directory name as argument. You may assume that the user will type the command correctly. Syntax: filestat Instructions 1. Download the file filestat.c 2. Your implementation file MUST be named filestat.c 3. Implement the code for the functions described in the requirements 4. Use system calls e.g. Istat function. 5. Test the code using the given file (filestat.c) 6. Check the results to make sure there are no failures. A sample output is provided for comparison. Your output should be the same as below, except for the "Time of last access". The format of the time should be the same, but the values can be different. o Output sample for the file filestat.c: File type : Regular Time of last access : Tue Oct 13 18:42:29 2020 File Permissions: User: Readable, Writable, Not executable Group : Readable, Not writable, Not executable Others : Readable, Not writable. Not executable Output sample for a directory File type : Directory Time of last access : Tue Oct 13 18:45:28 2020 File Permissions: User: Readable, Writable, Executable Group: Readable, Not writable, Executable Others : Readable, Not writable, Executable

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions

Question

2. What is the business value of security and control?

Answered: 1 week ago