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

📄 c-filesys5.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-filesys4.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-filesys6.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="86024">4.5  &nbsp;&nbsp;Tape File System: tapeFs</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86026"> </a>The tapeFs library, <b class="library">tapeFsLib</b>, provides basic services for tape devices that do not use a standard file or directory structure on tape. The tape volume is treated much like a raw device where the entire volume is a large file. Any data organization on this large file is the responsibility of a higher-level layer.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="86027">4.5.1  &nbsp;&nbsp;Tape Organization</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86029"> </a>The tapeFs file system imposes no organization of the data on the tape volume. It maintains no directory information; there is no division of the tape area into specific files; and no file names are used. An <b class="routine"><i class="routine">open</i></b><b>(&nbsp;)</b> operation on the tapeFs device specifies only the device name; no additional file names are allowed.</p><dd><p class="Body"><a name="86030"> </a>The entire tape area is available to any file descriptor open for the device. All read and write operations to the tape use a location offset relative to the current location of the tape head. When a file is configured as a rewind device and first opened, tape operations begin at the beginning-of-medium (BOM); see <a href="c-filesys5.html#86052"><i class="title">Initializing a Device for Use with the tapeFs File System</i></a>. Thereafter, all operations occur relative to where the tape head is located at that instant of time. No location information, as such, is maintained by tapeFs. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="87230">4.5.2  &nbsp;&nbsp;Using the tapeFs File System</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="87232"> </a>Before tapeFs can be used, it must be configured by defining <b class="symbol_UC">INCLUDE_TAPEFS</b> in the BSP file <b class="file">config.h</b>. (See <a href="c-config5.html#85532"><i class="title">8.5&nbsp;Configuring VxWorks</i></a>.) Note that the tape file system must be configured with SCSI-2 enabled. See <a href="c-iosys7.html#97119"><i class="title">Configuring SCSI Drivers</i></a> for configuration details. </p><dd><p class="Body"><a name="86040"> </a>Once the tape file system has been configured, you must initialize it and then define a tape device. Once the device is initialized, the physical tape device is available to the tape file system and normal I/O system operations can be performed. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="86041">Initializing the tapeFs File System</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86044"> </a>The tapeFs library, <b class="library">tapeFsLib</b>, is initialized by calling <b class="routine"><i class="routine">tapeFsInit</i></b><b>(&nbsp;)</b>. Each tape file system can handle multiple tape devices. However, each tape device is allowed only one file descriptor. Thus you cannot open two files on the same tape device.</p><dd><p class="Body"><a name="86045"> </a>The <b class="routine"><i class="routine">tapeFsInit</i></b><b>(&nbsp;)</b> routine also makes an entry for the tapeFs 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 function pointers to carry out tapeFs file operations on devices that use the tapeFs file system. The driver number assigned to the tapeFs file system is placed in a global variable, <b class="symbol_lc">tapeFsDrvNum</b>.</p><dd><p class="Body"><a name="86048"> </a>When initializing a tape device, <b class="routine"><i class="routine">tapeFsInit</i></b><b>(&nbsp;)</b> is called automatically if <b class="routine"><i class="routine">tapeFsDevInit</i></b><b>(&nbsp;)</b> is called; thus, the tape file system does not require explicit initialization.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="86052">Initializing a Device for Use with the tapeFs File System</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86053"> </a>Once the tapeFs file system has been initialized, the next step is to create one or more devices that can be used with it. This is done using the sequential device creation routine, <b class="routine"><i class="routine">scsiSeqDevCreate</i></b><b>(&nbsp;)</b>. The driver routine returns a pointer to a sequential device descriptor structure, <b class="symbol_UC">SEQ_DEV</b>. The <b class="symbol_UC">SEQ_DEV</b> structure describes the physical aspects of the device and specifies the routines in the device driver that tapeFs can call. For more information on sequential devices, see the manual entry for <b class="routine"><i class="routine">scsiSeqDevCreate</i></b><b>(&nbsp;)</b>, <a href="c-iosys7.html#97119"><i class="title">Configuring SCSI Drivers</i></a>, <a href="c-iosys9.html#85946"><i class="title">3.9.4&nbsp;Block Devices</i></a>, and <a href="c-iosys7.html#88241">Example&nbsp;3-6</a>.</p><dd><p class="Body"><a name="86065"> </a>Immediately after its creation, the sequential device has neither a name nor a file system associated with it. To initialize a sequential device for use with tapeFs, call <b class="routine"><i class="routine">tapeFsDevInit</i></b><b>(&nbsp;)</b> to assign a name and declare a file system. Its parameters are the volume name, for identifying the device; a pointer to <b class="symbol_UC">SEQ_DEV</b>, the sequential device descriptor structure; and a pointer to an initialized tape configuration structure <b class="symbol_UC">TAPE_CONFIG. </b>This structure has the following form:</p></dl><dl class="margin"><dd><pre class="Code"><b><a name="86067">typedef struct  /* TAPE_CONFIG tape device config structure */     {     int blkSize;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* block size; 0 =&gt; var. block size */     BOOL rewind;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* TRUE =&gt; a rewind device; FALSE =&gt; no rewind */     int numFileMarks; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* not used */     int density;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* not used */     } TAPE_CONFIG;</a></b></pre></dl><dl class="margin"><dd><p class="Body"><a name="86074"> </a>In the preceding definition of <b class="symbol_UC">TAPE_CONFIG</b>, only two fields, <b class="symbol_lc">blkSize</b> and <b class="symbol_lc">rewind</b>, are currently in use. If <b class="symbol_lc">rewind</b> is TRUE, then a tape device is rewound to the beginning-of-medium (BOM) upon closing a file with <b class="routine"><i class="routine">close</i></b><b>(&nbsp;)</b>. However, if <b class="symbol_lc">rewind</b> is FALSE, then closing a file has no effect on the position of the read/write head on the tape medium.</p><dd><p class="Body"><a name="86075"> </a>For more information on initializing a tapeFs device, see the online reference for <b class="routine"><i class="routine">tapeFsDevInit</i></b><b>(&nbsp;)</b> under <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">VxWorks Reference Manual&gt;Libraries</font></b>.</p><dd><p class="Body"><a name="86076"> </a>The <b class="symbol_lc">blkSize</b> field specifies the block size of the physical tape device. Having set the block size, each read or write operation has a transfer unit of <b class="symbol_lc">blkSize</b>. Tape devices can perform fixed or variable block transfers, a distinction also captured in the <b class="symbol_lc">blkSize</b> field.</p></dl></dl><dl class="margin"><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="86078">Fixed Block and Variable Block Devices</a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="86080"> </a>A tape file system can be created for fixed block size transfers or variable block size transfers, depending on the capabilities of the underlying physical device. The type of data transfer (fixed block or variable block) is usually decided when the tape device is being created in the file system, that is, before the call to <b class="routine"><i class="routine">tapeFsDevInit</i></b><b>(&nbsp;)</b>. A block size of zero represents variable block size data transfers.</p><dd><p class="Body"><a name="86081"> </a>Once the block size has been set for a particular tape device, it is usually not modified. To modify the block size, use the <b class="routine"><i class="routine">ioctl</i></b><b>(&nbsp;)</b> functions <b class="symbol_UC">FIOBLKSIZESET</b> and <b class="symbol_UC">FIOBLKSIZEGET</b> to set and get the block size on the physical device.</p><dd><p class="Body"><a name="86084"> </a>Note that for fixed block transfers, the tape file system buffers a block of data. If the block size of the physical device is changed after a file is opened, the file should first be closed and then re-opened in order for the new block size to take effect.</p></dl></dl><h4 class="EntityTitle"><a name="86086"><font face="Helvetica, sans-serif" size="-1" class="sans">Example 4-4:&nbsp;&nbsp;Tape Device Configuration</font></a></h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86087"> </a>There are many ways to configure a tape device. In this code example, a tape device is configured with a block size of 512 bytes and the option to rewind the device at the end of operations.</p><dl class="margin"><dd><pre class="Code2"><b><a name="86088">/* global variables assigned elsewhere */  SCSI_PHYS_DEV *&nbsp;&nbsp;&nbsp;pScsiPhysDev;  /* local variable declarations */  TAPE_VOL_DESC&nbsp;*&nbsp;&nbsp;pTapeVol; SEQ_DEV&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pSeqDev; TAPE_CONFIG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pTapeConfig;  /* initialization code */  pTapeConfig.blkSize&nbsp;&nbsp;= 512; pTapeConfig.rewind &nbsp;&nbsp;= TRUE; pSeqDev &nbsp;&nbsp;&nbsp;= scsiSeqDevCreate (pScsiPhysDev); pTapeVol &nbsp;&nbsp;= tapeFsDevInit ("/tape1", pSeqDev, pTapeConfig); </a></b></pre></dl><dd><p class="Body"><a name="86089"> </a>The <b class="routine"><i class="routine">tapeFsDevInit</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>). The return value of this routine is a pointer to a volume descriptor structure that contains volume-specific configuration and state information.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="86092">Mounting Volumes </a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86093"> </a>A tape volume is <i class="term">mounted</i> automatically during the <b class="routine"><i class="routine">open</i></b><b>(&nbsp;)</b> operation. There is no specific mount operation, that is, the mount is implicit in the <b class="routine"><i class="routine">open</i></b><b>(&nbsp;)</b> operation. </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="87197"><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="H4"><i><a name="86094">Modes of Operation</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86096"> </a>The tapeFs tape volumes can be operated in only one of two modes: read-only (<b class="symbol_UC">O_RDONLY</b>) or write-only (<b class="symbol_UC">O_WRONLY</b>). There is no read-write mode. The mode of operation is defined when the file is opened using <b class="routine"><i class="routine">open</i></b><b>(&nbsp;)</b>.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="86098">File I/O</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86100"> </a>To begin I/O to a tapeFs device, the device is first opened using <b class="routine"><i class="routine">open</i></b><b>(&nbsp;)</b>. Data on the tapeFs device is written and read using the standard I/O routines <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>. For more information, see <a href="c-iosys7.html#84932"><i class="title">3.7.6&nbsp;Block Devices</i></a>.</p><dd><p class="Body"><a name="86105"> </a>End-of-file markers can be written using <b class="routine"><i class="routine">ioctl</i></b><b>(&nbsp;)</b> with the <b class="symbol_UC">MTWEOF </b>function. For more information, see <a href="c-filesys5.html#86119"><i class="title">I/O Control Functions Supported by tapeFsLib</i></a>.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="86109">Changing Tapes</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86111"> </a>The tapeFs file system should be notified when removable media are changed (for example, when tapes are swapped). The <b class="routine"><i class="routine">tapeFsVolUnmount</i></b><b>(&nbsp;)</b> routine controls the mechanism to unmount a tape volume.</p><dd><p class="Body"><a name="86113"> </a>A tape should be unmounted before it is removed. Prior to unmounting a tape volume, an open file descriptor must be closed. Closing an open file flushes any buffered data to the tape, thus synchronizing the file system with the data on the tape. To flush or synchronize data, call <b class="routine"><i class="routine">ioctl</i></b><b>(&nbsp;)</b> with the <b class="symbol_UC">FIOFLUSH</b> or <b class="symbol_UC">FIOSYNC </b>functions, prior to closing the file descriptor. </p><dd><p class="Body"><a name="86116"> </a>After closing any open file, call <b class="routine"><i class="routine">tapeFsVolUnmount</i></b><b>(&nbsp;)</b> before removing the tape. Once a tape has been unmounted, the next I/O operation must remount the tape using <b class="routine"><i class="routine">open</i></b><b>(&nbsp;)</b>. </p><dd><p class="Body"><a name="86117"> </a>Interrupt handlers must not call <b class="routine"><i class="routine">tapeFsVolUnmount</i></b><b>(&nbsp;)</b> directly, because it is possible for the call to pend while the device becomes available. The interrupt handler can instead give a semaphore that prompts a task to unmount the volume. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="86119">I/O Control Functions Supported by <b class="library">tapeFsLib</b></a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86124"> </a>The tapeFs file system supports the <b class="routine"><i class="routine">ioctl</i></b><b>(&nbsp;)</b> functions shown in <a href="c-filesys5.html#86128">Table&nbsp;4-8</a>. The functions listed are defined in the header files <b class="file">ioLib.h</b>,<b class="file"> seqIo.h</b>, and <b>tapeFsLib.h. </b>For more information, see the reference entries for <b class="library">tapeFsLib</b>, <b class="library">ioLib</b>, and <b class="routine"><i class="routine">ioctl</i></b><b>(&nbsp;)</b>.<p class="table"><h4 class="EntityTitle"><a name="86128"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 4-8:&nbsp;&nbsp;I/O Control Functions Supported by <b class="library">tapeFsLib&nbsp;</b></font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="86134"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Function</font></b></div></th><th rowspan="1" colspan="1"><div class="CellHeadingC" align="center"><a name="86136"> </a><b><font face="Helvetica, sans-serif" size="-1" class="sans">Value</font></b></div></th><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="86138"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Meaning</font></b></div></th></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86140"> </a><b class="symbol_UC">FIOFLUSH</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="86142"> </a>2</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86144"> </a>Write out all modified file descriptor buffers.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86146"> </a><b class="symbol_UC">FIOSYNC</b> &nbsp;</div>

⌨️ 快捷键说明

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