⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fileio-directories.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
字号:
<!-- Copyright (C) 2003 Red Hat, Inc.                                --><!-- This material may be distributed only subject to the terms      --><!-- and conditions set forth in the Open Publication License, v1.0  --><!-- or later (the latest version is presently available at          --><!-- http://www.opencontent.org/openpub/).                           --><!-- Distribution of the work or derivative of the work in any       --><!-- standard (paper) book form is prohibited unless prior           --><!-- permission is obtained from the copyright holder.               --><HTML><HEAD><TITLE>Directories</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos Reference Manual"HREF="ecos-ref.html"><LINKREL="UP"TITLE="File System Support Infrastructure"HREF="fileio.html"><LINKREL="PREVIOUS"TITLE="File Table"HREF="fileio-file-table.html"><LINKREL="NEXT"TITLE="Synchronization"HREF="fileio-synchronization.html"></HEAD><BODYCLASS="CHAPTER"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="fileio-file-table.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="fileio-synchronization.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="CHAPTER"><H1><ANAME="FILEIO-DIRECTORIES">Chapter 23. Directories</H1><P>Filesystem operations all take a directory pointer as one of theirarguments.  A directory pointer is an opaque handle managed by thefilesystem. It should encapsulate a reference to a specific directorywithin the filesystem. For example, it may be a pointer to the datastructure that represents that directory (such as an inode), or apointer to a pathname for the directory.</P><P>The <TTCLASS="FUNCTION">chdir()</TT> filesystem function pointer has twomodes of use. When passed a pointer in the<TTCLASS="PARAMETER"><I>dir_out</I></TT> argument, it should locate the nameddirectory and place a directory pointer there. If the<TTCLASS="PARAMETER"><I>dir_out</I></TT> argument is NULL then the<TTCLASS="PARAMETER"><I>dir</I></TT> argument is a previously generateddirectory pointer that can now be disposed of. When the infrastructureis implementing the <TTCLASS="FUNCTION">chdir()</TT> function it makes twocalls to filesystem <TTCLASS="FUNCTION">chdir()</TT> functions. The firstis to get a directory pointer for the new current directory. If thissucceeds the second is to dispose of the old current directorypointer.</P><P>The <TTCLASS="FUNCTION">opendir()</TT> function is used to open adirectory for reading. This results in an open file object that can beread to return a sequence of <SPANCLASS="STRUCTNAME">struct dirent</SPAN>objects. The only operations that are allowed on this file are<TTCLASS="FUNCTION">read</TT>, <TTCLASS="FUNCTION">lseek</TT> and<TTCLASS="FUNCTION">close</TT>. Each read operation on this file shouldreturn a single <SPANCLASS="STRUCTNAME">struct dirent</SPAN> object. Whenthe end of the directory is reached, zero should be returned. The onlyseek operation allowed is a rewind to the start of the directory, bysupplying an offset of zero and a <TTCLASS="PARAMETER"><I>whence</I></TT>specifier of <TTCLASS="LITERAL">SEEK_SET</TT>.</P><P>Most of these considerations are invisible to clients of a filesystemsince they will access directories via the POSIX<TTCLASS="FUNCTION">opendir()</TT>, <TTCLASS="FUNCTION">readdir()</TT> and<TTCLASS="FUNCTION">closedir()</TT> functions.</P><P>Support for the <TTCLASS="FUNCTION">getcwd()</TT> function is provided bythree mechanisms.  The first is to use the<TTCLASS="LITERAL">FS_INFO_GETCWD</TT> getinfo key on the filesystem to useany internal support that it has for this. If that fails it falls backon one of the two other mechanisms. If<TTCLASS="LITERAL">CYGPKG_IO_FILEIO_TRACK_CWD</TT> is set then the currentdirectory is tracked textually in <TTCLASS="FUNCTION">chdir()</TT> and the result of that isreported in getcwd(). Otherwise an attempt is made to traverse thedirectory tree to its root using &quot;..&quot; entries.</P><P>This last option is complicated and expensive, and relies on thefilesystem supporting &quot;.&quot; and &quot;..&quot;  entries. This is not always thecase, particularly if the filesystem has been ported from anon-UNIX-compatible source. Tracking the pathname textually willusually work, but might not produce optimum results when symboliclinks are being used.</P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="fileio-file-table.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="fileio-synchronization.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">File Table</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="fileio.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Synchronization</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -