dosfslib.html
来自「vxworks相关论文」· HTML 代码 · 共 1,270 行 · 第 1/5 页
HTML
1,270 行
<b>DOS_OPT_CHANGENOWARN</b> must be set in the <b>dosvc_options</b> field of the<b>DOS_VOL_CONFIG</b> structure, if the driver and/orapplication is unable to issue a <b><i><a href="./dosFsLib.html#dosFsVolUnmount">dosFsVolUnmount</a></i>( )</b> call or assert aready-change when a disk is changed.<p>This configuration option results in a significant performance disadvantage,because the disk configuration data must be regularly read in from thephysical disk, in case the disk has been changed. In addition, setting<b>DOS_OPT_CHANGENOWARN</b> also enables auto-sync mode (see below).<p>Note that for disk change notification, all that is required is that<b><i><a href="./dosFsLib.html#dosFsVolUnmount">dosFsVolUnmount</a></i>( )</b> or <b><i><a href="./dosFsLib.html#dosFsReadyChange">dosFsReadyChange</a></i>( )</b> be called each time the disk ischanged. It is not necessary that either routine be called from thedevice driver or an interrupt handler. For example, if your applicationprovided a user interface through which an operator could enter a commandwhich would result in a <b><i><a href="./dosFsLib.html#dosFsVolUnmount">dosFsVolUnmount</a></i>( )</b> call before removing the disk,that would be sufficient, and <b>DOS_OPT_CHANGENOWARN</b> should not be set.It is important, however, that such a procedure be followed strictly.</blockQuote><h4>Synchronizing Volumes</h4><blockQuote>A disk should be "synchronized" before is is unmounted. To synchronize adisk means to write out all buffered data (files, directories, and the FATtable) that have been modified, so that the disk is "up-to-date." It mayor may not be necessary to explicitly synchronize a disk, depending onwhen (or if) the <b><i><a href="./dosFsLib.html#dosFsVolUnmount">dosFsVolUnmount</a></i>( )</b> call is issued.<p>When <b><i><a href="./dosFsLib.html#dosFsVolUnmount">dosFsVolUnmount</a></i>( )</b> is called, an attempt will be made to synchronize thedevice before unmounting. If the disk is still present and writable at thetime <b><i><a href="./dosFsLib.html#dosFsVolUnmount">dosFsVolUnmount</a></i>( )</b> is called, the synchronization will take place; thereis no need to independently synchronize the disk.<p>However, if <b><i><a href="./dosFsLib.html#dosFsVolUnmount">dosFsVolUnmount</a></i>( )</b> is called after a disk has been removed,it is obviously too late to synchronize. (In this situation, <b><i><a href="./dosFsLib.html#dosFsVolUnmount">dosFsVolUnmount</a></i>( )</b>discards the buffered data.) Therefore, a separate <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>( )</b> call withthe FIOFLUSH or FIOSYNC function should be made before the disk is removed. (This could be done in response to an operator command.)</blockQuote><h4>Auto-Sync Mode</h4><blockQuote>The dosFs file system provides a modified mode of behavior called "auto-sync."This mode is enabled by setting <b>DOS_OPT_AUTOSYNC</b> in the <b>dosvc_options</b> field ofthe <b>DOS_VOL_CONFIG</b> structure when calling <b><i><a href="./dosFsLib.html#dosFsDevInit">dosFsDevInit</a></i>( )</b>. When thisoption is enabled, modified directory and FAT data is written tothe physical device as soon as these structures are altered. (Normally,such changes may not be written out until the involved file is closed.)This results in a performance penalty, but it provides the highest levelof data security, since it minimizes the amount of time when directoryand FAT data on the disk are not up-to-date.<p>Auto-sync mode is automatically enabled if the volume does not have diskchange notification, i.e., if <b>DOS_OPT_CHANGENOWARN</b> is set in the <b>dosvc_options</b>field of the <b>DOS_VOL_CONFIG</b> structure when <b><i><a href="./dosFsLib.html#dosFsDevInit">dosFsDevInit</a></i>( )</b> iscalled. It may also be desirable for applications where data integrity--in case of a system crash--is a larger concern than simple disk I/O performance.<p></blockquote><h4>CHANGES IN VOLUME CONFIGURATION</h4><blockquote><p>Various disk configuration parameters are specifiedwhen the dosFs device is first initialized using <b><i><a href="./dosFsLib.html#dosFsDevInit">dosFsDevInit</a></i>( )</b>. Thisdata is kept in the volume descriptor (<b>DOS_VOL_DESC</b>) for the device.However, it is possible for a disk with different parameters than thosedefined to be placed in a drive after the device has already beeninitialized. For such a disk to be usable, the configuration datain the volume descriptor must be modified when a new disk is present.<p>When a disk is mounted, the boot sector information is read from the disk.This data is used to update the configuration data in the volume descriptor.Note that this will happen the first time the disk is accessed after thevolume has been unmounted (using <b><i><a href="./dosFsLib.html#dosFsVolUnmount">dosFsVolUnmount</a></i>( )</b>).<p>This automatic re-initialization of the configuration data has twoimportant implications:<dl><dt>(1)<dd>Since the values in the volume descriptor are reset when a newvolume is mounted, it is possible to omit the dosFs configuration data (byspecifying a NULL pointer instead of the address of a <b>DOS_VOL_CONFIG</b>structure during <b><i><a href="./dosFsLib.html#dosFsDevInit">dosFsDevInit</a></i>( )</b>). The first use of the volume must be witha properly formatted and initialized disk. (Attempting to initialize adisk, using FIODISKINIT, before a valid disk has been mounted is fruitless.)<p><dt>(2)<dd>The volume descriptor data is used when initializing a disk(with FIODISKINIT). The FIODISKINIT function initializes a disk withthe configuration of the most recently mounted disk, regardless of theoriginal specification during <b><i><a href="./dosFsLib.html#dosFsDevInit">dosFsDevInit</a></i>( )</b>. Therefore, it is recommendedthat FIODISKINIT be used immediately after <b><i><a href="./dosFsLib.html#dosFsDevInit">dosFsDevInit</a></i>( )</b>, before any diskhas been mounted. (The device should be opened in raw mode; the FIODISKINITfunction is then performed; and the device is then closed.) </dl><p></blockquote><h4>IOCTL FUNCTIONS</h4><blockquote><p>The dosFs file system supports the following <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>( )</b> functions. Thefunctions listed are defined in the header <b>ioLib.h</b>. Unless statedotherwise, the file descriptor used for these functions may be any filedescriptor which is opened to a file or directory on the volume 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 a DOS 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><i><a href="./dosFsLib.html#dosFsReadyChange">dosFsReadyChange</a></i>( )</b>.This function may be called from interrupt level:<pre> status = ioctl (fd, FIODISKCHANGE, 0);</pre><dt><b>FIOUNMOUNT</b><dd>Unmounts a disk volume. It performs the same function as <b><i><a href="./dosFsLib.html#dosFsVolUnmount">dosFsVolUnmount</a></i>( )</b>.This function must not be called from interrupt level:<pre> status = ioctl (fd, FIOUNMOUNT, 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 or directory to the string <i>newname</i>:<pre> status = ioctl (fd, FIORENAME, "newname");</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>FIOFLUSH</b><dd>Flushes the file output buffer. It guarantees that any output that hasbeen requested is actually written to the device. If the specified filedescriptor was obtained by opening the entire volume (raw mode), this function will flush all buffered file buffers, directories, and the FAT table to the physical device:<pre> status = ioctl (fd, FIOFLUSH, 0);</pre><dt><b>FIOSYNC</b><dd>Performs the same function as FIOFLUSH, and additionally re-reads bufferedfile data from the disk. This allows file changes made via a different filedescriptor to be seen.<p><dt><b>FIOTRUNC</b><dd>Truncates the specified file's length to <i>newLength</i> bytes. Any diskclusters which had been allocated to the file but are now unused arereturned, and the directory entry for the file is updated to reflectthe new length. Only regular files may be truncated; attempts to useFIOTRUNC on directories or the entire volume will return an error.FIOTRUNC may only be used to make files shorter; attempting to specifya <i>newLength</i> larger than the current size of the file produces anerror (setting errno to S_dosFsLib_INVALID_NUMBER_OF_BYTES).<pre> status = ioctl (fd, FIOTRUNC, newLength);</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>FIONFREE</b><dd>Copies to <i>freeCount</i> the amount of free space, in bytes, on the volume:<pre> status = ioctl (fd, FIONFREE, &freeCount);</pre><dt><b>FIOMKDIR</b><dd>Creates a new directory with the name specified as <i>dirName</i>:<pre> status = ioctl (fd, FIOMKDIR, "dirName");</pre><dt><b>FIORMDIR</b><dd>Removes the directory whose name is specified as <i>dirName</i>:<pre> status = ioctl (fd, FIORMDIR, "dirName");</pre><dt><b>FIOLABELGET</b><dd>Gets the volume label (located in root directory) and copies the string to<i>labelBuffer</i>:<pre> status = ioctl (fd, FIOLABELGET, &labelBuffer);</pre>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?