#include <libgen.h>
#include <sys/stat.h>
...
struct stat statbuf;
if (stat(dirname(argv[1]), &statbuf) != -1)
process_inode_number(statbuf.st_ino);
Note that it dirname()can change the string, so if you still need to, or if it can be a string literal (which is in read-only memory), use strdup()to make a copy of the string for dirname().
source
share