OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [doc/] [html/] [ref/] [fileio-file-table.html] - Diff between revs 28 and 174

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 28 Rev 174
<!-- Copyright (C) 2003 Red Hat, Inc.                                -->
<!-- Copyright (C) 2003 Red Hat, Inc.                                -->
<!-- This material may be distributed only subject to the terms      -->
<!-- This material may be distributed only subject to the terms      -->
<!-- and conditions set forth in the Open Publication License, v1.0  -->
<!-- and conditions set forth in the Open Publication License, v1.0  -->
<!-- or later (the latest version is presently available at          -->
<!-- or later (the latest version is presently available at          -->
<!-- http://www.opencontent.org/openpub/).                           -->
<!-- http://www.opencontent.org/openpub/).                           -->
<!-- Distribution of the work or derivative of the work in any       -->
<!-- Distribution of the work or derivative of the work in any       -->
<!-- standard (paper) book form is prohibited unless prior           -->
<!-- standard (paper) book form is prohibited unless prior           -->
<!-- permission is obtained from the copyright holder.               -->
<!-- permission is obtained from the copyright holder.               -->
<HTML
<HTML
><HEAD
><HEAD
><TITLE
><TITLE
>File Table</TITLE
>File Table</TITLE
><meta name="MSSmartTagsPreventParsing" content="TRUE">
><meta name="MSSmartTagsPreventParsing" content="TRUE">
<META
<META
NAME="GENERATOR"
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
"><LINK
REL="HOME"
REL="HOME"
TITLE="eCos Reference Manual"
TITLE="eCos Reference Manual"
HREF="ecos-ref.html"><LINK
HREF="ecos-ref.html"><LINK
REL="UP"
REL="UP"
TITLE="File System Support Infrastructure"
TITLE="File System Support Infrastructure"
HREF="fileio.html"><LINK
HREF="fileio.html"><LINK
REL="PREVIOUS"
REL="PREVIOUS"
TITLE="Mount Table"
TITLE="Mount Table"
HREF="fileio-mount-table.html"><LINK
HREF="fileio-mount-table.html"><LINK
REL="NEXT"
REL="NEXT"
TITLE="Directories"
TITLE="Directories"
HREF="fileio-directories.html"></HEAD
HREF="fileio-directories.html"></HEAD
><BODY
><BODY
CLASS="CHAPTER"
CLASS="CHAPTER"
BGCOLOR="#FFFFFF"
BGCOLOR="#FFFFFF"
TEXT="#000000"
TEXT="#000000"
LINK="#0000FF"
LINK="#0000FF"
VLINK="#840084"
VLINK="#840084"
ALINK="#0000FF"
ALINK="#0000FF"
><DIV
><DIV
CLASS="NAVHEADER"
CLASS="NAVHEADER"
><TABLE
><TABLE
SUMMARY="Header navigation table"
SUMMARY="Header navigation table"
WIDTH="100%"
WIDTH="100%"
BORDER="0"
BORDER="0"
CELLPADDING="0"
CELLPADDING="0"
CELLSPACING="0"
CELLSPACING="0"
><TR
><TR
><TH
><TH
COLSPAN="3"
COLSPAN="3"
ALIGN="center"
ALIGN="center"
>eCos Reference Manual</TH
>eCos Reference Manual</TH
></TR
></TR
><TR
><TR
><TD
><TD
WIDTH="10%"
WIDTH="10%"
ALIGN="left"
ALIGN="left"
VALIGN="bottom"
VALIGN="bottom"
><A
><A
HREF="fileio-mount-table.html"
HREF="fileio-mount-table.html"
ACCESSKEY="P"
ACCESSKEY="P"
>Prev</A
>Prev</A
></TD
></TD
><TD
><TD
WIDTH="80%"
WIDTH="80%"
ALIGN="center"
ALIGN="center"
VALIGN="bottom"
VALIGN="bottom"
></TD
></TD
><TD
><TD
WIDTH="10%"
WIDTH="10%"
ALIGN="right"
ALIGN="right"
VALIGN="bottom"
VALIGN="bottom"
><A
><A
HREF="fileio-directories.html"
HREF="fileio-directories.html"
ACCESSKEY="N"
ACCESSKEY="N"
>Next</A
>Next</A
></TD
></TD
></TR
></TR
></TABLE
></TABLE
><HR
><HR
ALIGN="LEFT"
ALIGN="LEFT"
WIDTH="100%"></DIV
WIDTH="100%"></DIV
><DIV
><DIV
CLASS="CHAPTER"
CLASS="CHAPTER"
><H1
><H1
><A
><A
NAME="FILEIO-FILE-TABLE">Chapter 22. File Table</H1
NAME="FILEIO-FILE-TABLE">Chapter 22. File Table</H1
><P
><P
>Once a file has been opened it is represented by an open file
>Once a file has been opened it is represented by an open file
object. These are allocated from an array of available file
object. These are allocated from an array of available file
objects. User code accesses these open file objects via a second array
objects. User code accesses these open file objects via a second array
of pointers which is indexed by small integer offsets. This gives the
of pointers which is indexed by small integer offsets. This gives the
usual Unix file descriptor functionality, complete with the various
usual Unix file descriptor functionality, complete with the various
duplication mechanisms.</P
duplication mechanisms.</P
><P
><P
>A file table entry has the following structure:</P
>A file table entry has the following structure:</P
><TABLE
><TABLE
BORDER="5"
BORDER="5"
BGCOLOR="#E0E0F0"
BGCOLOR="#E0E0F0"
WIDTH="70%"
WIDTH="70%"
><TR
><TR
><TD
><TD
><PRE
><PRE
CLASS="PROGRAMLISTING"
CLASS="PROGRAMLISTING"
>struct CYG_FILE_TAG
>struct CYG_FILE_TAG
{
{
    cyg_uint32                  f_flag;         /* file state                   */
    cyg_uint32                  f_flag;         /* file state                   */
    cyg_uint16                  f_ucount;       /* use count                    */
    cyg_uint16                  f_ucount;       /* use count                    */
    cyg_uint16                  f_type;         /* descriptor type              */
    cyg_uint16                  f_type;         /* descriptor type              */
    cyg_uint32                  f_syncmode;     /* synchronization protocol     */
    cyg_uint32                  f_syncmode;     /* synchronization protocol     */
    struct CYG_FILEOPS_TAG      *f_ops;         /* file operations              */
    struct CYG_FILEOPS_TAG      *f_ops;         /* file operations              */
    off_t                       f_offset;       /* current offset               */
    off_t                       f_offset;       /* current offset               */
    CYG_ADDRWORD                f_data;         /* file or socket               */
    CYG_ADDRWORD                f_data;         /* file or socket               */
    CYG_ADDRWORD                f_xops;         /* extra type specific ops      */
    CYG_ADDRWORD                f_xops;         /* extra type specific ops      */
    cyg_mtab_entry              *f_mte;         /* mount table entry            */
    cyg_mtab_entry              *f_mte;         /* mount table entry            */
};</PRE
};</PRE
></TD
></TD
></TR
></TR
></TABLE
></TABLE
><P
><P
>The <TT
>The <TT
CLASS="STRUCTFIELD"
CLASS="STRUCTFIELD"
><I
><I
>f_flag</I
>f_flag</I
></TT
></TT
> field contains some FILEIO
> field contains some FILEIO
control bits and some bits propagated from the
control bits and some bits propagated from the
<TT
<TT
CLASS="PARAMETER"
CLASS="PARAMETER"
><I
><I
>flags</I
>flags</I
></TT
></TT
> argument of the
> argument of the
<TT
<TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>open()</TT
>open()</TT
> call (defined by
> call (defined by
<TT
<TT
CLASS="LITERAL"
CLASS="LITERAL"
>CYG_FILE_MODE_MASK</TT
>CYG_FILE_MODE_MASK</TT
>).</P
>).</P
><P
><P
>The <TT
>The <TT
CLASS="STRUCTFIELD"
CLASS="STRUCTFIELD"
><I
><I
>f_ucount</I
>f_ucount</I
></TT
></TT
> field contains a use count that
> field contains a use count that
controls when a file will be closed. Each duplicate in the file
controls when a file will be closed. Each duplicate in the file
descriptor array counts for one reference here. It is also
descriptor array counts for one reference here. It is also
incremented around each I/O operation to ensure that the file cannot
incremented around each I/O operation to ensure that the file cannot
be closed while it has current I/O operations.</P
be closed while it has current I/O operations.</P
><P
><P
>The <TT
>The <TT
CLASS="STRUCTFIELD"
CLASS="STRUCTFIELD"
><I
><I
>f_type</I
>f_type</I
></TT
></TT
> field indicates the type of the
> field indicates the type of the
underlying file object. Some of the possible values here are
underlying file object. Some of the possible values here are
<TT
<TT
CLASS="LITERAL"
CLASS="LITERAL"
>CYG_FILE_TYPE_FILE</TT
>CYG_FILE_TYPE_FILE</TT
>,
>,
<TT
<TT
CLASS="LITERAL"
CLASS="LITERAL"
>CYG_FILE_TYPE_SOCKET</TT
>CYG_FILE_TYPE_SOCKET</TT
> or <TT
> or <TT
CLASS="LITERAL"
CLASS="LITERAL"
>CYG_FILE_TYPE_DEVICE</TT
>CYG_FILE_TYPE_DEVICE</TT
>.</P
>.</P
><P
><P
>The <TT
>The <TT
CLASS="STRUCTFIELD"
CLASS="STRUCTFIELD"
><I
><I
>f_syncmode</I
>f_syncmode</I
></TT
></TT
> field is copied from the
> field is copied from the
<TT
<TT
CLASS="STRUCTFIELD"
CLASS="STRUCTFIELD"
><I
><I
>syncmode</I
>syncmode</I
></TT
></TT
> field of the implementing
> field of the implementing
filesystem. Its use is described in <A
filesystem. Its use is described in <A
HREF="fileio-synchronization.html"
HREF="fileio-synchronization.html"
>Chapter 24</A
>Chapter 24</A
>.</P
>.</P
><P
><P
>The <TT
>The <TT
CLASS="STRUCTFIELD"
CLASS="STRUCTFIELD"
><I
><I
>f_offset</I
>f_offset</I
></TT
></TT
> field records the current file
> field records the current file
position. It is the responsibility of the file operation functions to
position. It is the responsibility of the file operation functions to
keep this field up to date.</P
keep this field up to date.</P
><P
><P
>The <TT
>The <TT
CLASS="STRUCTFIELD"
CLASS="STRUCTFIELD"
><I
><I
>f_data</I
>f_data</I
></TT
></TT
> field contains private data
> field contains private data
placed here by the underlying filesystem. Normally this will be a
placed here by the underlying filesystem. Normally this will be a
pointer to, or handle on, the filesystem object that implements this
pointer to, or handle on, the filesystem object that implements this
file.</P
file.</P
><P
><P
>The <TT
>The <TT
CLASS="STRUCTFIELD"
CLASS="STRUCTFIELD"
><I
><I
>f_xops</I
>f_xops</I
></TT
></TT
> field contains a pointer to any
> field contains a pointer to any
extra type specific operation functions. For example, the socket I/O
extra type specific operation functions. For example, the socket I/O
system installs a pointer to a table of functions that implement the
system installs a pointer to a table of functions that implement the
standard socket operations.</P
standard socket operations.</P
><P
><P
>The <TT
>The <TT
CLASS="STRUCTFIELD"
CLASS="STRUCTFIELD"
><I
><I
>f_mte</I
>f_mte</I
></TT
></TT
> field contains a pointer to the
> field contains a pointer to the
parent mount table entry for this file. It is used mainly to implement
parent mount table entry for this file. It is used mainly to implement
the synchronization protocol. This may contain a pointer to some other
the synchronization protocol. This may contain a pointer to some other
data structure in file objects not derived from a filesystem.</P
data structure in file objects not derived from a filesystem.</P
><P
><P
>The <TT
>The <TT
CLASS="STRUCTFIELD"
CLASS="STRUCTFIELD"
><I
><I
>f_ops</I
>f_ops</I
></TT
></TT
> field contains a pointer to a
> field contains a pointer to a
table of file I/O operations. This has the following structure:</P
table of file I/O operations. This has the following structure:</P
><TABLE
><TABLE
BORDER="5"
BORDER="5"
BGCOLOR="#E0E0F0"
BGCOLOR="#E0E0F0"
WIDTH="70%"
WIDTH="70%"
><TR
><TR
><TD
><TD
><PRE
><PRE
CLASS="PROGRAMLISTING"
CLASS="PROGRAMLISTING"
>struct CYG_FILEOPS_TAG
>struct CYG_FILEOPS_TAG
{
{
        int     (*fo_read)      (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio);
        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_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_lseek)     (struct CYG_FILE_TAG *fp, off_t *pos, int whence );
        int     (*fo_ioctl)     (struct CYG_FILE_TAG *fp, CYG_ADDRWORD com,
        int     (*fo_ioctl)     (struct CYG_FILE_TAG *fp, CYG_ADDRWORD com,
                                 CYG_ADDRWORD data);
                                 CYG_ADDRWORD data);
        int     (*fo_select)    (struct CYG_FILE_TAG *fp, int which, CYG_ADDRWORD info);
        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_fsync)     (struct CYG_FILE_TAG *fp, int mode );
        int     (*fo_close)     (struct CYG_FILE_TAG *fp);
        int     (*fo_close)     (struct CYG_FILE_TAG *fp);
        int     (*fo_fstat)     (struct CYG_FILE_TAG *fp, struct stat *buf );
        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_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 );
        int     (*fo_setinfo)   (struct CYG_FILE_TAG *fp, int key, char *buf, int len );
};</PRE
};</PRE
></TD
></TD
></TR
></TR
></TABLE
></TABLE
><P
><P
>It should be obvious from the names of most of these functions what
>It should be obvious from the names of most of these functions what
their responsibilities are. The <TT
their responsibilities are. The <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>fo_getinfo()</TT
>fo_getinfo()</TT
>
>
and <TT
and <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>fo_setinfo()</TT
>fo_setinfo()</TT
> function pointers, like their
> function pointers, like their
counterparts in the filesystem structure, implement minor control and
counterparts in the filesystem structure, implement minor control and
info functions such as <TT
info functions such as <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>fpathconf()</TT
>fpathconf()</TT
>.</P
>.</P
><P
><P
>The second argument to the <TT
>The second argument to the <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>fo_read()</TT
>fo_read()</TT
> and
> and
<TT
<TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>fo_write()</TT
>fo_write()</TT
> function pointers is a pointer to a
> function pointers is a pointer to a
UIO structure:</P
UIO structure:</P
><TABLE
><TABLE
BORDER="5"
BORDER="5"
BGCOLOR="#E0E0F0"
BGCOLOR="#E0E0F0"
WIDTH="70%"
WIDTH="70%"
><TR
><TR
><TD
><TD
><PRE
><PRE
CLASS="PROGRAMLISTING"
CLASS="PROGRAMLISTING"
>struct CYG_UIO_TAG
>struct CYG_UIO_TAG
{
{
    struct CYG_IOVEC_TAG *uio_iov;      /* pointer to array of iovecs */
    struct CYG_IOVEC_TAG *uio_iov;      /* pointer to array of iovecs */
    int                  uio_iovcnt;    /* number of iovecs in array */
    int                  uio_iovcnt;    /* number of iovecs in array */
    off_t                uio_offset;    /* offset into file this uio corresponds to */
    off_t                uio_offset;    /* offset into file this uio corresponds to */
    ssize_t              uio_resid;     /* residual i/o count */
    ssize_t              uio_resid;     /* residual i/o count */
    enum cyg_uio_seg     uio_segflg;    /* see above */
    enum cyg_uio_seg     uio_segflg;    /* see above */
    enum cyg_uio_rw      uio_rw;        /* see above */
    enum cyg_uio_rw      uio_rw;        /* see above */
};
};
 
 
struct CYG_IOVEC_TAG
struct CYG_IOVEC_TAG
{
{
    void           *iov_base;           /* Base address. */
    void           *iov_base;           /* Base address. */
    ssize_t        iov_len;             /* Length. */
    ssize_t        iov_len;             /* Length. */
};</PRE
};</PRE
></TD
></TD
></TR
></TR
></TABLE
></TABLE
><P
><P
>This structure encapsulates the parameters of any data transfer
>This structure encapsulates the parameters of any data transfer
operation. It provides support for scatter/gather operations and
operation. It provides support for scatter/gather operations and
records the progress of any data transfer. It is also compatible with
records the progress of any data transfer. It is also compatible with
the I/O operations of any BSD-derived network stacks and filesystems.</P
the I/O operations of any BSD-derived network stacks and filesystems.</P
><P
><P
>When a file is opened (or a file object created by some other means,
>When a file is opened (or a file object created by some other means,
such as <TT
such as <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>socket()</TT
>socket()</TT
> or <TT
> or <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>accept()</TT
>accept()</TT
>) it is the
>) it is the
responsibility of the filesystem open operation to initialize all the
responsibility of the filesystem open operation to initialize all the
fields of the object except the <TT
fields of the object except the <TT
CLASS="STRUCTFIELD"
CLASS="STRUCTFIELD"
><I
><I
>f_ucount</I
>f_ucount</I
></TT
></TT
>,
>,
<TT
<TT
CLASS="STRUCTFIELD"
CLASS="STRUCTFIELD"
><I
><I
>f_syncmode</I
>f_syncmode</I
></TT
></TT
> and
> and
<TT
<TT
CLASS="STRUCTFIELD"
CLASS="STRUCTFIELD"
><I
><I
>f_mte</I
>f_mte</I
></TT
></TT
> fields. Since the
> fields. Since the
<TT
<TT
CLASS="STRUCTFIELD"
CLASS="STRUCTFIELD"
><I
><I
>f_flag</I
>f_flag</I
></TT
></TT
> field will already contain bits belonging to the FILEIO
> field will already contain bits belonging to the FILEIO
infrastructure, any changes to it must be made with the appropriate
infrastructure, any changes to it must be made with the appropriate
logical operations.</P
logical operations.</P
></DIV
></DIV
><DIV
><DIV
CLASS="NAVFOOTER"
CLASS="NAVFOOTER"
><HR
><HR
ALIGN="LEFT"
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
SUMMARY="Footer navigation table"
WIDTH="100%"
WIDTH="100%"
BORDER="0"
BORDER="0"
CELLPADDING="0"
CELLPADDING="0"
CELLSPACING="0"
CELLSPACING="0"
><TR
><TR
><TD
><TD
WIDTH="33%"
WIDTH="33%"
ALIGN="left"
ALIGN="left"
VALIGN="top"
VALIGN="top"
><A
><A
HREF="fileio-mount-table.html"
HREF="fileio-mount-table.html"
ACCESSKEY="P"
ACCESSKEY="P"
>Prev</A
>Prev</A
></TD
></TD
><TD
><TD
WIDTH="34%"
WIDTH="34%"
ALIGN="center"
ALIGN="center"
VALIGN="top"
VALIGN="top"
><A
><A
HREF="ecos-ref.html"
HREF="ecos-ref.html"
ACCESSKEY="H"
ACCESSKEY="H"
>Home</A
>Home</A
></TD
></TD
><TD
><TD
WIDTH="33%"
WIDTH="33%"
ALIGN="right"
ALIGN="right"
VALIGN="top"
VALIGN="top"
><A
><A
HREF="fileio-directories.html"
HREF="fileio-directories.html"
ACCESSKEY="N"
ACCESSKEY="N"
>Next</A
>Next</A
></TD
></TD
></TR
></TR
><TR
><TR
><TD
><TD
WIDTH="33%"
WIDTH="33%"
ALIGN="left"
ALIGN="left"
VALIGN="top"
VALIGN="top"
>Mount Table</TD
>Mount Table</TD
><TD
><TD
WIDTH="34%"
WIDTH="34%"
ALIGN="center"
ALIGN="center"
VALIGN="top"
VALIGN="top"
><A
><A
HREF="fileio.html"
HREF="fileio.html"
ACCESSKEY="U"
ACCESSKEY="U"
>Up</A
>Up</A
></TD
></TD
><TD
><TD
WIDTH="33%"
WIDTH="33%"
ALIGN="right"
ALIGN="right"
VALIGN="top"
VALIGN="top"
>Directories</TD
>Directories</TD
></TR
></TR
></TABLE
></TABLE
></DIV
></DIV
></BODY
></BODY
></HTML
></HTML
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.