Filesystems in VxWorks

VxWorks supports many filesystems:

VxWorks Driver	Description
--------------	-----------

netDrv		Accesses a remote filesystem using rsh or FTP

nfsDrv		Network File System (spec originally from Sun)

dosFsLib	MS-DOS filesystem

rt11FsLib	RT-11 filesystem

This tutorial will concentrate on the ones in use at Fermilab: network and NFS.

The "network" Filesystem

The so-called "network" filesystem is a fake filesystem based on rsh or FTP. It works by copying entire files into and out of local buffers using the Internet services rsh (remote shell) or FTP (File Transfer Protocol). This means that you must have an appropriate account setup on the host. For security reasons, this should really be a special account with very limited access to the host's other resources.


To create an instance of a network filesystem, you use netDevCreate( char *devname, char *hostname, int protocol ). The "devname" argument specifies the name you would like to give the new mount point. The "hostname" argument specifies the name of the host this filesystem resides on. It must already be in the host table. The "protocol" argument should be 0 for rsh, or 1 for FTP. To put a host in the host table, use hostAdd( char *name, char *addr ). The "name" argument is the name of the host, while "addr" specifies its address in Internet dot notation. For example, the following would create an rsh-based network filesystem from host sun2 (at

	hostAdd "sun2", ""
	netDevCreate "sun2:", "sun2", 0

Notice that the convention is to use a device name which is the host's name followed by a colon. This gives us the filesystem, but there is one more issue: the account which allows access to it. The command "iam" lets you set the account name and password. If the account is to be "vxworks", use:

	iam "vxworks"

In the above example, the password is set to NULL (we are using rsh). Now, if these commands were successful, accesses to "sun2:{some-path}" would access the file on the host "sun2" located at {some-path}. NOTE: if you use a relative pathname (no leading slash), it is relative to the accessing account's home directory.

The Automatic Entry

When you boot VxWorks over the network, an automatic network filesystem entry is created based on the boot parameters. The device name is the boot host's name followed by a colon (the boot host is also automatically added to the host table). The username is automatically set to that in the boot parameters. If FTP is being used, the password is automatically set to that in the boot parameters.


VxWorks provides an optional NFS client. It is NOT configured into the kernel by default; you must "#define INCLUDE_NFS" in configAll.h or config.h and rebuild VxWorks (with "make vxWorks") to get it. It is already configured in the latest Fermilab versions of BSPs.


To mount a filesystem, use nfsMount( char *host, char *remotefsname, char *localfsname ). The host must already be in the host table. If it is not, you must first use hostAdd() to add it. For example, to mount "/opt" from host "sun2" (at as "/sun2/opt" on the target, use:

	hostAdd "sun2", ""
	nfsMount "sun2", "/opt", "/sun2/opt"

If you don't specify the "localfsname" argument, it defaults to the value of "remotefsname". With NFS, you must worry about UNIX-style UIDs and GIDs. A UID (User IDentification) in UNIX is a number which uniquely identifies an account. A GID is a number which uniquely identifies a "group". You can compile in a default UID/GID (using NFS_USER_ID and NFS_GROUP_ID in configAll.h or config.h) to correspond to a special account at your site. Otherwise, you might have to ensure they are set correctly, using nfsAuthUnixSet( char *host, int uid, int gid, int ngids, int *aup_gids ). "host" is as usual; the network name of the host you used in the nfsMount(). "uid" is the UID; "gid" is the account's default GID. The other two arguments are used to tell the server any other groups the account might belong to: the first is the number of them, and the second is an array of them. Hopefully you won't have to worry about these. So, to set the UID/GID to 1050/5050 on "sun2", not worrying about additional groups, use:

	nfsAuthUnixSet "sun2", 1050, 5050

The Automatic Entry(-ies)

By default, there is no automatic NFS mounting. However, you can enable an option which automatically tries to mount all exports from the boot host by defining NFS_MOUNT_ALL in configAll.h or config.h and rebuilding VxWorks.