29.01.2013 Views

GPFS: Administration and Programming Reference - IRA Home

GPFS: Administration and Programming Reference - IRA Home

GPFS: Administration and Programming Reference - IRA Home

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

gpfs_prealloc() Subroutine<br />

Exceptions<br />

None.<br />

Error status<br />

EACCES The file is not opened for writing.<br />

EBADF The file descriptor is not valid.<br />

EDQUOT A disk quota has been exceeded<br />

EFBIG The file has become too large for the file system or has exceeded the file size as defined<br />

by the user’s ulimit value.<br />

EINVAL The file descriptor does not refer to a <strong>GPFS</strong> file or a regular file; a negative value was<br />

specified for StartOffset or BytesToPrealloc.<br />

ENOTREADY The file system on which the file resides has become unavailable.<br />

ENOSPC The file system has run out of disk space.<br />

ENOSYS The gpfs_prealloc() subroutine is not supported under the current file system format.<br />

Examples<br />

#include <br />

#include <br />

#include <br />

#include <br />

int rc;<br />

int fileH<strong>and</strong>le = -1;<br />

char* fileNameP = "datafile";<br />

offset_t startOffset = 0;<br />

offset_t bytesToAllocate = 20*1024*1024; /* 20 MB */<br />

fileH<strong>and</strong>le = open(fileNameP, O_RDWR|O_CREAT, 0644);<br />

if (fileH<strong>and</strong>le < 0)<br />

{<br />

perror(fileNameP);<br />

exit(1);<br />

}<br />

rc = gpfs_prealloc(fileH<strong>and</strong>le, startOffset, bytesToAllocate);<br />

if (rc < 0)<br />

{<br />

fprintf(stderr, "Error %d preallocation at %lld for %lld in %s\n",<br />

errno, startOffset, bytesToAllocate, fileNameP);<br />

exit(1);<br />

}<br />

Location<br />

/usr/lpp/mmfs/lib/libgpfs.a for AIX, /usr/lpp/mmfs/lib/libgpfs.so for Linux<br />

334 <strong>GPFS</strong>: <strong>Administration</strong> <strong>and</strong> <strong>Programming</strong> <strong>Reference</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!