Hi I need help on this Using c program in linux environment
Hi, I need help on this. Using c program in linux environment
For this assignment, you will create a system command that will directory entries by inode number. NAME rbi - removes a directory entry by inode number. SYNOPSIS rbi INODENUMBER DESCRIPTION Removes a file or directory from the current directory matching the supplied inode number. Displays an appropriate error message on failure. You may assume the user always provides an integer for the inode number. SAMPLE USAGE rbi 23593064 - directory entry with matching inode number is removed, rbi - synopsis displayedSolution
int fd, inode; fd = open(\"/path/to/your/file\", YOUR_DESIRED_OPEN_MODE); if (fd < 0) { // some error occurred while opening the file // use [perror(\"Error opening the file\");] to get error description } struct stat file_stat; int ret; ret = fstat (fd, &file_stat); if (ret < 0) { // error getting file stat } inode = file_stat.st_ino; // inode now contains inode number of the file with descriptor fd // Use your inode number
