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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [doc/] [html/] [ref/] [fileio-directories.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
>Directories</TITLE
>Directories</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="File Table"
TITLE="File Table"
HREF="fileio-file-table.html"><LINK
HREF="fileio-file-table.html"><LINK
REL="NEXT"
REL="NEXT"
TITLE="Synchronization"
TITLE="Synchronization"
HREF="fileio-synchronization.html"></HEAD
HREF="fileio-synchronization.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-file-table.html"
HREF="fileio-file-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-synchronization.html"
HREF="fileio-synchronization.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-DIRECTORIES">Chapter 23. Directories</H1
NAME="FILEIO-DIRECTORIES">Chapter 23. Directories</H1
><P
><P
>Filesystem operations all take a directory pointer as one of their
>Filesystem operations all take a directory pointer as one of their
arguments.  A directory pointer is an opaque handle managed by the
arguments.  A directory pointer is an opaque handle managed by the
filesystem. It should encapsulate a reference to a specific directory
filesystem. It should encapsulate a reference to a specific directory
within the filesystem. For example, it may be a pointer to the data
within the filesystem. For example, it may be a pointer to the data
structure that represents that directory (such as an inode), or a
structure that represents that directory (such as an inode), or a
pointer to a pathname for the directory.</P
pointer to a pathname for the directory.</P
><P
><P
>The <TT
>The <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>chdir()</TT
>chdir()</TT
> filesystem function pointer has two
> filesystem function pointer has two
modes of use. When passed a pointer in the
modes of use. When passed a pointer in the
<TT
<TT
CLASS="PARAMETER"
CLASS="PARAMETER"
><I
><I
>dir_out</I
>dir_out</I
></TT
></TT
> argument, it should locate the named
> argument, it should locate the named
directory and place a directory pointer there. If the
directory and place a directory pointer there. If the
<TT
<TT
CLASS="PARAMETER"
CLASS="PARAMETER"
><I
><I
>dir_out</I
>dir_out</I
></TT
></TT
> argument is NULL then the
> argument is NULL then the
<TT
<TT
CLASS="PARAMETER"
CLASS="PARAMETER"
><I
><I
>dir</I
>dir</I
></TT
></TT
> argument is a previously generated
> argument is a previously generated
directory pointer that can now be disposed of. When the infrastructure
directory pointer that can now be disposed of. When the infrastructure
is implementing the <TT
is implementing the <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>chdir()</TT
>chdir()</TT
> function it makes two
> function it makes two
calls to filesystem <TT
calls to filesystem <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>chdir()</TT
>chdir()</TT
> functions. The first
> functions. The first
is to get a directory pointer for the new current directory. If this
is to get a directory pointer for the new current directory. If this
succeeds the second is to dispose of the old current directory
succeeds the second is to dispose of the old current directory
pointer.</P
pointer.</P
><P
><P
>The <TT
>The <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>opendir()</TT
>opendir()</TT
> function is used to open a
> function is used to open a
directory for reading. This results in an open file object that can be
directory for reading. This results in an open file object that can be
read to return a sequence of <SPAN
read to return a sequence of <SPAN
CLASS="STRUCTNAME"
CLASS="STRUCTNAME"
>struct dirent</SPAN
>struct dirent</SPAN
>
>
objects. The only operations that are allowed on this file are
objects. The only operations that are allowed on this file are
<TT
<TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>read</TT
>read</TT
>, <TT
>, <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>lseek</TT
>lseek</TT
> and
> and
<TT
<TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>close</TT
>close</TT
>. Each read operation on this file should
>. Each read operation on this file should
return a single <SPAN
return a single <SPAN
CLASS="STRUCTNAME"
CLASS="STRUCTNAME"
>struct dirent</SPAN
>struct dirent</SPAN
> object. When
> object. When
the end of the directory is reached, zero should be returned. The only
the end of the directory is reached, zero should be returned. The only
seek operation allowed is a rewind to the start of the directory, by
seek operation allowed is a rewind to the start of the directory, by
supplying an offset of zero and a <TT
supplying an offset of zero and a <TT
CLASS="PARAMETER"
CLASS="PARAMETER"
><I
><I
>whence</I
>whence</I
></TT
></TT
>
>
specifier of <TT
specifier of <TT
CLASS="LITERAL"
CLASS="LITERAL"
>SEEK_SET</TT
>SEEK_SET</TT
>.</P
>.</P
><P
><P
>Most of these considerations are invisible to clients of a filesystem
>Most of these considerations are invisible to clients of a filesystem
since they will access directories via the POSIX
since they will access directories via the POSIX
<TT
<TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>opendir()</TT
>opendir()</TT
>, <TT
>, <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>readdir()</TT
>readdir()</TT
> and
> and
<TT
<TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>closedir()</TT
>closedir()</TT
> functions.</P
> functions.</P
><P
><P
>Support for the <TT
>Support for the <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>getcwd()</TT
>getcwd()</TT
> function is provided by
> function is provided by
three mechanisms.  The first is to use the
three mechanisms.  The first is to use the
<TT
<TT
CLASS="LITERAL"
CLASS="LITERAL"
>FS_INFO_GETCWD</TT
>FS_INFO_GETCWD</TT
> getinfo key on the filesystem to use
> getinfo key on the filesystem to use
any internal support that it has for this. If that fails it falls back
any internal support that it has for this. If that fails it falls back
on one of the two other mechanisms. If
on one of the two other mechanisms. If
<TT
<TT
CLASS="LITERAL"
CLASS="LITERAL"
>CYGPKG_IO_FILEIO_TRACK_CWD</TT
>CYGPKG_IO_FILEIO_TRACK_CWD</TT
> is set then the current
> is set then the current
directory is tracked textually in <TT
directory is tracked textually in <TT
CLASS="FUNCTION"
CLASS="FUNCTION"
>chdir()</TT
>chdir()</TT
> and the result of that is
> and the result of that is
reported in getcwd(). Otherwise an attempt is made to traverse the
reported in getcwd(). Otherwise an attempt is made to traverse the
directory tree to its root using &quot;..&quot; entries.</P
directory tree to its root using &quot;..&quot; entries.</P
><P
><P
>This last option is complicated and expensive, and relies on the
>This last option is complicated and expensive, and relies on the
filesystem supporting &quot;.&quot; and &quot;..&quot;  entries. This is not always the
filesystem supporting &quot;.&quot; and &quot;..&quot;  entries. This is not always the
case, particularly if the filesystem has been ported from a
case, particularly if the filesystem has been ported from a
non-UNIX-compatible source. Tracking the pathname textually will
non-UNIX-compatible source. Tracking the pathname textually will
usually work, but might not produce optimum results when symbolic
usually work, but might not produce optimum results when symbolic
links are being used.</P
links are being used.</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-file-table.html"
HREF="fileio-file-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-synchronization.html"
HREF="fileio-synchronization.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"
>File Table</TD
>File 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"
>Synchronization</TD
>Synchronization</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.