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

📄 tapefslib.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/tapeFsLib.html - generated by refgen from tapeFsLib.c --> <title> tapeFsLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.html"><i>VxWorks Reference Manual :  Libraries</i></a></p></blockquote><h1>tapeFsLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>tapeFsLib</strong> - tape sequential device file system library </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><i><a href="./tapeFsLib.html#tapeFsDevInit">tapeFsDevInit</a></i>(&nbsp;)</b>  -  associate a sequential device with tape volume functions<br><b><i><a href="./tapeFsLib.html#tapeFsInit">tapeFsInit</a></i>(&nbsp;)</b>  -  initialize the tape volume library<br><b><i><a href="./tapeFsLib.html#tapeFsReadyChange">tapeFsReadyChange</a></i>(&nbsp;)</b>  -  notify <b><a href="./tapeFsLib.html#top">tapeFsLib</a></b> of a change in ready status<br><b><i><a href="./tapeFsLib.html#tapeFsVolUnmount">tapeFsVolUnmount</a></i>(&nbsp;)</b>  -  disable a tape device volume<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides basic services for tape devices that do notuse a standard file or directory structure on tape.  The tape volume is treatedmuch like a large file. The tape may either be read or written. However, thereis no high-level organization of the tape into files or directories, which must be provided by a higher-level layer.<p></blockquote><h4>USING THIS LIBRARY</h4><blockquote><p>The various routines provided by the VxWorks tape file system, or tapeFs, canbe categorized into three broad groupings: general initialization,device initialization, and file system operation.<p>The <b><i><a href="./tapeFsLib.html#tapeFsInit">tapeFsInit</a></i>(&nbsp;)</b> routine is the principal general initialization function;it needs to be called only once, regardless of how many tapeFs devicesare used.<p>To initialize devices, <b><i><a href="./tapeFsLib.html#tapeFsDevInit">tapeFsDevInit</a></i>(&nbsp;)</b> must be called for each tapeFs device.<p>Use of this library typically occurs through standard use of the I/O systemroutines <b><i><a href="./ioLib.html#open">open</a></i>(&nbsp;)</b>, <b><i><a href="./ioLib.html#close">close</a></i>(&nbsp;)</b>, <b><i><a href="./ioLib.html#read">read</a></i>(&nbsp;)</b>, <b><i><a href="./ioLib.html#write">write</a></i>(&nbsp;)</b> and <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>(&nbsp;)</b>.  Besides these standard I/O system operations, several routines are provided to inform the file system of changes in the system environment.  The <b><i><a href="./tapeFsLib.html#tapeFsVolUnmount">tapeFsVolUnmount</a></i>(&nbsp;)</b> routine informs the file system that a particular device should be unmounted; any synchronization should be done prior to invocation of this routine, in preparation for a tape volume change. The <b><i><a href="./tapeFsLib.html#tapeFsReadyChange">tapeFsReadyChange</a></i>(&nbsp;)</b> routine is used to inform the file system that atape may have been swapped and that the next tape operation should firstremount the tape. Information about a ready-change is also obtained from the driver using the <b>SEQ_DEV</b> device structure. Note that <b><i><a href="./tapeFsLib.html#tapeFsVolUnmount">tapeFsVolUnmount</a></i>(&nbsp;)</b> and<b><i><a href="./tapeFsLib.html#tapeFsReadyChange">tapeFsReadyChange</a></i>(&nbsp;)</b> should be called only after a file has been closed.<p></blockquote><h4>INITIALIZATION OF THE FILE SYSTEM</h4><blockquote><p>Before any other routines in <b><a href="./tapeFsLib.html#top">tapeFsLib</a></b> can be used, <b><i><a href="./tapeFsLib.html#tapeFsInit">tapeFsInit</a></i>(&nbsp;)</b> must be called to initialize the library. This implementationof the tape file system assumes only one file descriptor per volume. However,this constraint can be changed in case a future implementation demandsmultiple file descriptors per volume.<p>During the <b><i><a href="./tapeFsLib.html#tapeFsInit">tapeFsInit</a></i>(&nbsp;)</b> call, the tape device library is installed as a driverin the I/O system driver table.  The driver number associated with it isthen placed in a global variable, <b>tapeFsDrvNum</b>.<p>To enable this initialization, define <b>INCLUDE_TAPEFS</b> in the BSP, or simply start using the tape file system with a call to <b><i><a href="./tapeFsLib.html#tapeFsDevInit">tapeFsDevInit</a></i>(&nbsp;)</b> and <b><i><a href="./tapeFsLib.html#tapeFsInit">tapeFsInit</a></i>(&nbsp;)</b> will be called automatically if it has not been called before. <p></blockquote><h4>DEFINING A TAPE DEVICE</h4><blockquote><p>To use this library for a particular device, the device structureused by the device driver must contain, as the very first item, asequential device description structure (<b>SEQ_DEV</b>).  The <b>SEQ_DEV</b> must be initialized before calling <b><i><a href="./tapeFsLib.html#tapeFsDevInit">tapeFsDevInit</a></i>(&nbsp;)</b>. The driver places in the <b>SEQ_DEV</b> structure the addresses of routines that it must supply:  one that reads oneor more blocks, one that writes one or more blocks, one that performsI/O control (<b><i><a href="./ioLib.html#ioctl">ioctl</a></i>(&nbsp;)</b>) on the device, one that writes file marks on a tape, one that rewinds the tape volume, one that reserves a tape device for use,one that releases a tape device after use, one that mounts/unmounts a volume,one that spaces forward or backwards by blocks or file marks, one that erasesthe tape, one that resets the tape device, and one that checks the status of the device.The <b>SEQ_DEV</b> structure also contains fields that describe the physical configuration of the device.  For more information about defining sequentialdevices, see the <i>VxWorks Programmer's Guide: I/O System. </i><p></blockquote><h4>INITIALIZATION OF THE DEVICE </h4><blockquote><p>The <b><i><a href="./tapeFsLib.html#tapeFsDevInit">tapeFsDevInit</a></i>(&nbsp;)</b> routine is used to associate a device with the <b><a href="./tapeFsLib.html#top">tapeFsLib</a></b>functions.  The <b>volName</b> parameter expected by <b><i><a href="./tapeFsLib.html#tapeFsDevInit">tapeFsDevInit</a></i>(&nbsp;)</b> is a pointer toa name string which identifies the device.  This string serves asthe pathname for I/O operations which operate on the device and  appears in the I/O system device table, which can be displayedusing <b><i><a href="./iosShow.html#iosDevShow">iosDevShow</a></i>(&nbsp;)</b>.<p>The <b>pSeqDev</b> parameter expected by <b><i><a href="./tapeFsLib.html#tapeFsDevInit">tapeFsDevInit</a></i>(&nbsp;)</b> is a pointerto the <b>SEQ_DEV</b> structure describing the device and containing theaddresses of the required driver functions.  <p>The <b>pTapeConfig</b> parameter is a pointer to a <b>TAPE_CONFIG</b> structure that contains information specifying how the tape device should be configured. The configuration items are fixed/variable block size, rewind/no-rewind device,and number of file marks to be written. For more information about the <b>TAPE_CONFIG</b> structure, look at the header file <b>tapeFsLib.h</b>. <p>The syntax of the <b><i><a href="./tapeFsLib.html#tapeFsDevInit">tapeFsDevInit</a></i>(&nbsp;)</b> routine is as follows:<pre>    tapeFsDevInit        (        char *        volName,     /* name to be used for volume   */        SEQ_DEV *     pSeqDev,     /* pointer to device descriptor */        TAPE_CONFIG * pTapeConfig  /* pointer to tape config info  */        )</pre>When <b><a href="./tapeFsLib.html#top">tapeFsLib</a></b> receives a request from the I/O system, after <b><i><a href="./tapeFsLib.html#tapeFsDevInit">tapeFsDevInit</a></i>(&nbsp;)</b>has been called, it calls the device driver routines (whose addresses werepassed in the <b>SEQ_DEV</b> structure) to access the device.<p></blockquote><h4>OPENING AND CLOSING A FILE</h4><blockquote><p>A tape volume is opened by calling the I/O system routine <b><i><a href="./ioLib.html#open">open</a></i>(&nbsp;)</b>. A file canbe opened only with the <b>O_RDONLY</b> or <b>O_WRONLY</b> flags. The <b>O_RDWR</b> mode is not used by this library. A call to<b><i><a href="./ioLib.html#open">open</a></i>(&nbsp;)</b> initializes the file descriptor buffer and state information, reservesthe tape device, rewinds the tape device if it was configured as a rewinddevice, and mounts a volume. Once a tape volume has been opened, that tapedevice is reserved, disallowing any other system from accessing that device until the tape volume is closed. Also, the single file descriptor is marked"in use" until the file is closed, making sure that a file descriptor isnot opened multiple times.<p>A tape device is closed by calling the I/O system routine <b><i><a href="./ioLib.html#close">close</a></i>(&nbsp;)</b>. Upon a <b><i><a href="./ioLib.html#close">close</a></i>(&nbsp;)</b> request, any unwrittenbuffers are flushed, the device is rewound (if it is a rewind device), and, finally, the device is released.<p></blockquote><h4>UNMOUNTING VOLUMES (CHANGING TAPES)</h4><blockquote><p>A tape volume should be unmounted before it is removed.  When unmounting a volume, make sure that any open file is closed first.A tape may be unmounted by calling <b><i><a href="./tapeFsLib.html#tapeFsVolUnmount">tapeFsVolUnmount</a></i>(&nbsp;)</b> directly.<p>If a file is open, it is not correct to change the medium and continue with the same file descriptor still open.Since tapeFs assumes only one file descriptor per device, to reuse that device, the file must be closed and opened later for the new tape volume.<p>Before <b><i><a href="./tapeFsLib.html#tapeFsVolUnmount">tapeFsVolUnmount</a></i>(&nbsp;)</b> is called, the device should be synchronized by invoking the <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>(&nbsp;)</b> FIOSYNC or FIOFLUSH. It is the responsibilityof the higher-level layer to synchronize the tape file system before unmounting. Failure to synchronize the volume before unmounting may resultin loss of data.<p></blockquote><h4>IOCTL FUNCTIONS</h4><blockquote><p>The VxWorks tape sequential device file system supports the following <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>(&nbsp;)</b>functions.  The functions listed are defined in the header files <b>ioLib.h</b> and <b>tapeFsLib.h</b>.<p><dl><dt><b>FIOFLUSH</b><dd>Writes all modified file descriptor buffers to the physical device.<pre>    status = ioctl (fd, FIOFLUSH, 0);</pre><dt><b>FIOSYNC</b><dd>Performs the same function as FIOFLUSH.<p><dt><b>FIOBLKSIZEGET</b><dd>Returns the value of the block size set on the physical device. This valueis compared against the <b>sd_blkSize</b> value set in the <b>SEQ_DEV</b> device structure.<p><dt><b>FIOBLKSIZESET</b><dd>Sets a specified block size value on the physical device and also updates thevalue in the <b>SEQ_DEV</b> and <b>TAPE_VOL_DESC</b> structures, unless the supplied valueis zero, in which case the device structures are updated but the device is not set to zero. This is because zero implies variable block operations,therefore the device block size is ignored.<p><dt><b>MTIOCTOP</b><dd>Allows use of the standard UNIX MTIO <b>ioctl</b> operationsby means of the MTOP structure. The MTOP structure appears as follows:<pre>typedef struct mtop    {    short       mt_op;                  /* operation */    int         mt_count;               /* number of operations */    } MTOP;</pre>Use these <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>(&nbsp;)</b> operations as follows:<pre>    MTOP mtop;    mtop.mt_op    = MTWEOF;    mtop.mt_count = 1;    status = ioctl (fd, MTIOCTOP, (int) &amp;mtop);</pre> </dl><p>The permissable values for <b>mt_op</b> are:<p><dl><dt>MTWEOF<dd>Writes an end-of-file record to tape. An end-of-file record is a file mark.<p><dt>MTFSF<dd>Forward space over a file mark and position the tape head in the gap betweenthe file mark just skipped and the next data block.Any buffered data is flushed out to the tape if the tape is in writemode.<p><dt>MTBSF<dd>Backward space over a file mark and position the tape head in the gap preceeding the file mark, that is, right before the file mark.Any buffered data is flushed out to the tape if the tape is in writemode.<p>

⌨️ 快捷键说明

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