Operating System - HP-UX
1751974 Members
4668 Online
108784 Solutions
New Discussion юеВ

Mount using an NFS file handle

 
Stephen Keane
Honored Contributor

Mount using an NFS file handle

I am trying to mount a fileystem from a remote server using NFS. I can do this from command line OK, but I am trying to do it programatically in C/C++.

I can get the NFS file handle for the file on the remote machine I am interested in, but I can't get the mount(2) command to work I keep getting EINVAL. This is not helped by the fact that I don't actually know what the dataptr argument for the mount(2) command is supposed to be for an NFS mount. I have

fs = "" (that's what trace showed)
path = directory path on remote machine
mflag = MS_DATA (that's what trace showed)
fstype = "nfs3" (that's what trace showed)
dataptr = char[64] with first 32 bytes = fhandle returned by clnt_call
datalen = 64 (that's what trace showed)


Having traced a successful command line mount, I can see that the datalen argument is 64 bytes, so I assume that dataptr is the address of a structure of size 64 bytes. The file handle I get back is only 32 bytes, (as it is a fhandle type) and looks OK.

The clnt_create(), authsys_create_default() and clnt_call() calls all complete successfully.
2 REPLIES 2
Peter Godron
Honored Contributor

Re: Mount using an NFS file handle

Stephen,
I assume you have had alook through the
/usr/include/sys/mount.h
Also for somebody elses code:
http://www.koders.com/c/fid838F9F10371C15E1D4B681A6A838130D0F99DF4D.aspx
(Have not read ALL the code, but is in the right area I think)
Regards
Stephen Keane
Honored Contributor

Re: Mount using an NFS file handle

Yes I've had an extensive rummage through the /usr/include area.

I'd seen the file you posted, but as I said when I trace the call the mount system call is being given a 64 byte structure and the nfs_mount_data in the example code is way bigger than that. S'worth a try I guess.