2 #include <sys/socket.h>
4 #include <linux/version.h>
5 #if LINUX_VERSION_CODE < 0x020600
7 # include <linux/nfs.h>
10 # include <linux/nfs.h>
12 #include <linux/nfs2.h>
13 #include <linux/nfs_mount.h>
18 mountnfs(int proto, struct sockaddr_in *sa, uchar *handle, int nhandle, char *mtpt)
21 struct nfs_mount_data nfs;
23 fd = socket(AF_INET, proto, proto==SOCK_STREAM ? IPPROTO_TCP : IPPROTO_UDP);
25 sysfatal("socket: %r");
27 memset(&nfs, 0, sizeof nfs);
28 nfs.version = NFS_MOUNT_VERSION;
37 if(proto==SOCK_STREAM)
38 nfs.flags |= NFS_MOUNT_TCP;
48 strcpy(nfs.hostname, "backup");
51 memcpy(nfs.root.data, handle, nhandle);
52 nfs.root.size = nhandle;
53 mflag = MS_NOATIME|MS_NODEV|MS_NODIRATIME|
54 MS_NOEXEC|MS_NOSUID|MS_RDONLY;
56 if(mount("backup:/", mtpt, "nfs", mflag, &nfs) < 0)
57 sysfatal("mount: %r");