VxWorks Reference Manual : Libraries
unixDrv - UNIX-file disk driver (VxSim for Solaris and VxSim for HP)
unixDrv( ) - install UNIX disk driver
unixDiskDevCreate( ) - create a UNIX disk device
unixDiskInit( ) - initialize a dosFs disk on top of UNIX
This driver emulates a VxWorks disk driver, but actually uses the UNIX file system to store the data. The VxWorks disk appears under UNIX as a single file. The UNIX file name, and the size of the disk, may be specified during the unixDiskDevCreate( ) call.
Most of the routines in this driver are accessible only through the I/O system. The routine unixDrv( ) must be called to initialize the driver and the unixDiskDevCreate( ) routine is used to create devices.
Before a UNIX disk can be used, it must be created. This is done with the unixDiskDevCreate( ) call. The format of this call is:
BLK_DEV *unixDiskDevCreate ( char *unixFile, /* name of the UNIX file to use */ int bytesPerBlk, /* number of bytes per block */ int blksPerTrack, /* number of blocks per track */ int nBlocks /* number of blocks on this device */ )The UNIX file must be pre-allocated separately. This can be done using the UNIX mkfile(8) command. Note that you have to create an appropriately sized file. For example, to create a UNIX file system that is used as a common floppy dosFs file system, you would issue the comand:mkfile 1440k /tmp/floppy.dosThis will create space for a 1.44 Meg DOS floppy (1474560 bytes, or 2880 512-byte blocks).The bytesPerBlk parameter specifies the size of each logical block on the disk. If bytesPerBlk is zero, 512 is the default.
The blksPerTrack parameter specifies the number of blocks on each logical track of the UNIX disk. If blksPerTrack is zero, the count of blocks per track will be set to nBlocks (i.e., the disk will be defined as having only one track). UNIX disk devices typically are specified with only one track.
The nBlocks parameter specifies the size of the disk, in blocks. If nBlocks is zero the size of the UNIX file specified, divided by the number of bytes per block, is used.
The formatting parameters (bytesPerBlk, blksPerTrack, and nBlocks) are critical only if the UNIX disk already contains the contents of a disk created elsewhere. In that case, the formatting parameters must be identical to those used when the image was created. Otherwise, they may be any convenient number.
Once the device has been created it still does not have a name or file system associated with it. This must be done by using the file system's device initialization routine (e.g., dosFsDevInit( )). The dosFs and rt11Fs file systems also provide make-file-system routines (dosFsMkfs( ) and rt11FsMkfs( )), which may be used to associate a name and file system with the block device and initialize that file system on the device using default configuration parameters.
The unixDiskDevCreate( ) call returns a pointer to a block device structure (BLK_DEV). This structure contains fields that describe the physical properties of a disk device and specify the addresses of routines within the UNIX disk driver. The BLK_DEV structure address must be passed to the desired file system (dosFs, rt11Fs, or rawFs) during the file system's device initialization or make-file-system routine. Only then is a name and file system associated with the device, making it available for use.
As an example, to create a 200KB disk, 512-byte blocks, and only one track, the proper call would be:
BLK_DEV *pBlkDev; pBlkDev = unixDiskDevCreate ("/tmp/filesys1", 512, 400, 400, 0);This will attach the UNIX file /tmp/filesys1 as a block device.A convenience routine, unixDiskInit( ), is provided to do the unixDiskDevCreate( ) followed by either a dosFsMkFs( ) or dosFsDevInit( ), whichever is appropriate.
The format of this call is:
BLK_DEV *unixDiskInit ( char * unixFile, /* name of the UNIX file to use */ char * volName, /* name of the dosFs volume to use */ int nBytes /* number of bytes in dosFs volume */ )This call will create the UNIX disk if required.
Only the FIODISKFORMAT request is supported; all other ioctl requests return an error, and set the task's errno to S_ioLib_UNKNOWN_REQUEST.
unixDrv, dosFsDevInit( ), dosFsMkfs( ), rt11FsDevInit( ), rt11FsMkfs( ), rawFsDevInit( ), VxWorks Programmer's Guide: I/O System, Local File Systems
unixDrv( ) - install UNIX disk driver
STATUS unixDrv (void)
Used in usrConfig.c to cause the UNIX disk driver to be linked in when building VxWorks. Otherwise, it is not necessary to call this routine before using the UNIX disk driver.
This routine is only applicable to VxSim for Solaris and VxSim for HP.
OK (always).
unixDiskDevCreate( ) - create a UNIX disk device
BLK_DEV *unixDiskDevCreate ( char * unixFile, /* name of the UNIX file */ int bytesPerBlk, /* number of bytes per block */ int blksPerTrack, /* number of blocks per track */ int nBlocks /* number of blocks on this device */ )
This routine creates a UNIX disk device.
The unixFile parameter specifies the name of the UNIX file to use for the disk device.
The bytesPerBlk parameter specifies the size of each logical block on the disk. If bytesPerBlk is zero, 512 is the default.
The blksPerTrack parameter specifies the number of blocks on each logical track of the disk. If blksPerTrack is zero, the count of blocks per track is set to nBlocks (i.e., the disk is defined as having only one track).
The nBlocks parameter specifies the size of the disk, in blocks. If nBlocks is zero, a default size is used. The default is calculated as the size of the UNIX disk divided by the number of bytes per block.
This routine is only applicable to VxSim for Solaris and VxSim for HP.
A pointer to block device (BLK_DEV) structure, or NULL, if unable to open the UNIX disk.
unixDiskInit( ) - initialize a dosFs disk on top of UNIX
void unixDiskInit ( char * unixFile, /* UNIX file name */ char * volName, /* dosFs name */ int diskSize /* number of bytes */ )
This routine provides some convenience for a user wanting to create a UNIX disk-based dosFs file system under VxWorks. The user only specifes the UNIX file to use, the dosFs volume name, and the size of the volume in bytes, if the UNIX file needs to be created.
This routine is only applicable to VxSim for Solaris and VxSim for HP.
N/A