obtain detailed information about an open file
#include <sys/stat.h> int fsys_fstat( int fildes, struct _fsys_stat *buf );
The fsys_fstat() function obtains detailed information about an open file whose file descriptor is fildes. 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.
errno, fstat(), fsys_stat(), lstat(), stat()
/* * Get the extended stat info for a list of files * and report the file sizes and numbers of extents */ #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <unistd.h> void main( int argc, char **argv ) { int fd; int ecode = 0; int n; struct _fsys_stat xsbuf; for( n = 1; n < argc; ++n ) { if( ( fd = open( argv[n], O_RDONLY ) ) == -1 ) { perror( argv[n] ); ecode++; } else if( fsys_fstat( fd, &xsbuf ) == -1 ) { perror( argv[n] ); close( fd ); ecode++; } else { printf( "File %s is %ld bytes and has %u extents\n", argv[n], xsbuf.st_size, xsbuf.st_num_xtnts); close( fd ); } } exit( ecode ); }
QNX
QNX