The problem is likely that you forgot to change all instances of "status" to "struct stat"; this includes in your function declarations.
But that won't cause your program to work. You're passing a uid_t to show_info(), not a struct stat, or a status. If you change show_info() to expect a uid_t, then to print it properly, you'd do something like:
Code:
printf("uid: %d\n", (int)uid);
The cast (the (int) part) is necessary because uid_t is not a standard type so printf() doesn't know how to print it. Welcome to C. If you plan on passing a struct, vart's comment applies.
You'll also probably want to include fcntl.h for open(); but then the way you're using open() is not correct. The first argument to stat() is a string that contains a filename. You're trying to pass a file descriptor. There exists a function fstat() that takes a file descriptor as the first argument, but don't embed your open() call into it the way you're trying to do here. Two reasons: You can't tell if the open() failed and thus you'll pass -1 to fstat() instead of a valid file descriptor; or you will lose the descriptor so you won't be able to close the file:
Code:
int fd;
struct stat buf;
fd = open("somefile", O_RDONLY);
if(fd == -1)
{
perror("open");
exit(1);
}
if(fstat(fd, &buf) == -1)
{
perror("fstat");
exit(1);
}
/* now you can do what you want with buf */
close(fd); /* you could check this for error too... */
As a final note, I'd suggest explicitly listing the return type of main:
Code:
int main(void /* or int argc, char **argv */)
C99 removed implicit int, and it doesn't hurt to be explicit anyway.