From 05bc5137e88f1b40ed6e9a14a145ef4dc75396d4 Mon Sep 17 00:00:00 2001 From: rsc Date: Thu, 28 Jul 2005 17:26:45 +0000 Subject: try to collect common bsd code --- src/cmd/vbackup/mount-BSD.c | 53 ++++++++++++++++++++++++++++++++++++++ src/cmd/vbackup/mount-FreeBSD.c | 56 +---------------------------------------- src/cmd/vbackup/mount-NetBSD.c | 53 +------------------------------------- src/cmd/vbackup/mount-OpenBSD.c | 53 +------------------------------------- 4 files changed, 56 insertions(+), 159 deletions(-) create mode 100644 src/cmd/vbackup/mount-BSD.c (limited to 'src/cmd/vbackup') diff --git a/src/cmd/vbackup/mount-BSD.c b/src/cmd/vbackup/mount-BSD.c new file mode 100644 index 00000000..b93cfbef --- /dev/null +++ b/src/cmd/vbackup/mount-BSD.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(__FreeBSD_version) && __FreeBSD_version >= 500000 +# include +#else +# include +#endif +#include +#include "mountnfs.h" + +void +mountnfs(int proto, struct sockaddr_in *sa, + uchar *handle, int nhandle, char *mtpt) +{ + int mflag; + struct nfs_args na; + + memset(&na, 0, sizeof na); + na.version = NFS_ARGSVERSION; + na.addr = (struct sockaddr*)sa; + na.addrlen = sizeof *sa; + na.sotype = proto; + na.proto = (proto == SOCK_STREAM) ? IPPROTO_TCP : IPPROTO_UDP; + na.fh = handle; + na.fhsize = nhandle; + na.flags = NFSMNT_RESVPORT|NFSMNT_NFSV3|NFSMNT_INT; + na.wsize = NFS_WSIZE; + na.rsize = NFS_RSIZE; + na.readdirsize = NFS_READDIRSIZE; + na.timeo = 2; + na.retrans = NFS_RETRANS; + na.maxgrouplist = NFS_MAXGRPS; + na.hostname = "backup"; + na.acregmin = 60; + na.acregmax = 600; + na.acdirmin = 60; + na.acdirmax = 600; + + mflag = MNT_RDONLY|MNT_NOSUID|MNT_NOATIME|MNT_NODEV; + if(mount("nfs", mtpt, mflag, &na) < 0) + sysfatal("mount: %r"); +} diff --git a/src/cmd/vbackup/mount-FreeBSD.c b/src/cmd/vbackup/mount-FreeBSD.c index 7803f8bd..0379cee8 100644 --- a/src/cmd/vbackup/mount-FreeBSD.c +++ b/src/cmd/vbackup/mount-FreeBSD.c @@ -1,55 +1 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if __FreeBSD_version >= 500000 -# include -#else -# include -#endif -#include -#include "mountnfs.h" - -void -mountnfs(int proto, struct sockaddr_in *sa, - uchar *handle, int nhandle, char *mtpt) -{ - int mflag; - struct nfs_args na; - - memset(&na, 0, sizeof na); - na.version = NFS_ARGSVERSION; - na.addr = (struct sockaddr*)sa; - na.addrlen = sizeof *sa; - na.sotype = proto; - na.proto = (proto == SOCK_STREAM) ? IPPROTO_TCP : IPPROTO_UDP; - na.fh = handle; - na.fhsize = nhandle; - na.flags = NFSMNT_RESVPORT|NFSMNT_NFSV3|NFSMNT_INT; - na.wsize = NFS_WSIZE; - na.rsize = NFS_RSIZE; - na.readdirsize = NFS_READDIRSIZE; - na.timeo = 2; - na.retrans = NFS_RETRANS; - na.maxgrouplist = NFS_MAXGRPS; - na.readahead = 0; - na.deadthresh = 0; - na.hostname = "backup"; - na.acregmin = 60; - na.acregmax = 600; - na.acdirmin = 60; - na.acdirmax = 600; - - mflag = MNT_RDONLY|MNT_NOSUID|MNT_NOATIME|MNT_NODEV; - if(mount("nfs", mtpt, mflag, &na) < 0) - sysfatal("mount: %r"); -} +#include "mount-BSD.c" diff --git a/src/cmd/vbackup/mount-NetBSD.c b/src/cmd/vbackup/mount-NetBSD.c index ac5cab2a..0379cee8 100644 --- a/src/cmd/vbackup/mount-NetBSD.c +++ b/src/cmd/vbackup/mount-NetBSD.c @@ -1,52 +1 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mountnfs.h" - -void -mountnfs(int proto, struct sockaddr_in *sa, - uchar *handle, int nhandle, char *mtpt) -{ - int mflag; - struct nfs_args na; - - memset(&na, 0, sizeof na); - na.version = NFS_ARGSVERSION; - na.addr = (struct sockaddr*)sa; - na.addrlen = sizeof *sa; - na.sotype = proto; - na.proto = (proto == SOCK_STREAM) ? IPPROTO_TCP : IPPROTO_UDP; - na.fh = handle; - na.fhsize = nhandle; - na.flags = NFSMNT_RESVPORT|NFSMNT_NFSV3|NFSMNT_INT; - na.wsize = NFS_WSIZE; - na.rsize = NFS_RSIZE; - na.readdirsize = NFS_READDIRSIZE; - na.timeo = 2; - na.retrans = NFS_RETRANS; - na.maxgrouplist = NFS_MAXGRPS; - na.readahead = 0; - na.leaseterm = 0; - na.deadthresh = 0; - na.hostname = "backup"; - na.acregmin = 60; - na.acregmax = 600; - na.acdirmin = 60; - na.acdirmax = 600; - - mflag = MNT_RDONLY|MNT_NOSUID|MNT_NOATIME|MNT_NODEV; - if(mount("nfs", mtpt, mflag, &na) < 0) - sysfatal("mount: %r"); -} +#include "mount-BSD.c" diff --git a/src/cmd/vbackup/mount-OpenBSD.c b/src/cmd/vbackup/mount-OpenBSD.c index ac5cab2a..0379cee8 100644 --- a/src/cmd/vbackup/mount-OpenBSD.c +++ b/src/cmd/vbackup/mount-OpenBSD.c @@ -1,52 +1 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mountnfs.h" - -void -mountnfs(int proto, struct sockaddr_in *sa, - uchar *handle, int nhandle, char *mtpt) -{ - int mflag; - struct nfs_args na; - - memset(&na, 0, sizeof na); - na.version = NFS_ARGSVERSION; - na.addr = (struct sockaddr*)sa; - na.addrlen = sizeof *sa; - na.sotype = proto; - na.proto = (proto == SOCK_STREAM) ? IPPROTO_TCP : IPPROTO_UDP; - na.fh = handle; - na.fhsize = nhandle; - na.flags = NFSMNT_RESVPORT|NFSMNT_NFSV3|NFSMNT_INT; - na.wsize = NFS_WSIZE; - na.rsize = NFS_RSIZE; - na.readdirsize = NFS_READDIRSIZE; - na.timeo = 2; - na.retrans = NFS_RETRANS; - na.maxgrouplist = NFS_MAXGRPS; - na.readahead = 0; - na.leaseterm = 0; - na.deadthresh = 0; - na.hostname = "backup"; - na.acregmin = 60; - na.acregmax = 600; - na.acdirmin = 60; - na.acdirmax = 600; - - mflag = MNT_RDONLY|MNT_NOSUID|MNT_NOATIME|MNT_NODEV; - if(mount("nfs", mtpt, mflag, &na) < 0) - sysfatal("mount: %r"); -} +#include "mount-BSD.c" -- cgit v1.2.3