[Previous]
[Contents]
[Next]

fsys_fstat()

obtain detailed information about an open file

Synopsis:

#include <sys/stat.h>
int fsys_fstat( int fildes, 
                struct _fsys_stat *buf );

Description:

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.


Note: This call only works on regular files, directories and other disk-based file types.

Returns:

0
Success
-1
An error occurred. errno is set to indicate the error.

Errors:

EBADF
The fildes argument is not a valid file descriptor.
ENOSYS
This operation is not supported for the resource manager associated with this fildes. Try calling fstat().

Examples:

/*
 * 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 );
  }

Classification:

QNX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

errno, fstat(), fsys_stat(), lstat(), stat()


[Previous]
[Contents]
[Next]