Comtrol eCos User Manual
Page 422

Chapter 22. File Table
int (*fo_read)
(struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio);
int (*fo_write)
(struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio);
int
(*fo_lseek)
(struct CYG_FILE_TAG *fp, off_t *pos, int whence );
int (*fo_ioctl)
(struct CYG_FILE_TAG *fp, CYG_ADDRWORD com,
CYG_ADDRWORD data);
int (*fo_select)
(struct CYG_FILE_TAG *fp, int which, CYG_ADDRWORD info);
int
(*fo_fsync)
(struct CYG_FILE_TAG *fp, int mode );
int (*fo_close)
(struct CYG_FILE_TAG *fp);
int
(*fo_fstat)
(struct CYG_FILE_TAG *fp, struct stat *buf );
int
(*fo_getinfo)
(struct CYG_FILE_TAG *fp, int key, char *buf, int len );
int
(*fo_setinfo)
(struct CYG_FILE_TAG *fp, int key, char *buf, int len );
};
It should be obvious from the names of most of these functions what their responsibilities are. The
fo_getinfo()
and
fo_setinfo()
function pointers, like their counterparts in the filesystem structure, implement minor control
and info functions such as
fpathconf()
.
The second argument to the
fo_read()
and
fo_write()
function pointers is a pointer to a UIO structure:
struct CYG_UIO_TAG
{
struct CYG_IOVEC_TAG *uio_iov; /* pointer to array of iovecs */
int
uio_iovcnt; /* number of iovecs in array */
off_t
uio_offset; /* offset into file this uio corresponds to */
ssize_t
uio_resid; /* residual i/o count */
enum cyg_uio_seg
uio_segflg;
/* see above */
enum cyg_uio_rw
uio_rw;
/* see above */
};
struct CYG_IOVEC_TAG
{
void
*iov_base;
/* Base address. */
ssize_t
iov_len;
/* Length. */
};
This structure encapsulates the parameters of any data transfer operation. It provides support for scatter/gather
operations and records the progress of any data transfer. It is also compatible with the I/O operations of any BSD-
derived network stacks and filesystems.
When a file is opened (or a file object created by some other means, such as
socket()
or
accept()
) it is the
responsibility of the filesystem open operation to initialize all the fields of the object except the
f_ucount
,
f_syncmode
and
f_mte
fields. Since the
f_flag
field will already contain bits belonging to the FILEIO
infrastructure, any changes to it must be made with the appropriate logical operations.
318