5.  Mount Protocol Definition

5.1.  Introduction

The mount protocol is separate from, but related to, the NFS protocol. It provides operating system specific services to get the NFS off the ground -- looking up server path names, validating user identity, and checking access permissions. Clients use the mount protocol to get the first file handle, which allows them entry into a remote filesystem.

The mount protocol is kept separate from the NFS protocol to make it easy to plug in new access checking and validation methods without changing the NFS server protocol.

Notice that the protocol definition implies stateful servers because the server maintains a list of client's mount requests. The mount list information is not critical for the correct functioning of either the client or the server. It is intended for advisory use only, for example, to warn possible clients when a server is going down.

Version one of the mount protocol is used with version two of the NFS protocol. The only connecting point is the fhandle structure, which is the same for both protocols.

5.2.  RPC Information

Authentication
The mount service uses AUTH_UNIX and AUTH_DES style authentication only.
Transport Protocols
The mount service is currently supported on UDP/IP only.
Port Number
Consult the server's portmapper, described in the chapter Remote Procedure Calls: Protocol Specification, to find the port number on which the mount service is registered.

5.3.  Sizes of XDR Structures

These are the sizes, given in decimal bytes, of various XDR structures used in the protocol:

/* The maximum number of bytes in a pathname argument */
const MNTPATHLEN = 1024;

/* The maximum number of bytes in a name argument */
const MNTNAMLEN = 255;

/* The size in bytes of the opaque file handle */
const FHSIZE = 32;

5.4.  Basic Data Types

This section presents the data types used by the mount protocol. In many cases they are similar to the types used in NFS.

5.4.1.  fhandle
typedef opaque fhandle[FHSIZE];
The type fhandle is the file handle that the server passes to the client. All file operations are done using file handles to refer to a file or directory. The file handle can contain whatever information the server needs to distinguish an individual file.

This is the same as the "fhandle" XDR definition in version 2 of the NFS protocol; see Basic Data Types in the definition of the NFS protocol, above.

5.4.2.  fhstatus
union fhstatus switch (unsigned status) {
	case 0:
		fhandle directory;
	default:
		void;
};
The type fhstatus is a union. If a "status" of zero is returned, the call completed successfully, and a file handle for the "directory" follows. A non-zero status indicates some sort of error. In this case the status is a UNIX error number.

5.4.3.  dirpath
typedef string dirpath<MNTPATHLEN>;
The type dirpath is a server pathname of a directory.

5.4.4.  name
typedef string name<MNTNAMLEN>;
The type name is an arbitrary string used for various names.

5.5.  Server Procedures

The following sections define the RPC procedures supplied by a mount server.

/*
* Protocol description for the mount program
*/

program MOUNTPROG {
/*
* Version 1 of the mount protocol used with
* version 2 of the NFS protocol.
*/
	version MOUNTVERS {
		void        MOUNTPROC_NULL(void)    = 0;
		fhstatus    MOUNTPROC_MNT(dirpath)  = 1;
		mountlist   MOUNTPROC_DUMP(void)    = 2;
		void        MOUNTPROC_UMNT(dirpath) = 3;
		void        MOUNTPROC_UMNTALL(void) = 4;
		exportlist  MOUNTPROC_EXPORT(void)  = 5;
	} = 1;
} = 100005;

5.5.1.  Do Nothing
void 
MNTPROC_NULL(void) = 0;
This procedure does no work. It is made available in all RPC services to allow server response testing and timing.

5.5.2.  Add Mount Entry
fhstatus
MNTPROC_MNT(dirpath) = 1;
If the reply "status" is 0, then the reply "directory" contains the file handle for the directory "dirname". This file handle may be used in the NFS protocol. This procedure also adds a new entry to the mount list for this client mounting "dirname".

5.5.3.  Return Mount Entries
struct *mountlist {
	name      hostname;
	dirpath   directory;
	mountlist nextentry;
};

mountlist
MNTPROC_DUMP(void) = 2;
Returns the list of remote mounted filesystems. The "mountlist" contains one entry for each "hostname" and "directory" pair.

5.5.4.  Remove Mount Entry
void
MNTPROC_UMNT(dirpath) = 3;
Removes the mount list entry for the input "dirpath".

5.5.5.  Remove All Mount Entries
void
MNTPROC_UMNTALL(void) = 4;
Removes all of the mount list entries for this client.

5.5.6.  Return Export List
struct *groups {
	name grname;
	groups grnext;
};

struct *exportlist {
	dirpath filesys;
	groups groups;
	exportlist next;
};

exportlist
MNTPROC_EXPORT(void) = 5;
Returns a variable number of export list entries. Each entry contains a filesystem name and a list of groups that are allowed to import it. The filesystem name is in "filesys", and the group name is in the list "groups".

Note: The exportlist should contain more information about the status of the filesystem, such as a read-only flag.