Question: Task 2: Printing the time that the file path was created (50 points) The stat system call can access a file by name and retrieve
Task 2: Printing the time that the file path was created (50 points) The stat system call can access a file by name and retrieve file status information. It is given by: int stat (const char *pathname, struct stat *buf): This system call returns a stat structure (both the function and struct are called stat), which contains the following fields: struct stat Adev_t sl_dev; /* ID of device containing file * ino_tsuino; inode number mode_1st_mode; /* protection inlink_tst_nlink; /* number of hard links */ uid_ s_uid; /* user ID of owner gid_t sl_gid; /* group ID of owner * dev_t surdev; /* device ID (if special file) bff_ts_size; /* total size, in bytes / blksize_t sublksize; /*blocksize for file system 1/0 */ plkcnt_tst_blocks; /* number of 512B blocks allocated kime_t st_atime; /* time of last access * kime_t si_mtime; /* time of last modification/ kime_tst_ctime;/" time of last status change On success, zero is returned. On error, -1 is returned, and errno is set appropriately. The following program displays the time that the file path was last accessed. Type in and complete the following program on the computer. Save it as printaccess.c. Compile the program, then execute it by giving it a path name as an argument. printaccess.co #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
