ge@dutlru1.tudelft.nl (Ge van Geldorp) (10/05/90)
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 should be passed to some system call. Peeking through libc.a, I found a nfs_mount() routine, but I could not find a single reference to this routine in the docs. What arguments does it take? I am not interested in solutions doing something like system("mount..."), I need to duplicate the functionality of the mount command in my own program. BTW, this is AIX PS/2 1.2 Ge van Geldorp ge@dutlru2.tudelft.nl ...!uunet!hp4nl!dutlru2.tudelft.nl!ge
jp@merak.la.locus.com (John Pipkins) (10/09/90)
In article <1990Oct4.213654.10663@dutlru1.tudelft.nl> ge@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@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.