📄 rawfslib.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/rawFsLib.html - generated by refgen from rawFsLib.c --> <title> rawFsLib </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>rawFsLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>rawFsLib</strong> - raw block device file system library </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><i><a href="./rawFsLib.html#rawFsDevInit">rawFsDevInit</a></i>( )</b> - associate a block device with raw volume functions<br><b><i><a href="./rawFsLib.html#rawFsInit">rawFsInit</a></i>( )</b> - prepare to use the raw volume library<br><b><i><a href="./rawFsLib.html#rawFsModeChange">rawFsModeChange</a></i>( )</b> - modify the mode of a raw device volume<br><b><i><a href="./rawFsLib.html#rawFsReadyChange">rawFsReadyChange</a></i>( )</b> - notify <b><a href="./rawFsLib.html#top">rawFsLib</a></b> of a change in ready status<br><b><i><a href="./rawFsLib.html#rawFsVolUnmount">rawFsVolUnmount</a></i>( )</b> - disable a raw device volume<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides basic services for disk devices that do notuse a standard file or directory structure. The disk volume is treatedmuch like a large file. Portions of it may be read, written, or thecurrent position within the disk may be changed. However, thereis no high-level organization of the disk into files or directories.<p></blockquote><h4>USING THIS LIBRARY</h4><blockquote><p>The various routines provided by the VxWorks raw "file system" (rawFs) maybe separated into three broad groups: general initialization,device initialization, and file system operation.<p>The <b><i><a href="./rawFsLib.html#rawFsInit">rawFsInit</a></i>( )</b> routine is the principal initialization function;it need only be called once, regardless of how many rawFs deviceswill be used.<p>A separate rawFs routine is used for device initialization. Foreach rawFs device, <b><i><a href="./rawFsLib.html#rawFsDevInit">rawFsDevInit</a></i>( )</b> must be called to install the device.<p>Several routines are provided to inform the file system ofchanges in the system environment. The <b><i><a href="./rawFsLib.html#rawFsModeChange">rawFsModeChange</a></i>( )</b> routine may beused to modify the readability or writability of a particular device.The <b><i><a href="./rawFsLib.html#rawFsReadyChange">rawFsReadyChange</a></i>( )</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. The <b><i><a href="./rawFsLib.html#rawFsVolUnmount">rawFsVolUnmount</a></i>( )</b> routine informs thefile system that a particular device should be synchronized and unmounted,generally in preparation for a disk change.<p></blockquote><h4>INITIALIZATION</h4><blockquote><p>Before any other routines in <b><a href="./rawFsLib.html#top">rawFsLib</a></b> can be used, <b><i><a href="./rawFsLib.html#rawFsInit">rawFsInit</a></i>( )</b> must be called to initialize the library. This call specifies themaximum number of raw device file descriptors that can be opensimultaneously and allocates memory for that many raw file descriptors.Any attempt to open more raw device file descriptors than the specifiedmaximum will result in errors from <b><i><a href="./ioLib.html#open">open</a></i>( )</b> or <b><i><a href="./ioLib.html#creat">creat</a></i>( )</b>.<p>During the <b><i><a href="./rawFsLib.html#rawFsInit">rawFsInit</a></i>( )</b> call, the raw 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>rawFsDrvNum</b>.<p>This initialization is enabled when the configuration macro <b>INCLUDE_RAWFS</b>is defined; <b><i><a href="./rawFsLib.html#rawFsInit">rawFsInit</a></i>( )</b> is then called from the root task, <b><i><a href="./usrConfig.html#usrRoot">usrRoot</a></i>( )</b>, in<b>usrConfig.c</b>.<p></blockquote><h4>DEFINING A RAW 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, ablock device description structure (<b>BLK_DEV</b>). This must be initializedbefore calling <b><i><a href="./rawFsLib.html#rawFsDevInit">rawFsDevInit</a></i>( )</b>. In the <b>BLK_DEV</b> structure, the driver includesthe addresses of five routines 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>( )</b>) on the device, one that checks the status of thethe device, and one that resets the device. The <b>BLK_DEV</b> structure alsocontains fields that describe the physical configuration of the device. Formore information about defining block devices, see the <i>VxWorks Programmer's Guide: I/O System. </i><p>The <b><i><a href="./rawFsLib.html#rawFsDevInit">rawFsDevInit</a></i>( )</b> routine is used to associate a device with the <b><a href="./rawFsLib.html#top">rawFsLib</a></b>functions. The <i>volName</i> parameter expected by <b><i><a href="./rawFsLib.html#rawFsDevInit">rawFsDevInit</a></i>( )</b> is a pointer toa name string, to be used to identify the device. This will serve asthe pathname for I/O operations which operate on the device. Thisname will appear in the I/O system device table, which may be displayedusing <b><i><a href="./iosShow.html#iosDevShow">iosDevShow</a></i>( )</b>.<p>The <i>pBlkDev</i> parameter that <b><i><a href="./rawFsLib.html#rawFsDevInit">rawFsDevInit</a></i>( )</b> expects is a pointerto the <b>BLK_DEV</b> structure describing the device and contains theaddresses of the required driver functions. The syntax of the <b><i><a href="./rawFsLib.html#rawFsDevInit">rawFsDevInit</a></i>( )</b>routine is as follows:<pre> rawFsDevInit ( char *volName, /* name to be used for volume */ BLK_DEV *pBlkDev /* pointer to device descriptor */ )</pre>Unlike the VxWorks DOS and RT-11 file systems, raw volumes do notrequire an FIODISKINIT <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>( )</b> function to initialize volume structures.(Such an <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>( )</b> call can be made for a raw volume, but it has no effect.)As a result, there is no "make file system" routine for raw volumes(for comparison, see the manual entries for <b><i><a href="./dosFsLib.html#dosFsMkfs">dosFsMkfs</a></i>( )</b> and <b><i>rt11Mkfs</i>( )</b>).<p>When <b><a href="./rawFsLib.html#top">rawFsLib</a></b> receives a request from the I/O system, after <b><i><a href="./rawFsLib.html#rawFsDevInit">rawFsDevInit</a></i>( )</b>has been called, it calls the device driver routines (whose addresses werepassed in the <b>BLK_DEV</b> structure) to access the device.<p></blockquote><h4>MULTIPLE LOGICAL DEVICES</h4><blockquote><p>The block number passed to the block read and write routines is an absolutenumber, starting from block 0 at the beginning of the device. If desired,the driver may add an offset from the beginning of the physical devicebefore the start of the logical device. This would normally be done bykeeping an offset parameter in the driver's device-specific structure,and adding the proper number of blocks to the block number passed to the readand write routines. See the <b><a href="./ramDrv.html#top">ramDrv</a></b> manual entry for an example.<p></blockquote><h4>UNMOUNTING VOLUMES (CHANGING DISKS)</h4><blockquote><p>A disk should be unmounted before it is removed. When unmounted,any modified data that has not been written to the disk will be writtenout. A disk may be unmounted by either calling <b><i><a href="./rawFsLib.html#rawFsVolUnmount">rawFsVolUnmount</a></i>( )</b> directlyor calling <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>( )</b> with a FIODISKCHANGE function code.<p>There may be open file descriptors to a raw device volume when it isunmounted. If this is the case, those file descriptors will be markedas obsolete. Any attempts to use them for further I/O operations willreturn an S_rawFsLib_FD_OBSOLETE error. To free such file descriptors, use the<b><i><a href="./ioLib.html#close">close</a></i>( )</b> call, as usual. This will successfully free the descriptor,but will still return S_rawFsLib_FD_OBSOLETE.<p></blockquote><h4>SYNCHRONIZING VOLUMES</h4><blockquote><p>A disk should be "synchronized" before it is unmounted. To synchronize adisk means to write out all buffered data (the write buffers associatedwith open file descriptors), so that the disk is updated. It mayor may not be necessary to explicitly synchronize a disk, depending onhow (or if) the driver issues the <b><i><a href="./rawFsLib.html#rawFsVolUnmount">rawFsVolUnmount</a></i>( )</b> call.<p>When <b><i><a href="./rawFsLib.html#rawFsVolUnmount">rawFsVolUnmount</a></i>( )</b> is called, an attempt will be made to synchronize thedevice before unmounting. However, if the <b><i><a href="./rawFsLib.html#rawFsVolUnmount">rawFsVolUnmount</a></i>( )</b> call is made bya driver in response to a disk being removed, it is obviously too late tosynchronize. Therefore, a separate <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>( )</b> call specifying the FIOSYNCfunction should be made before the disk is removed. (This could be done inresponse to an operator command.)<p>If the disk will still be present and writable when <b><i><a href="./rawFsLib.html#rawFsVolUnmount">rawFsVolUnmount</a></i>( )</b> iscalled, it is not necessary to first synchronize the disk. Inall other circumstances, failure to synchronize the volume beforeunmounting may result in lost data.<p></blockquote><h4>IOCTL FUNCTIONS</h4><blockquote><p>The VxWorks raw block device file system supports the following <b><i><a href="./ioLib.html#ioctl">ioctl</a></i>( )</b>functions. The functions listed are defined in the header <b>ioLib.h</b>.<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 raw file system on the disk volume.Since there are no file system structures, this functions performs no action.It is provided only for compatibility with other VxWorks file systems.<p><dt><b>FIODISKCHANGE</b><dd>Announces a media change. It performs the same function as <b><i><a href="./rawFsLib.html#rawFsReadyChange">rawFsReadyChange</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="./rawFsLib.html#rawFsVolUnmount">rawFsVolUnmount</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>FIOSEEK</b><dd>Sets the current byte offset on the disk to the position specifiedby <i>newOffset</i>:<pre> status = ioctl (fd, FIOSEEK, newOffset);</pre><dt><b>FIOWHERE</b><dd>Returns the current byte position from the start of the device
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -