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

📄 c-filesys3.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title>    Local File Systems   </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="GuideIX.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-filesys.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-filesys2.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-filesys4.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="85629">4.3  &nbsp;&nbsp;RT-11-Compatible File System: rt11Fs</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85630"> </a>VxWorks provides the file system rt11Fs, which is compatible with the RT-11 file system. It is provided primarily for compatibility with earlier versions of VxWorks. Normally, the dosFs file system is the preferred choice, because it offers such enhancements as optional contiguous file allocation, flexible file naming, and so on.</p></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/warning.gif"></td><td><hr><div class="CalloutCell"><a name="86678"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">WARNING:  </font></b></a>The rt11Fs file system is considered obsolescent. In a future release of VxWorks, rt11Fs may not be supported.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85641">4.3.1  &nbsp;&nbsp;Disk Organization</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85643"> </a>The rtllFs file system uses a simple disk organization. Although this simplicity results in some loss of flexibility, rt11Fs is suitable for many real-time applications.</p><dd><p class="Body"><a name="85645"> </a>The rt11Fs file system maintains only <i class="term">contiguous files</i>. A contiguous file consists of a series of disk sectors that are consecutive. Contiguous files are well-suited to real-time applications because little time is spent locating specific portions of a file. The disadvantage of using contiguous files exclusively is that a disk can gradually become fragmented, reducing the efficiency of the disk space allocation.</p><dd><p class="Body"><a name="85646"> </a>The rt11Fs disk format uses a single directory to describe all files on the disk. The size of this directory is limited to a fixed number of directory entries. Along with regular files, unused areas of the disk are also described by special directory entries. These special entries are used to keep track of individual sections of free space on the disk.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85647">4.3.2  &nbsp;&nbsp;Initializing the rt11Fs File System</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85649"> </a>Before any other operations can be performed, the rt11Fs file system library, <b class="library">rt11FsLib</b>, must be initialized by calling <b class="routine"><i class="routine">rt11FsInit</i></b><b>(&nbsp;)</b>. This routine takes a single parameter, the maximum number of rt11Fs file descriptors that can be open at one time. This count is used to allocate a set of descriptors; a descriptor is used each time a file or an rt11Fs device is opened.</p><dd><p class="Body"><a name="85652"> </a>The <b class="routine"><i class="routine">rt11FsInit</i></b><b>(&nbsp;)</b> routine also makes an entry for the rt11Fs file system in the I/O system driver table (with <b class="routine"><i class="routine">iosDrvInstall</i></b><b>(&nbsp;)</b>). This entry specifies entry points for the rt11Fs file operations and is used for all devices that use the rt11Fs file system. The driver number assigned to the rt11Fs file systems is placed in a global variable <b class="symbol_lc">rt11FsDrvNum</b>.</p><dd><p class="Body"><a name="85654"> </a>The <b class="routine"><i class="routine">rt11FsInit</i></b><b>(&nbsp;)</b> routine is normally called by the <b class="routine"><i class="routine">usrRoot</i></b><b>(&nbsp;)</b> task after starting the VxWorks system. To use this initialization, make sure <b class="symbol_UC">INCLUDE_RT11FS</b> is selected for inclusion in the project facility VxWorks view, and set <b class="symbol_UC">NUM_RT11FS_FILES</b> to the desired maximum open file count in the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Params</font></b> tab of the properties window.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85658">4.3.3  &nbsp;&nbsp;Initializing a Device for Use with rt11Fs</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85660"> </a>After the rt11Fs file system is initialized, the next step is to create one or more devices. Devices are created by the device driver's device creation routine (<i class="textVariable">xx</i><b class="routine"><i class="routine">DevCreate</i></b><b>(&nbsp;)</b>). The driver routine returns a pointer to a block device descriptor structure (<b class="symbol_UC">BLK_DEV</b>). The <b class="symbol_UC">BLK_DEV</b> structure describes the physical aspects of the device and specifies the routines in the device driver that a file system can call. For more information about block devices, see <a href="c-iosys9.html#85946"><i class="title">3.9.4&nbsp;Block Devices</i></a>.</p><dd><p class="Body"><a name="85665"> </a>Immediately after its creation, the block device has neither a name nor a file system associated with it. To initialize a block device for use with rt11Fs, the already-created block device must be associated with rt11Fs and must have a name assigned to it. This is done with <b class="routine"><i class="routine">rt11FsDevInit</i></b><b>(&nbsp;)</b>. Its parameters are:</p></dl><dl class="margin"><p class="listspace"><ul class="Dash" type="circle"><li><a name="85667"> </a>the name to be used to identify the device</li></ul></p><p class="listspace"><ul class="Dash" type="circle"><li><a name="85668"> </a>a pointer to the <b class="symbol_UC">BLK_DEV</b> structure</li></ul></p><p class="listspace"><ul class="Dash" type="circle"><li><a name="85669"> </a>a boolean value indicating whether the disk uses standard RT-11 skew and interleave</li></ul></p><p class="listspace"><ul class="Dash" type="circle"><li><a name="85670"> </a>the number of entries to be used in the disk directory (in some cases, the actual number used is greater than the number specified)</li></ul></p><p class="listspace"><ul class="Dash" type="circle"><li><a name="85671"> </a>a boolean value indicating whether this disk is subject to being changed without notification to the file system</li></ul></p></dl><dl class="margin"><dd><p class="Body"><a name="85672"> </a>For example:</p></dl><dl class="margin"><dd><pre class="Code"><b><a name="85673">RT_VOL_DESC&nbsp;&nbsp;*pVolDesc; pVolDesc&nbsp;=&nbsp;rt11FsDevInit&nbsp;("DEV1:",&nbsp;pBlkDev,&nbsp;rtFmt,&nbsp;nEntries,&nbsp;changeNoWarn);</a></b></pre></dl><dl class="margin"><dd><p class="Body"><a name="85674"> </a>The <b class="routine"><i class="routine">rt11FsDevInit</i></b><b>(&nbsp;)</b> call assigns the specified name to the device and enters the device in the I/O system device table (with <b class="routine"><i class="routine">iosDevAdd</i></b><b>(&nbsp;)</b>). It also allocates and initializes the file system's volume descriptor for the device. It returns a pointer to the volume descriptor to the caller; this pointer is used to identify the volume during some file system calls.</p><dd><p class="Body"><a name="85676"> </a>Note that initializing the device for use with the rt11Fs file system does not format the disk, nor does it initialize the rt11Fs disk directory. These are done using <b class="routine"><i class="routine">ioctl</i></b><b>(&nbsp;)</b> with the functions <b class="symbol_UC">FIODISKFORMAT</b> and <b class="symbol_UC">FIODISKINIT</b>, respectively.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85680">4.3.4  &nbsp;&nbsp;Mounting Volumes</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85682"> </a>A disk volume is <i class="term">mounted</i> automatically, generally during the first <b class="routine"><i class="routine">open</i></b><b>(&nbsp;)</b> or <b class="routine"><i class="routine">creat</i></b><b>(&nbsp;)</b> for a file or directory on the disk. (Certain <b class="routine"><i class="routine">ioctl</i></b><b>(&nbsp;)</b> functions also cause the disk to be mounted.) When a disk is mounted, the directory data is read it.</p><dd><p class="Body"><a name="87151"> </a>Automatic mounting reoccurs on the first file access following a ready-change operation (see <a href="c-filesys3.html#85711"><i class="title">4.3.8&nbsp;Changing Disks</i></a>) or periodically if the disk is defined during the <b class="routine"><i class="routine">rt11FsDevInit</i></b><b>(&nbsp;)</b> call with the <b class="symbol_lc">changeNoWarn</b> parameter set to TRUE. Automatic mounting does not occur when a disk is opened in raw mode. For more information, see <a href="c-filesys3.html#85697"><i class="title">4.3.6&nbsp;Opening the Whole Device (Raw Mode)</i></a>.</p></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/caution.gif"></td><td><hr><div class="CalloutCell"><a name="87162"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">CAUTION:  </font></b></a>Because device names are recognized by the I/O system using simple substring matching, file systems should not use a slash (<b>/</b>) alone as a name; unexpected results may occur.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="87168">4.3.5  &nbsp;&nbsp;File I/O</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85692"> </a>Files on an rt11Fs file system device are created, deleted, written, and read using the standard VxWorks I/O routines: <b class="routine"><i class="routine">creat</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">remove</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">write</i></b><b>(&nbsp;)</b>, and <b class="routine"><i class="routine">read</i></b><b>(&nbsp;)</b>. The size of an rt11Fs file is determined during its initial <b class="routine"><i class="routine">open</i></b><b>(&nbsp;)</b> or <b class="routine"><i class="routine">creat</i></b><b>(&nbsp;)</b>. Once closed, additional space cannot be allocated to the file. For more information, see <a href="c-iosys3.html#83659"><i class="title">3.3&nbsp;Basic I/O</i></a>.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85697">4.3.6  &nbsp;&nbsp;Opening the Whole Device (Raw Mode)</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85699"> </a>It is possible to open an entire rt11Fs volume by specifying only the device name during the <b class="routine"><i class="routine">open</i></b><b>(&nbsp;)</b> or <b class="routine"><i class="routine">creat</i></b><b>(&nbsp;)</b> call. A file descriptor is returned, as when opening a regular file; however, operations on that file descriptor affect the entire device. Opening the entire volume in this manner is called <i class="term">raw mode</i>.</p><dd><p class="Body"><a name="85701"> </a>The most common reason for opening the entire device is to obtain a file descriptor to perform an <b class="routine"><i class="routine">ioctl</i></b><b>(&nbsp;)</b> function that does not pertain to an individual file. An example is the <b class="symbol_UC">FIOSQUEEZE</b> function, which combines fragmented free space across the entire volume.</p><dd><p class="Body"><a name="85702"> </a>When a disk is initialized with an rt11Fs directory, open the device in raw mode. The <b class="routine"><i class="routine">ioctl</i></b><b>(&nbsp;)</b> function <b class="symbol_UC">FIODISKINIT</b> performs the initialization.</p><dd><p class="Body"><a name="85703"> </a>A disk can be read or written in raw mode. In this case, the entire disk area is treated much like a single large file. No directory entry is made to describe any data written using raw mode, and care must be taken to avoid overwriting the regular rt11Fs directory at the beginning of the disk. This type of I/O is also provided by <b class="library">rawFsLib</b>.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85705">4.3.7  &nbsp;&nbsp;Reclaiming Fragmented Free Disk Space</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85707"> </a>As previously mentioned, the contiguous file allocation scheme used by the rt11Fs file system can gradually result in disk fragmentation. In this situation, the available free space on the disk is scattered in a number of small chunks. This reduces the ability of the system to create new files.</p><dd><p class="Body"><a name="85709"> </a>To correct this condition, <b class="library">rt11FsLib</b> includes the <b class="routine"><i class="routine">ioctl</i></b><b>(&nbsp;)</b> function <b class="symbol_UC">FIOSQUEEZE</b>. This routine moves files so that the free space is combined at the end of the disk. When you call <b class="routine"><i class="routine">ioctl</i></b><b>(&nbsp;)</b> with <b class="symbol_UC">FIOSQUEEZE</b>, it is critical that there be no open files on the device. With large disks, this call may require considerable time to execute.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85711">4.3.8  &nbsp;&nbsp;Changing Disks</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85713"> </a>To increase performance, rt11Fs keeps copies of directory entries for each volume in memory. While this greatly speeds up access to files, it requires that <b class="library">rt11FsLib</b> be notified when removable disks are changed (for example, when floppies are swapped). This notification is provided by the ready-change mechanism.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="85715">Announcing Disk Changes with Ready-Change</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85717"> </a>A change in ready-status is interpreted by <b class="library">rt11FsLib</b> to mean that the disk must be remounted during the next I/O operation. There are three ways to announce a ready-change:</p></dl><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="85719"> </a>By calling <b class="routine"><i class="routine">rt11FsReadyChange</i></b><b>(&nbsp;)</b> directly.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="85721"> </a>By calling <b class="routine"><i class="routine">ioctl</i></b><b>(&nbsp;)</b> with <b class="symbol_UC">FIODISKCHANGE</b>.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="85722"> </a>By having the device driver set the <b class="symbol_lc">bd_readyChanged</b> field in the <b class="symbol_UC">BLK_DEV</b> structure to TRUE; this has the same effect as notifying <b class="library">rt11FsLib</b> directly.</li></ul>

⌨️ 快捷键说明

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