gtpc2mjcC/C++ Language Support User's Guide

TPF_FSDD_APPEND-Write Beginning at the End of a File

This type of function is specified as part of the file system device driver interface and is called by TPF file system C functions that require a physical append to a file device to append output data to an open special file.

Format

typedef long TPF_FSDD_APPEND(void *buffer, long data_size, int noblock,
    const TPF_FSDD_FILEDATA *filedata);

buffer
The address of the data buffer from which the output data will be appended. The range of addresses buffer through buffer + data_size - 1 is not verified to be addressable.

data_size
The size of the output data to be appended to file. data_size ranges from 1 to 2 147 483 647 (2**31 - 1) inclusive.

noblock
Nonblocking append request indicator.

For files that support nonblocking writes and cannot accept data immediately, you can write code to do the following:

filedata
The address of the file data object returned by the TPF_FSDD_OPEN-type device driver function for the special file being appended.

Normal Return

The number of bytes appended from buffer, from 1 to data_size inclusive.

Note:
When zero bytes of data are requested to be appended, TPF file system C functions return zero without calling this device driver function.

Error Return

-1 means an error during the append operation. The device driver should also set errno to indicate the type of error.

Programming Considerations

Examples

The following example is the append device driver interface function for the null file (/dev/null).

#include <c$spif.h> /* Device driver interface */
 
/**********************************************************************/
/* The null_append() function appends to a null file.  It always      */
/* succeeds.                                                          */
/**********************************************************************/
long null_append(void *data, long data_size, int non_block,
                 const TPF_FSDD_FILEDATA *filedata)
{
    return data_size;
}

Related Information