gpfs_iread() subroutine

Reads a file opened by gpfs_iopen().

Library

GPFS Library (libgpfs.a for AIX®, libgpfs.so for Linux®)

Synopsis

#include <gpfs.h>
int gpfs_iread(gpfs_ifile_t *ifile, 
               void *buffer, 
               int bufferSize, 
               gpfs_off64_t *offset);

Description

The gpfs_iread() subroutine reads data from the file indicated by the ifile parameter returned from gpfs_iopen(). This subroutine reads data beginning at parameter offset and continuing for bufferSize bytes into the buffer specified by buffer. If successful, the subroutine returns a value that is the length of the data read, and sets parameter offset to the offset of the next byte to be read. A return value of 0 indicates end-of-file.

For an overview of using gpfs_iread() in a backup application, see Using APIs to develop backup applications.

Note: Compile any program that uses this subroutine with the -lgpfs flag from the following library:
  • libgpfs.a for AIX
  • libgpfs.so for Linux

Parameters

ifile
Pointer to gpfs_ifile_t from gpfs_iopen().
buffer
Buffer for the data to be read.
bufferSize
Size of the buffer (that is, the amount of data to be read).
offset
Offset of where within the file to read. If gpfs_iread() is successful, offset is updated to the next byte after the last one that was read.

Exit status

If the gpfs_iread() subroutine is successful, it returns the number of bytes read.

If the gpfs_iread() subroutine is unsuccessful, it returns a value of -1 and sets the global error variable errno to indicate the nature of the error.

Exceptions

None.

Error status

Error codes include but are not limited to the following:

EISDIR
The specified file is a directory.
EINVAL
Missing or incorrect parameter.
ENOSYS
The gpfs_iread() subroutine is not available.
EPERM
The caller does not have superuser privileges.
ESTALE
Cached file system information was not valid.
GPFS_E_INVAL_IFILE
Incorrect ifile parameter.
GPFS_E_ISLNK
The specified file is a symlink. Use gpfs_ireadlink subroutine on symlink.

Location

/usr/lpp/mmfs/lib/libgpfs.a for AIX

/usr/lpp/mmfs/lib/libgpfs.so for Linux