get information about the file in a path
#include <sys/stat.h>
int fsys_stat( const char *path,
struct _fsys_stat *buf );
The fsys_stat() function obtains detailed information about the file referenced in path. This information is placed in the structure pointed to by buf.
The _fsys_stat structure includes all the information contained in the stat structure plus filesystem extent information.
![]() |
This call works only on regular files, directories and other disk-based file types. |
/*
* Get the extended stat info for a list of files
* and report the file sizes and numbers of extents
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
void main( int argc, char **argv )
{
int ecode = 0;
int n;
struct _fsys_stat xsbuf;
for( n = 1; n < argc; ++n ) {
if( fsys_stat( argv[n], &xsbuf ) == -1 ) {
perror( argv[n] );
ecode++;
} else
printf(
"File %s is %ld bytes and has %u extents\n",
argv[n], xsbuf.st_size, xsbuf.st_num_xtnts);
}
exit( ecode );
}
QNX
| Safety: | |
|---|---|
| Interrupt handler | No |
| Signal handler | Yes, but modifies errno |
| Thread | Yes |
errno, fstat(), fsys_fstat(), lstat(), stat()