1
I’m trying to build a program within the function stat
that shows the value of inode
and the value of gid
.
Follows 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 that the return is :
st_gid : 12779520 I-Node number: -1076104514
The program is returning a non-zero number to gid which should be zero because the file is root authored and is running as root and a negative number for inode. When after the ls -li command it returns zero for gid and 263458 for inode. Someone could clarify where the error is?
Okay. I’ll test here to see if it works and return. Thank you.
– uthacod
really is right missing assign value in buf. Thank you and can call it off.
– uthacod
@uthacod, if the answer solved your problem, you can click on V next to the answer to mark your question as answered
– Brumazzi DB