osPfsReadWriteFile.3p 2.21 KB
.TH osPfsReadWriteFile 3P local "Silicon Graphics, Inc."
.SH NAME
.upperok
osPfsReadWriteFile \- Read/Write a file
.SH SYNOPSIS
.nf
\f3
.Op c
#include <ultra64.h>
.sp .8v
s32 osPfsReadWriteFile(OSPfs \(**pfs, s32 file_no, u8 flag, int offset,
                       int nbytes, u8 \(** data_buffer);
.Op
\f1
.fi
.SH DESCRIPTION
.sp
Base on the input 
.I flag
(PFS_READ or PFS_WRITE),
the 
.I osPfsReadWriteFile
function 
attempts to read or write
.I nbytes
bytes from/to the file associated with
.I file_no
into the buffer pointed to by
.I data_buffer.
.I file_no
is a file descriptor obtained from a successful
.I osPfsAllocateFile 
(3P) or
.I osPfsFindFile 
(3P) function call.
The transaction of data proceeds from the position in the file indicated by 
.I offset,
as measured in bytes from the beginning of the file. Both
.I offset
and
.I nbytes
must be multiple of
.I BLOCKSIZE
bytes and must be less than file size.
The 
.I Pfs
handle 
must be the handle returned from 
.I osPfsInit.
See
.IR osPfsInit 
(3P) for details on how to create this handle. 
.sp
Note that the file is not allowed to grow on the write. The application
should declare the size needed on allocation time or use
.I osPfsReSizeFile 
(3P) to grow/truncate the file.
.sp
A value of 0 is returned if the calls succeed, otherwise
one of the following error code is returned.
.PP
.nf
.ta 5 26 
	PFS_ERR_CONTRFAIL	The controller sends data at higher data
			transfer rate than the hardware handling 
			capability or the hardware CRC error
			occurs.
.sp
	PFS_ERR_INVALID		Invalid parameter or the specified file
			does not exist. Application should change 
			parameter and then retry.
.sp
	PFS_ERR_NEW_PACK	CONTROLLER PAK has been changed to a
 			different one. Application needs to call 
			osPfsInit(3p) to initialize the new
			CONTROLLER PAK.
.sp
	PFS_ERR_INCONSISTENT	File system is corrupted. Application needs
			to call osPfsChecker(3P) to repair the file 
			system.
.sp
	PFS_ERR_BAD_DATA	The data read from CONTROLLER PAK are bad. 
			Application should just ignore the data.
	

.fi
.SH "SEE ALSO"
osContInit (3P),
osPfsAllocateFile (3P),
osPfsChecker (3P),
osPfsFileState (3P),
osPfsFreeBlocks (3P),
osPfsInit (3P),
osPfsIsPlug (3P),
osPfsReSizeFile (3P),
osPfsSetLabel (3P)