Question: C/shell programming Task 2: Printing the time that the file path was created (50 points) The stat system call can access a file by name
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 t st_devID of device containing file ino t st ino;/inode number mode_t st_mode; / protection t st nlink; / number of hard links/ t st uid * user ID of owncr/ gid t st gidgroup ID of owner t st rdev;device ID (if special file) t st size; total size, in bytes t st blksize; blocksize for file system LO blkcnt t st blocks; / number of 512B blocks allocated c t st atime; time of last access time t st mtime; time of last modification/ time t st ctime; time of last status change On success, zero is returned. On error, is retuned, 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 t as printaccess.c. Compile the program, then execute it by giving it a path name as an argument. rintaccess.c: #i #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
