The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 10-10-2008
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,763
The stat() function call returns -1 on error. Are you checking the return code?
Then finding what errno references to produce a meaningful error message?
perror() will do that for you.

lstat() works on symlinks only -- you aren't calling lstat? Even though your error message says so.

These are the two calls you should be using. stat() is a much more likely choice.
Code:
int stat(const char *path, struct stat *buf);
int fstat(int filesdes, struct stat *buf);