示例#1
0
/* fseek for buffered I/O handles */
int
stream_seek(StreamHandle_t * streamP, afs_foff_t offset, int whence)
{
    int rc;
    int retval = 0;

    if (streamP->str_direction == STREAM_DIRECTION_WRITE
	&& streamP->str_bufoff > 0) {
	rc = OS_WRITE(streamP->str_fd, streamP->str_buffer,
		      streamP->str_bufoff);
	if (rc < 0) {
	    streamP->str_error = errno;
	    retval = -1;
	}
    }
    streamP->str_bufoff = 0;
    streamP->str_buflen = 0;
    streamP->str_eof = 0;
    streamP->str_direction = STREAM_DIRECTION_NONE;
    if (OS_SEEK(streamP->str_fd, offset, whence) < 0) {
	streamP->str_error = errno;
	retval = -1;
    }
    return retval;
}
示例#2
0
ssize_t
ih_pwrite(int fd, const void * buf, size_t count, afs_foff_t offset)
{
	afs_foff_t code;
	code = OS_SEEK(fd, offset, 0);
	if (code < 0)
	    return code;
	return OS_WRITE(fd, buf, count);
}
示例#3
0
ssize_t
ih_pread(int fd, void * buf, size_t count, afs_foff_t offset)
{
	afs_foff_t code;
	code = OS_SEEK(fd, offset, 0);
	if (code < 0)
	    return code;
	return OS_READ(fd, buf, count);
}