pwrite64

Writes data to a file.

Library:LibC
Classification:POSIX
Service:File and Directory I/O

Syntax

  #include <unistd.h> 
   
  ssize_t  pwrite64 (
     int             fildes,
     const void     *buf,
     size_t          nbytes,
     off64_t         off);
  

Parameters

fildes

(IN) Specifies a file descriptor.

buf

(IN) Points to the address at which to start transmitting data.

nbytes

(IN) Specifies the number of bytes to write.

off

(IN) Specifies the starting offset in the file for the write.

Return Values

If successful, returns the number of bytes of data actually written. Otherwise, returns -1 and sets errno to one of the following:

Decimal

Constant

Description

4

EBADF

Bad file number.

9

EINVAL

Invalid fildes or off parameter.

12

ENOSPC

No free space remains on the device containing the file.

14

ERANGE

The transfer request size was outside the range supported by the file associated with fildes.

25

ENXIO

Either a hang up occurred or the device does not exist.

28

EIO

An I/O error occurred while reading from or writing to the file system.

32

EPIPE

The fildes parameter refers to a pipe or FIFO.

55

ENOBUFS

Insufficient resources.

63

EINTR

The write operation was interrupted by a signal.

71

EFBIG

An attempt was made to write a file that exceeds the file size limit or the maximum file size.

Remarks

The pwrite64 function attempts to write nbytes from the buffer pointed to by buf to the file associated with the open file descriptor, fildes.The data is written to the file at the position specified by the off parameter.

The fildes value is returned by open or creat. The access mode must have included either O_WRONLY or O_RDWR when the file was opened.

The pwrite64 function is equivalent to pwrite except that it handles files larger than 2 GB.

See Also