cctools
Functions
full_io.h File Reference

Perform complete I/O operations, retrying through failures and signals. More...

#include <sys/types.h>
#include <stdint.h>
#include <stdio.h>

Go to the source code of this file.

Functions

ssize_t full_read (int fd, void *buf, size_t count)
 Read the next bytes from a file descriptor. More...
 
ssize_t full_write (int fd, const void *buf, size_t count)
 Write the next bytes to a file descriptor. More...
 
ssize_t full_pread (int fd, void *buf, size_t count, off_t offset)
 Read arbitrary bytes from a file descriptor. More...
 
ssize_t full_pwrite (int fd, const void *buf, size_t count, off_t offset)
 Write arbitrary bytes to a file descriptor. More...
 
ssize_t full_pread64 (int fd, void *buf, size_t count, int64_t offset)
 Read arbitrary bytes from a file descriptor. More...
 
ssize_t full_pwrite64 (int fd, const void *buf, size_t count, int64_t offset)
 Write arbitrary bytes to a file descriptor. More...
 
ssize_t full_fread (FILE *file, void *buf, size_t count)
 Read the next bytes from a file stream. More...
 
ssize_t full_fwrite (FILE *file, const void *buf, size_t count)
 Write the next bytes to a file stream. More...
 

Detailed Description

Perform complete I/O operations, retrying through failures and signals.

A subtle property of Unix is that the kernel may choose to leave an I/O operation incomplete, returning a smaller number of bytes than you requested, or simply giving up with the error EINTR, if it is simply more "convenient". The full_io routines look lik normal Unix read and write operations, but silently retry through temporary failures. Of course, these routines may still fail for more permanent reasons such as end of file or disk full.

Function Documentation

ssize_t full_read ( int  fd,
void *  buf,
size_t  count 
)

Read the next bytes from a file descriptor.

Parameters
fdFile descriptor.
bufPointer to buffer.
countThe number of bytes to read.
Returns
The number of bytes actually read, or less than zero indicating error.
ssize_t full_write ( int  fd,
const void *  buf,
size_t  count 
)

Write the next bytes to a file descriptor.

Parameters
fdFile descriptor.
bufPointer to buffer.
countThe number of bytes to write.
Returns
The number of bytes actually written, or less than zero indicating error.
ssize_t full_pread ( int  fd,
void *  buf,
size_t  count,
off_t  offset 
)

Read arbitrary bytes from a file descriptor.

Parameters
fdFile descriptor.
bufPointer to buffer.
countThe number of bytes to read.
offsetThe offset in the file to begin from.
Returns
The number of bytes actually read, or less than zero indicating error.
ssize_t full_pwrite ( int  fd,
const void *  buf,
size_t  count,
off_t  offset 
)

Write arbitrary bytes to a file descriptor.

Parameters
fdFile descriptor.
bufPointer to buffer.
countThe number of bytes to write.
offsetThe offset in the file to begin from.
Returns
The number of bytes actually written, or less than zero indicating error.
ssize_t full_pread64 ( int  fd,
void *  buf,
size_t  count,
int64_t  offset 
)

Read arbitrary bytes from a file descriptor.

(64 bit)

Parameters
fdFile descriptor.
bufPointer to buffer.
countThe number of bytes to read.
offsetThe offset in the file to begin from.
Returns
The number of bytes actually read, or less than zero indicating error.
ssize_t full_pwrite64 ( int  fd,
const void *  buf,
size_t  count,
int64_t  offset 
)

Write arbitrary bytes to a file descriptor.

(64 bit)

Parameters
fdFile descriptor.
bufPointer to buffer.
countThe number of bytes to write.
offsetThe offset in the file to begin from.
Returns
The number of bytes actually written, or less than zero indicating error.
ssize_t full_fread ( FILE *  file,
void *  buf,
size_t  count 
)

Read the next bytes from a file stream.

Parameters
fileStandard file stream.
bufPointer to buffer.
countThe number of bytes to read.
Returns
The number of bytes actually read, or less than zero indicating error.
ssize_t full_fwrite ( FILE *  file,
const void *  buf,
size_t  count 
)

Write the next bytes to a file stream.

Parameters
fileStandard file stream.
bufPointer to buffer.
countThe number of bytes to write.
Returns
The number of bytes actually written, or less than zero indicating error.