gtpc2mjjC/C++ Language Support User's Guide

TPF_FSDD_RESIZE-Change the Size of a File

This type of function is specified as part of the file system device driver interface and is called by fopen, ftruncate, and open to change the size of the special file. If the file is extended beyond its current size, the extended part will (logically) contain \0.

Format

typedef int TPF_FSDD_RESIZE(long size,
            const TPF_FSDD_FILEDATA *filedata);

size
The new size of the special file. size ranges from 0 to 2 147 483 647 (2**31 - 1). If size is larger than the previous size of the file, the extended part will (logically) contain \0.

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

Normal Return

0
The size of the file was changed to size.

Error Return

-1
The size of the file was not changed.

Programming Considerations

Examples

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

#include <c$spif.h> /* Device driver interface */
#include <errno.h>  /* errno, EINVAL */
 
/**********************************************************************/
/* The null_resize() function always fails (the size of a null file   */
/* is always zero).                                                   */
/**********************************************************************/
int null_resize(long new_size, const TPF_FSDD_FILEDATA *filedata)
{
    errno = EINVAL;
    return -1;
}

Related Information