VxWorks Reference Manual : Libraries
nfsDrv - Network File System (NFS) I/O driver
nfsDrv( ) - install the NFS driver
nfsDrvNumGet( ) - return the IO system driver number for the nfs driver
nfsMount( ) - mount an NFS file system
nfsMountAll( ) - mount all file systems exported by a specified host
nfsDevShow( ) - display the mounted NFS devices
nfsUnmount( ) - unmount an NFS device
nfsDevListGet( ) - create list of all the NFS devices in the system
nfsDevInfoGet( ) - read configuration information from the requested NFS device
This driver provides facilities for accessing files transparently over the network via NFS (Network File System). By creating a network device with nfsMount( ), files on a remote NFS system (such as a UNIX system) can be handled as if they were local.
The nfsDrv( ) routine initializes the driver. The nfsMount( ) and nfsUnmount( ) routines mount and unmount file systems. The nfsMountAll( ) routine mounts all file systems exported by a specified host.
Before using the network driver, it must be initialized by calling nfsDrv( ). This routine must be called before any reads, writes, or other NFS calls. This is done automatically when the configuration macro INCLUDE_NFS is defined.
In order to access a remote file system, an NFS device must be created by calling nfsMount( ). For example, to create the device /myd0/ for the file system /d0/ on the host wrs, call:
nfsMount ("wrs", "/d0/", "/myd0/");The file /d0/dog on the host wrs can now be accessed as /myd0/dog.If the third parameter to nfsMount( ) is NULL, VxWorks creates a device with the same name as the file system. For example, the call:
nfsMount ("wrs", "/d0/", NULL);or from the shell:nfsMount "wrs", "/d0/"creates the device /d0/. The file /d0/dog is accessed by the same name, /d0/dog.Before mounting a file system, the host must already have been created with hostAdd( ). The routine nfsDevShow( ) displays the mounted NFS devices.
The NFS driver responds to the following ioctl( ) functions:
- FIOGETNAME
- Gets the file name of fd and copies it to the buffer referenced by nameBuf:
status = ioctl (fd, FIOGETNAME, &nameBuf);- FIONREAD
- Copies to nBytesUnread the number of bytes remaining in the file specified by fd:
status = ioctl (fd, FIONREAD, &nBytesUnread);- FIOSEEK
- Sets the current byte offset in the file to the position specified by newOffset. If the seek goes beyond the end-of-file, the file grows. The end-of-file pointer gets moved to the new position, and the new space is filled with zeros:
status = ioctl (fd, FIOSEEK, newOffset);- FIOSYNC
- Flush data to the remote NFS file. It takes no additional argument:
status = ioctl (fd, FIOSYNC, 0);- FIOWHERE
- Returns the current byte position in the file. This is the byte offset of the next byte to be read or written. It takes no additional argument:
position = ioctl (fd, FIOWHERE, 0);- FIOREADDIR
- Reads the next directory entry. The argument dirStruct is a pointer to a directory descriptor of type DIR. Normally, the readdir( ) routine is used to read a directory, rather than using the FIOREADDIR function directly. See the manual entry for dirLib:
DIR dirStruct; fd = open ("directory", O_RDONLY); status = ioctl (fd, FIOREADDIR, &dirStruct);- FIOFSTATGET
- Gets file status information (directory entry data). The argument statStruct is a pointer to a stat structure that is filled with data describing the specified file. Normally, the stat( ) or fstat( ) routine is used to obtain file information, rather than using the FIOFSTATGET function directly. See the manual entry for dirLib:
struct stat statStruct; fd = open ("file", O_RDONLY); status = ioctl (fd, FIOFSTATGET, &statStruct);
- FIOFSTATFSGET
- Gets the file system parameters for and open file descriptor. The argument statfsStruct is a pointer to a statfs structure that is filled with data describing the underlying filesystem. Normally, the stat( ) or fstat( ) routine is used to obtain file information, rather than using the FIOFSTATGET function directly. See the manual entry for dirLib:
statfs statfsStruct; fd = open ("directory", O_RDONLY); status = ioctl (fd, FIOFSTATFSGET, &statfsStruct);
There is only one client handle/cache per task. Performance is poor if a task is accessing two or more NFS files.
Changing nfsCacheSize after a file is open could cause adverse effects. However, changing it before opening any NFS file descriptors should not pose a problem.
nfsDrv.h, ioLib.h, dirent.h
nfsDrv, dirLib, nfsLib, hostAdd( ), ioctl( ), VxWorks Programmer's Guide: Network
nfsDrv( ) - install the NFS driver
STATUS nfsDrv (void)
This routine initializes and installs the NFS driver. It must be called before any reads, writes, or other NFS calls. This is done automatically when the configuration macro INCLUDE_NFS is defined.
OK, or ERROR if there is no room for the driver.
nfsDrvNumGet( ) - return the IO system driver number for the nfs driver
int nfsDrvNumGet (void)
This routine returns the nfs driver number allocated by iosDrvInstall during the nfs driver initialization. If the nfs driver has yet to be initialized, or if initialization failed, nfsDrvNumGet will return ERROR.
the nfs driver number or ERROR
nfsMount( ) - mount an NFS file system
STATUS nfsMount ( char * host, /* name of remote host */ char * fileSystem, /* name of remote directory to mount */ char * localName /* local device name for remote dir (NULL = use */ /* name) */ )
This routine mounts a remote file system. It creates a local device localName for a remote file system on a specified host. The host must have already been added to the local host table with hostAdd( ). If localName is NULL, the local name will be the same as the remote name.
OK, or ERROR if the driver is not installed, host is invalid, or memory is insufficient.
nfsDrv, nfsUnmount( ), hostAdd( )
nfsMountAll( ) - mount all file systems exported by a specified host
STATUS nfsMountAll ( char * pHostName, /* name of remote host */ char * pClientName, /* name of a client specified in access list, if any */ BOOL quietFlag /* FALSE = print name of each mounted file system */ )
This routine mounts the file systems exported by the host pHostName which are accessible by pClientName. A pClientName entry of NULL will only mount file systems which are accessible by any client. The nfsMount( ) routine is called to mount each file system. It creates a local device for each mount which has the same name as the remote file system.
If the quietFlag setting is FALSE, each file system is printed on standard output after it is mounted successfully.
OK, or ERROR if any mount fails.
nfsDevShow( ) - display the mounted NFS devices
void nfsDevShow (void)
This routine displays the device names and their associated NFS file systems.
-> nfsDevShow device name file system ----------- ----------- /yuba1/ yuba:/yuba1 /wrs1/ wrs:/wrs1
N/A
nfsUnmount( ) - unmount an NFS device
STATUS nfsUnmount ( char * localName /* local of nfs device */ )
This routine unmounts file systems that were previously mounted via NFS.
OK, or ERROR if localName is not an NFS device or cannot be mounted.
nfsDevListGet( ) - create list of all the NFS devices in the system
int nfsDevListGet ( unsigned long nfsDevList[], /* NFS dev list of handles */ int listSize /* number of elements available in the list */ )
This routine fills the array nfsDevlist up to listSize, with handles to NFS devices currently in the system.
The number of entries filled in the nfsDevList array.
nfsDrv, nfsDevInfoGet( )
nfsDevInfoGet( ) - read configuration information from the requested NFS device
STATUS nfsDevInfoGet ( unsigned long nfsDevHandle, /* NFS device handle */ NFS_DEV_INFO * pnfsInfo /* ptr to struct to hold config info */ )
This routine accesses the NFS device specified in the parameter nfsDevHandle and fills in the structure pointed to by pnfsInfo.
OK if pnfsInfo information is valid, otherwise ERROR.
nfsDrv, nfsDevListGet( )