I'm trying to build a program inside the stat
function that shows the value of inode
and the value of gid
.
Follow the code:
#include <stdio.h>
#include <sys/types.h
#include <sys/stat.h>
#include <unistd.h>
int stat(const char *path, struct stat *buf);
struct stat buf;
printf("st_gid : %d\n", buf.st_gid);
printf("I-node number: %ld\n", (long) buf.st_ino);
Only the return is:
st_gid: 12779520 I-node number: -1076104514
The program is returning a nonzero number for the gid that should be zero because the file is authored by root and running as root and a negative number for the inode. When after the ls -li command it returns zero for the gid and 263458 for the inode. Could someone clarify where the error is?