📄 rt11fslib.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/rt11FsLib.html - generated by refgen from rt11FsLib.c --> <title> rt11FsLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.htm"><i>VxWorks API Reference : OS Libraries</i></a></p></blockquote><h1>rt11FsLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>rt11FsLib</strong> - RT-11 media-compatible file system library </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./rt11FsLib.html#rt11FsDevInit">rt11FsDevInit</a>( )</b> - initialize the rt11Fs device descriptor<br><b><a href="./rt11FsLib.html#rt11FsInit">rt11FsInit</a>( )</b> - prepare to use the rt11Fs library<br><b><a href="./rt11FsLib.html#rt11FsMkfs">rt11FsMkfs</a>( )</b> - initialize a device and create an rt11Fs file system<br><b><a href="./rt11FsLib.html#rt11FsDateSet">rt11FsDateSet</a>( )</b> - set the rt11Fs file system date<br><b><a href="./rt11FsLib.html#rt11FsReadyChange">rt11FsReadyChange</a>( )</b> - notify rt11Fs of a change in ready status<br><b><a href="./rt11FsLib.html#rt11FsModeChange">rt11FsModeChange</a>( )</b> - modify the mode of an rt11Fs volume<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides services for file-oriented device drivers which usethe RT-11 file standard. This module takes care of all the necessary buffering, directory maintenance, and RT-11-specific details.<p></blockquote><h4>USING THIS LIBRARY</h4><blockquote><p>The various routines provided by the VxWorks RT-11 file system (rt11Fs) maybe separated into three broad groups: general initialization,device initialization, and file system operation.<p>The <b><a href="./rt11FsLib.html#rt11FsInit">rt11FsInit</a>( )</b> routine is the principal initialization function;it need only be called once, regardless of how many rt11Fs deviceswill be used.<p>Other rt11Fs routines are used for device initialization. Foreach rt11Fs device, either <b><a href="./rt11FsLib.html#rt11FsDevInit">rt11FsDevInit</a>( )</b> or <b><a href="./rt11FsLib.html#rt11FsMkfs">rt11FsMkfs</a>( )</b> must be calledto install the device and define its configuration.<p>Several functions are provided to inform the file system ofchanges in the system environment. The <b><a href="./rt11FsLib.html#rt11FsDateSet">rt11FsDateSet</a>( )</b> routine is usedto set the date. The <b><a href="./rt11FsLib.html#rt11FsModeChange">rt11FsModeChange</a>( )</b> routine is used tomodify the readability or writability of a particular device. The<b><a href="./rt11FsLib.html#rt11FsReadyChange">rt11FsReadyChange</a>( )</b> routine is used to inform the file system that adisk may have been swapped, and that the next disk operation should firstremount the disk.<p></blockquote><h4>INITIALIZING RT11FSLIB</h4><blockquote><p>Before any other routines in <b><a href="./rt11FsLib.html#top">rt11FsLib</a></b> can be used, <b><a href="./rt11FsLib.html#rt11FsInit">rt11FsInit</a>( )</b> must be called to initialize this library. This call specifies the maximum number of rt11Fs files that can be open simultaneously and allocates memory for that many rt11Fs file descriptors.Attempts to open more files than the specified maximum will resultin errors from <b><a href="./ioLib.html#open">open</a>( )</b> or <b><a href="./ioLib.html#creat">creat</a>( )</b>.<p>This initialization is enabled when the configuration macro<b>INCLUDE_RT11FS</b> is defined.<p></blockquote><h4>DEFINING AN RT-11 DEVICE</h4><blockquote><p>To use this library for a particular device, the device structure mustcontain, as the very first item, a <b>BLK_DEV</b> structure. This must beinitialized before calling <b><a href="./rt11FsLib.html#rt11FsDevInit">rt11FsDevInit</a>( )</b>. In the <b>BLK_DEV</b> structure, thedriver includes the addresses of five routines which it must supply: onethat reads one or more sectors, one that writes one or more sectors, onethat performs I/O control on the device (using <b><a href="./ioLib.html#ioctl">ioctl</a>( )</b>), one that checks thestatus of the device, and one that resets the device. This structure alsospecifies various physical aspects of the device (e.g., number of sectors,sectors per track, whether the media is removable). For more information aboutdefining block devices, see the<i>VxWorks Programmer's Guide: I/O System. </i><p>The device is associated with the rt11Fs file system by the<b><a href="./rt11FsLib.html#rt11FsDevInit">rt11FsDevInit</a>( )</b> call. The arguments to <b><a href="./rt11FsLib.html#rt11FsDevInit">rt11FsDevInit</a>( )</b> include the nameto be used for the rt11Fs volume, a pointer to the <b>BLK_DEV</b> structure,whether the device uses RT-11 standard skew and interleave, and themaximum number of files that can be contained in the device directory.<p>Thereafter, when the file system receives a request from the I/O system, itsimply calls the provided routines in the device driver to fulfill therequest.<p></blockquote><h4>RTFMT</h4><blockquote><p>The RT-11 standard defines a peculiar software interleave andtrack-to-track skew as part of the format. The <i>rtFmt</i> parameter passedto <b><a href="./rt11FsLib.html#rt11FsDevInit">rt11FsDevInit</a>( )</b> should be TRUE if this formatting is desired. Thisshould be the case if strict RT-11 compatibility is desired, or if filesmust be transferred between the development and target machines using theVxWorks-supplied RT-11 tools. Software interleave and skew willautomatically be dealt with by <b><a href="./rt11FsLib.html#top">rt11FsLib</a></b>.<p>When <i>rtFmt</i> has been passed as TRUE and the maximum number of files isspecified <b>RT_FILES_FOR_2_BLOCK_SEG</b>, the driver does not need to doanything else to maintain RT-11 compatibility (except to add the track offset as described above).<p>Note that if the number of files specified is different than<b>RT_FILES_FOR_2_BLOCK_SEG</b> under either a VxWorks system or an RT-11 system,compatibility is lost because VxWorks allocates a contiguous directory,whereas RT-11 systems create chained directories.<p></blockquote><h4>MULTIPLE LOGICAL DEVICES AND RT-11 COMPATIBILITY</h4><blockquote><p>The sector number passed to the sector read and write routines is anabsolute number, starting from sector 0 at the beginning of the device.If desired, the driver may add an offset from the beginning of thephysical device before the start of the logical device. This wouldnormally be done by keeping an offset parameter in the device-specificstructure of the driver, and adding the proper number of sectors to thesector number passed to the read and write routines.<p>The RT-11 standard defines the disk to start on track 1. Track 0 is setaside for boot information. Therefore, in order to retain truecompatibility with RT-11 systems, a one-track offset (i.e., the number ofsectors in one track) needs to be added to the sector numbers passed tothe sector read and write routines, and the device size needs to bedeclared as one track smaller than it actually is. This must be done bythe driver using <b><a href="./rt11FsLib.html#top">rt11FsLib</a></b>; the library does not add such an offsetautomatically.<p>In the VxWorks RT-11 implementation, the directory is a fixed size, ableto contain at least as many files as specified in the call to<b><a href="./rt11FsLib.html#rt11FsDevInit">rt11FsDevInit</a>( )</b>. If the maximum number of files is specified to be<b>RT_FILES_FOR_2_BLOCK_SEG</b>, strict RT-11 compatibility is maintained,because this is the initial allocation in the RT-11 standard.<p></blockquote><h4>RT-11 FILE NAMES</h4><blockquote><p>File names in the RT-11 file system use six characters, followedby a period (.), followed by an optional three-character extension.<p></blockquote><h4>DIRECTORY ENTRIES</h4><blockquote><p>An <b><a href="./ioLib.html#ioctl">ioctl</a>( )</b> call with the FIODIRENTRY function returns information about aparticular directory entry. A pointer to a <b>REQ_DIR_ENTRY</b> structure ispassed as the parameter. The field <b>entryNum</b> in the <b>REQ_DIR_ENTRY</b>structure must be set to the desired entry number. The name of the file,its size (in bytes), and its creation date are returned in the structure.If the specified entry is empty (i.e., if it represents an unallocatedsection of the disk), the name will be an empty string, the size will bethe size of the available disk section, and the date will be meaningless.Typically, the entries are accessed sequentially, starting with <b>entryNum</b> = 0,until the terminating entry is reached, indicated by a return code of ERROR.<p></blockquote><h4>DIRECTORIES IN MEMORY</h4><blockquote><p>A copy of the directory for each volume is kept in memory (in the <b>RT_VOL_DESC</b>structure). This speeds up directory accesses, but requires that <b><a href="./rt11FsLib.html#top">rt11FsLib</a></b>be notified when disks are changed (i.e., floppies are swapped). If thedriver can find this out (by interrogating controller status or byreceiving an interrupt), the driver simply calls <b><a href="./rt11FsLib.html#rt11FsReadyChange">rt11FsReadyChange</a>( )</b> when adisk is inserted or removed. The library <b><a href="./rt11FsLib.html#top">rt11FsLib</a></b> will automatically tryto remount the device next time it needs it.<p>If the driver does not have access to the information that disk volumeshave been changed, the <i>changeNoWarn</i> parameter should be set to TRUEwhen the device is defined using <b><a href="./rt11FsLib.html#rt11FsDevInit">rt11FsDevInit</a>( )</b>. This will cause thedisk to be automatically remounted before each <b><a href="./ioLib.html#open">open</a>( )</b>, <b><a href="./ioLib.html#creat">creat</a>( )</b>, <b>delete( )</b>,and directory listing.<p>The routine <b><a href="./rt11FsLib.html#rt11FsReadyChange">rt11FsReadyChange</a>( )</b> can also be called by user tasks, byissuing an <b><a href="./ioLib.html#ioctl">ioctl</a>( )</b> call with FIODISKCHANGE as the function code.<p></blockquote><h4>ACCESSING THE RAW DISK</h4><blockquote><p>As a special case in <b><a href="./ioLib.html#open">open</a>( )</b> and <b><a href="./ioLib.html#creat">creat</a>( )</b> calls, <b><a href="./rt11FsLib.html#top">rt11FsLib</a></b> recognizes a NULLfile name to indicate access to the entire "raw" disk, as opposed to afile on the disk. Access in raw mode is useful for a disk that has nofile system. For example, to initialize a new file system on the disk,use an <b><a href="./ioLib.html#ioctl">ioctl</a>( )</b> call with FIODISKINIT. To read the directory of a disk forwhich no file names are known, open the raw disk and use an <b><a href="./ioLib.html#ioctl">ioctl</a>( )</b> callwith the function FIODIRENTRY.<p></blockquote><h4>HINTS</h4><blockquote><p>The RT-11 file system is much simpler than the more common UNIX or MS-DOSfile systems. The advantage of RT-11 is its speed; file access is made inat most one seek because all files are contiguous. Some of the most commonerrors for users with a UNIX background are:<ul><li></li>Only a single create at a time may be active per device.<li></li>File size is set by the first create and close sequence;use <b><a href="./ioLib.html#lseek">lseek</a>( )</b> to ensure a specific file size;there is no append function to expand a file.<li></li>Files are strictly block oriented; unused portionsof a block are filled with NULLs -- there is noend-of-file marker other than the last block.</ul><p></blockquote><h4>IOCTL FUNCTIONS</h4><blockquote><p>The rt11Fs file system supports the following <b><a href="./ioLib.html#ioctl">ioctl</a>( )</b> functions.The functions listed are defined in the header <b>ioLib.h</b>. Unless statedotherwise, the file descriptor used for these functions can be any filedescriptor open to a file or to the volume itself.<p><dl><dt><b>FIODISKFORMAT</b><dd>Formats the entire disk with appropriate hardware track and sector marks.No file system is initialized on the disk by this request.Note that this is a driver-provided function:<pre> fd = open ("DEV1:", O_WRONLY); status = ioctl (fd, FIODISKFORMAT, 0);</pre><dt><b>FIODISKINIT</b><dd>Initializes an rt11Fs file system on the disk volume.This routine does not format the disk; formatting must be done by the driver.The file descriptor should be obtained by opening the entire volume in raw mode:<pre> fd = open ("DEV1:", O_WRONLY); status = ioctl (fd, FIODISKINIT, 0);</pre><dt><b>FIODISKCHANGE</b><dd>Announces a media change. It performs the same function as <b><a href="./rt11FsLib.html#rt11FsReadyChange">rt11FsReadyChange</a>( )</b>.This function may be called from interrupt level:<pre> status = ioctl (fd, FIODISKCHANGE, 0);</pre><dt><b>FIOGETNAME</b><dd>Gets the file name of the file descriptor and copies it to the buffer <i>nameBuf</i>:<pre> status = ioctl (fd, FIOGETNAME, &nameBuf);</pre><dt><b>FIORENAME</b><dd>Renames the file to the string <i>newname</i>:<pre> status = ioctl (fd, FIORENAME, "newname");</pre><dt><b>FIONREAD</b><dd>Copies to <i>unreadCount</i> the number of unread bytes in the file:<pre> status = ioctl (fd, FIONREAD, &unreadCount);</pre><dt><b>FIOFLUSH</b><dd>Flushes the file output buffer. It guarantees that any output that has beenrequested is actually written to the device.<pre> status = ioctl (fd, FIOFLUSH, 0);</pre><dt><b>FIOSEEK</b><dd>Sets the current byte offset in the file to the position specified by<i>newOffset</i>:<pre> status = ioctl (fd, FIOSEEK, newOffset);</pre><dt><b>FIOWHERE</b><dd>Returns the current byte position in the file. This is the byte offset ofthe next byte to be read or written. It takes no additional argument:<pre> position = ioctl (fd, FIOWHERE, 0);</pre><dt><b>FIOSQUEEZE</b><dd>Coalesces fragmented free space on an rt11Fs volume:<pre> status = ioctl (fd, FIOSQUEEZE, 0);</pre><dt>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -