Blob


1 #include <u.h>
2 #include <sys/socket.h>
3 #include <netinet/in.h>
4 #include <netdb.h>
5 #include <sys/stat.h>
6 #include <sys/param.h>
7 #include <sys/mount.h>
8 #include <sys/syslog.h>
9 #include <rpc/rpc.h>
10 #include <rpc/pmap_clnt.h>
11 #include <rpc/pmap_prot.h>
12 #include <nfs/rpcv2.h>
13 #include <nfs/nfsproto.h>
14 #if __FreeBSD_version >= 500000
15 # include <nfsclient/nfs.h>
16 #else
17 # include <nfs/nfs.h>
18 #endif
19 #include <libc.h>
20 #include "mountnfs.h"
22 void
23 mountnfs(int proto, struct sockaddr_in *sa,
24 uchar *handle, int nhandle, char *mtpt)
25 {
26 int mflag;
27 struct nfs_args na;
29 memset(&na, 0, sizeof na);
30 na.version = NFS_ARGSVERSION;
31 na.addr = (struct sockaddr*)sa;
32 na.addrlen = sizeof *sa;
33 na.sotype = proto;
34 na.proto = (proto == SOCK_STREAM) ? IPPROTO_TCP : IPPROTO_UDP;
35 na.fh = handle;
36 na.fhsize = nhandle;
37 na.flags = NFSMNT_RESVPORT|NFSMNT_NFSV3|NFSMNT_INT;
38 na.wsize = NFS_WSIZE;
39 na.rsize = NFS_RSIZE;
40 na.readdirsize = NFS_READDIRSIZE;
41 na.timeo = 2;
42 na.retrans = NFS_RETRANS;
43 na.maxgrouplist = NFS_MAXGRPS;
44 na.readahead = 0;
45 na.deadthresh = 0;
46 na.hostname = "backup";
47 na.acregmin = 60;
48 na.acregmax = 600;
49 na.acdirmin = 60;
50 na.acdirmax = 600;
52 mflag = MNT_RDONLY|MNT_NOSUID|MNT_NOATIME|MNT_NODEV;
53 if(mount("nfs", mtpt, mflag, &na) < 0)
54 sysfatal("mount: %r");
55 }