VxWorks Reference Manual : Libraries

nfsDrv

NAME

nfsDrv - Network File System (NFS) I/O driver

ROUTINES

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

DESCRIPTION

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.

USER-CALLABLE ROUTINES

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.

INITIALIZATION

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.

CREATING NFS DEVICES

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.

IOCTL FUNCTIONS

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);

DEFICIENCIES

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.

INCLUDE FILES

nfsDrv.h, ioLib.h, dirent.h

SEE ALSO

nfsDrv, dirLib, nfsLib, hostAdd( ), ioctl( ), VxWorks Programmer's Guide: Network


Libraries : Routines

nfsDrv( )

NAME

nfsDrv( ) - install the NFS driver

SYNOPSIS


STATUS nfsDrv (void)

DESCRIPTION

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.

RETURNS

OK, or ERROR if there is no room for the driver.

SEE ALSO

nfsDrv


Libraries : Routines

nfsDrvNumGet( )

NAME

nfsDrvNumGet( ) - return the IO system driver number for the nfs driver

SYNOPSIS


int nfsDrvNumGet (void)

DESCRIPTION

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.

RETURNS

the nfs driver number or ERROR

SEE ALSO

nfsDrv


Libraries : Routines

nfsMount( )

NAME

nfsMount( ) - mount an NFS file system

SYNOPSIS

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) */
    )

DESCRIPTION

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.

RETURNS

OK, or ERROR if the driver is not installed, host is invalid, or memory is insufficient.

SEE ALSO

nfsDrv, nfsUnmount( ), hostAdd( )


Libraries : Routines

nfsMountAll( )

NAME

nfsMountAll( ) - mount all file systems exported by a specified host

SYNOPSIS

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 */
    )

DESCRIPTION

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.

RETURNS

OK, or ERROR if any mount fails.

SEE ALSO

nfsDrv, nfsMount( )


Libraries : Routines

nfsDevShow( )

NAME

nfsDevShow( ) - display the mounted NFS devices

SYNOPSIS


void nfsDevShow (void)

DESCRIPTION

This routine displays the device names and their associated NFS file systems.

EXAMPLE

    -> nfsDevShow
    device name          file system
    -----------          -----------
    /yuba1/              yuba:/yuba1
    /wrs1/               wrs:/wrs1

RETURNS

N/A

SEE ALSO

nfsDrv


Libraries : Routines

nfsUnmount( )

NAME

nfsUnmount( ) - unmount an NFS device

SYNOPSIS

STATUS nfsUnmount
    (
    char * localName /* local of nfs device */
    )

DESCRIPTION

This routine unmounts file systems that were previously mounted via NFS.

RETURNS

OK, or ERROR if localName is not an NFS device or cannot be mounted.

SEE ALSO

nfsDrv, nfsMount( )


Libraries : Routines

nfsDevListGet( )

NAME

nfsDevListGet( ) - create list of all the NFS devices in the system

SYNOPSIS

int nfsDevListGet
    (
    unsigned long nfsDevList[], /* NFS dev list of handles */
    int           listSize      /* number of elements available in the list */
    )

DESCRIPTION

This routine fills the array nfsDevlist up to listSize, with handles to NFS devices currently in the system.

RETURNS

The number of entries filled in the nfsDevList array.

SEE ALSO

nfsDrv, nfsDevInfoGet( )


Libraries : Routines

nfsDevInfoGet( )

NAME

nfsDevInfoGet( ) - read configuration information from the requested NFS device

SYNOPSIS

STATUS nfsDevInfoGet
    (
    unsigned long  nfsDevHandle, /* NFS device handle */
    NFS_DEV_INFO * pnfsInfo      /* ptr to struct to hold config info */
    )

DESCRIPTION

This routine accesses the NFS device specified in the parameter nfsDevHandle and fills in the structure pointed to by pnfsInfo.

RETURNS

OK if pnfsInfo information is valid, otherwise ERROR.

SEE ALSO

nfsDrv, nfsDevListGet( )