NFS mounting from within program (AIX 1.2)

John Pipkins jp at merak.la.locus.com
Tue Oct 9 06:17:34 AEST 1990


In article <1990Oct4.213654.10663 at dutlru1.tudelft.nl> ge at dutlru1.tudelft.nl (Ge van Geldorp) writes:
>How do I mount a remote NFS filesystem from within a program? I know I have
>to talk to the remote rpc.mountd first, then setup a nfs_args structure which
>..... (stuff deleted)
>Ge van Geldorp
>ge at dutlru2.tudelft.nl
>...!uunet!hp4nl!dutlru2.tudelft.nl!ge

(Note:  This was given to me by our NFS experted a few months ago.)

Here is the information about performing an NFS mount programatically.


There is a system call called nfs_mount.  It takes three arguments, the
pathname of the mount point, an nfs_args structure, and a read-only flag.

The pathname should be an absolute path name.

The read only flag is 1 if the filesystem should be read-only, 0 otherwise.

The nfs_args structure is defined in /usr/include/sys/nfs.h.
It contains the following fields:
	the IP address of the server;
	the file handle obtained from the server - described below;
	the gfs of this filesystem - 0 means the kernel should pick
		a free one;
	the hostname of the server;
	flags which indicate which of the following fields should be read,
		and whether the mount is hard or soft - valid values
		are just after the declaration of nfs_args in nfs.h;
	the read and write size for buffers sent to the server;
	the timeout between attempted transmissions;
	the number of retransmissions before giving up on a soft mount
		or restarting a hard mount;
	

File handles uniquely identify a file or directory on the server.  The
file handle passed in the nfs_args should be the file handle for the root
of the directory tree being mounted on the server.  To obtain this a
RPC call to the mount daemon on the server will be needed.  A description
of how to make RPC calls is found in the Programming Tools and Interfaces
Manual.  The program number for mountd can be found in /etc/rpc.

NOTE:
   If you use this method to add mounts, /etc/mtab will not be correctly
   updated, thus tools such as "mount" and "df" will not know of their
   existence.



More information about the Comp.unix.aix mailing list