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