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 defined(__FreeBSD_version) && __FreeBSD_version >= 500000
15 # include <nfsclient/nfs.h>
16 #else
17 # include <nfs/nfs.h>
18 #endif
19 #ifdef __NetBSD__
20 # include <nfs/nfsmount.h>
21 #endif
22 #include <libc.h>
23 #include "mountnfs.h"
24 #ifndef MNT_NOATIME
25 # define MNT_NOATIME 0
26 #endif
28 void
29 mountnfs(int proto, struct sockaddr_in *sa,
30 uchar *handle, int nhandle, char *mtpt)
31 {
32 int mflag;
33 struct nfs_args na;
35 memset(&na, 0, sizeof na);
36 na.version = NFS_ARGSVERSION;
37 na.addr = (struct sockaddr*)sa;
38 na.addrlen = sizeof *sa;
39 na.sotype = proto;
40 na.proto = (proto == SOCK_STREAM) ? IPPROTO_TCP : IPPROTO_UDP;
41 na.fh = handle;
42 na.fhsize = nhandle;
43 na.flags = NFSMNT_RESVPORT|NFSMNT_NFSV3|NFSMNT_INT;
44 na.wsize = NFS_WSIZE;
45 na.rsize = NFS_RSIZE;
46 na.readdirsize = NFS_READDIRSIZE;
47 na.timeo = 200;
48 na.retrans = NFS_RETRANS;
49 na.maxgrouplist = NFS_MAXGRPS;
50 na.hostname = "backup";
51 #ifndef __NetBSD__
52 na.acregmin = 60;
53 na.acregmax = 600;
54 na.acdirmin = 60;
55 na.acdirmax = 600;
56 #endif
57 mflag = MNT_RDONLY|MNT_NOSUID|MNT_NOATIME|MNT_NODEV;
58 if(mount("nfs", mtpt, mflag, &na) < 0)
59 sysfatal("mount: %r");
60 }