diff options
author | obrien <obrien@FreeBSD.org> | 1998-08-23 22:07:21 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 1998-08-23 22:07:21 +0000 |
commit | 663d5a0f32ed8dfc091ffb6153161591ac6ba563 (patch) | |
tree | 60b090a6cbdb64326bb128ea49a231d08eb2680e /contrib/amd/conf | |
download | FreeBSD-src-663d5a0f32ed8dfc091ffb6153161591ac6ba563.zip FreeBSD-src-663d5a0f32ed8dfc091ffb6153161591ac6ba563.tar.gz |
Virgin import of AMD (am-utils) v6.0a16
Diffstat (limited to 'contrib/amd/conf')
-rw-r--r-- | contrib/amd/conf/checkmount/checkmount_bsd44.c | 78 | ||||
-rw-r--r-- | contrib/amd/conf/fh_dref/fh_dref_freebsd22.h | 2 | ||||
-rw-r--r-- | contrib/amd/conf/hn_dref/hn_dref_default.h | 2 | ||||
-rw-r--r-- | contrib/amd/conf/mount/mount_freebsd3.c | 68 | ||||
-rw-r--r-- | contrib/amd/conf/mtab/mtab_bsd.c | 145 | ||||
-rw-r--r-- | contrib/amd/conf/nfs_prot/nfs_prot_freebsd2.h | 146 | ||||
-rw-r--r-- | contrib/amd/conf/nfs_prot/nfs_prot_freebsd3.h | 211 | ||||
-rw-r--r-- | contrib/amd/conf/sa_dref/sa_dref_bsd44.h | 5 | ||||
-rw-r--r-- | contrib/amd/conf/transp/transp_sockets.c | 399 | ||||
-rw-r--r-- | contrib/amd/conf/trap/trap_default.h | 2 | ||||
-rw-r--r-- | contrib/amd/conf/trap/trap_freebsd3.h | 3 | ||||
-rw-r--r-- | contrib/amd/conf/umount/umount_bsd44.c | 89 |
12 files changed, 1150 insertions, 0 deletions
diff --git a/contrib/amd/conf/checkmount/checkmount_bsd44.c b/contrib/amd/conf/checkmount/checkmount_bsd44.c new file mode 100644 index 0000000..80276e6 --- /dev/null +++ b/contrib/amd/conf/checkmount/checkmount_bsd44.c @@ -0,0 +1,78 @@ +/* + * Copyright (c) 1997-1998 Erez Zadok + * Copyright (c) 1990 Jan-Simon Pendry + * Copyright (c) 1990 Imperial College of Science, Technology & Medicine + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry at Imperial College, London. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * %W% (Berkeley) %G% + * + * $Id: checkmount_bsd44.c,v 5.2.2.2 1992/05/31 16:35:45 jsp Exp $ + * + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ +#include <am_defs.h> + +extern int is_same_host(char *name1, char *name2, struct in_addr addr2); +int fixmount_check_mount(char *host, struct in_addr hostaddr, char *path); + +int +fixmount_check_mount(char *host, struct in_addr hostaddr, char *path) +{ + struct statfs *mntbufp, *mntp; + int nloc, i; + char *colon; + + /* read mount table from kernel */ + nloc = getmntinfo(&mntbufp, MNT_NOWAIT); + if (nloc <= 0) { + perror("getmntinfo"); + exit(1); + } + + mntp = mntbufp; + for (i=0; i<nloc; ++i) { + if ((colon = strchr(mntp->f_mntfromname, ':'))) { + *colon = '\0'; + if (STREQ(colon + 1, path) && + is_same_host(mntp->f_mntfromname, host, hostaddr)) + return 1; + } + } + + return 0; +} diff --git a/contrib/amd/conf/fh_dref/fh_dref_freebsd22.h b/contrib/amd/conf/fh_dref/fh_dref_freebsd22.h new file mode 100644 index 0000000..989561d --- /dev/null +++ b/contrib/amd/conf/fh_dref/fh_dref_freebsd22.h @@ -0,0 +1,2 @@ +/* $srcdir/conf/fh_dref/fh_dref_freebsd22.h */ +#define NFS_FH_DREF(dst, src) (dst) = (u_char *) (src) diff --git a/contrib/amd/conf/hn_dref/hn_dref_default.h b/contrib/amd/conf/hn_dref/hn_dref_default.h new file mode 100644 index 0000000..d495ea8 --- /dev/null +++ b/contrib/amd/conf/hn_dref/hn_dref_default.h @@ -0,0 +1,2 @@ +/* $srcdir/conf/hn_dref/hn_dref_default.h */ +#define NFS_HN_DREF(dst, src) (dst) = (src) diff --git a/contrib/amd/conf/mount/mount_freebsd3.c b/contrib/amd/conf/mount/mount_freebsd3.c new file mode 100644 index 0000000..5888ed9 --- /dev/null +++ b/contrib/amd/conf/mount/mount_freebsd3.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1997-1998 Erez Zadok + * Copyright (c) 1990 Jan-Simon Pendry + * Copyright (c) 1990 Imperial College of Science, Technology & Medicine + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry at Imperial College, London. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * %W% (Berkeley) %G% + * + * $Id: mount_freebsd3.c,v 5.2.2.1 1992/02/09 15:10:08 jsp beta $ + * + */ + +/* + * FreeBSD 3.x (as of snapshot 3.0-980311-SNAP) Mount helper + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ +#include <am_defs.h> +#include <amu.h> + +/* + * Map from conventional mount arguments + * to FreeBSD 3.0 style arguments. + */ +int +mount_freebsd3(MTYPE_TYPE type, const char *dir, int flags, voidp data) +{ + char const *namelist[] = INITMOUNTNAMES; + + return mount(namelist[type], + dir, + flags, + data); +} diff --git a/contrib/amd/conf/mtab/mtab_bsd.c b/contrib/amd/conf/mtab/mtab_bsd.c new file mode 100644 index 0000000..100d7d5 --- /dev/null +++ b/contrib/amd/conf/mtab/mtab_bsd.c @@ -0,0 +1,145 @@ +/* + * Copyright (c) 1997-1998 Erez Zadok + * Copyright (c) 1990 Jan-Simon Pendry + * Copyright (c) 1990 Imperial College of Science, Technology & Medicine + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry at Imperial College, London. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * %W% (Berkeley) %G% + * + * $Id: mtab_bsd.c,v 5.2.2.2 1992/11/12 23:29:14 jsp Exp $ + * + */ + +/* + * BSD 4.4 systems don't write their mount tables on a file. Instead, they + * use a (better) system where the kernel keeps this state, and you access + * the mount tables via a known interface. + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ +#include <am_defs.h> +#include <amu.h> + + +static mntent_t * +mnt_dup(struct statfs *mp) +{ + mntent_t *new_mp = ALLOC(mntent_t); + char *ty; + + new_mp->mnt_fsname = strdup(mp->f_mntfromname); + new_mp->mnt_dir = strdup(mp->f_mntonname); + +#ifdef HAVE_FIELD_STRUCT_STATFS_F_FSTYPENAME + ty = mp->f_fstypename; +#else /* not HAVE_FIELD_STRUCT_STATFS_F_FSTYPENAME */ + switch (mp->f_type) { + +# if defined(MOUNT_UFS) && defined(MNTTAB_TYPE_UFS) + case MOUNT_UFS: + ty = MNTTAB_TYPE_UFS; + break; +# endif /* defined(MOUNT_UFS) && defined(MNTTAB_TYPE_UFS) */ + +# if defined(MOUNT_NFS) && defined(MNTTAB_TYPE_NFS) + case MOUNT_NFS: + ty = MNTTAB_TYPE_NFS; + break; +# endif /* defined(MOUNT_NFS) && defined(MNTTAB_TYPE_NFS) */ + +# if defined(MOUNT_MFS) && defined(MNTTAB_TYPE_MFS) + case MOUNT_MFS: + ty = MNTTAB_TYPE_MFS; + break; +# endif /* defined(MOUNT_MFS) && defined(MNTTAB_TYPE_MFS) */ + + default: + ty = "unknown"; + + break; + } +#endif /* not HAVE_FIELD_STRUCT_STATFS_F_FSTYPENAME */ + + new_mp->mnt_type = strdup(ty); + new_mp->mnt_opts = strdup("unset"); + new_mp->mnt_freq = 0; + new_mp->mnt_passno = 0; + + return new_mp; +} + + +/* + * Read a mount table into memory + */ +mntlist * +read_mtab(char *fs, const char *mnttabname) +{ + mntlist **mpp, *mhp; + struct statfs *mntbufp, *mntp; + + int nloc = getmntinfo(&mntbufp, MNT_NOWAIT); + + if (nloc == 0) { + plog(XLOG_ERROR, "Can't read mount table"); + return 0; + } + mpp = &mhp; + for (mntp = mntbufp; mntp < mntbufp + nloc; mntp++) { + /* + * Allocate a new slot + */ + *mpp = ALLOC(struct mntlist); + + /* + * Copy the data returned by getmntent + */ + (*mpp)->mnt = mnt_dup(mntp); + + /* + * Move to next pointer + */ + mpp = &(*mpp)->mnext; + } + + /* + * Terminate the list + */ + *mpp = 0; + + return mhp; +} diff --git a/contrib/amd/conf/nfs_prot/nfs_prot_freebsd2.h b/contrib/amd/conf/nfs_prot/nfs_prot_freebsd2.h new file mode 100644 index 0000000..e55e114 --- /dev/null +++ b/contrib/amd/conf/nfs_prot/nfs_prot_freebsd2.h @@ -0,0 +1,146 @@ +/* + * Copyright (c) 1997-1998 Erez Zadok + * Copyright (c) 1990 Jan-Simon Pendry + * Copyright (c) 1990 Imperial College of Science, Technology & Medicine + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry at Imperial College, London. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * %W% (Berkeley) %G% + * + * $Id: nfs_prot_freebsd2.h,v 1.1 1996/01/13 23:23:39 ezk Exp ezk $ + * + */ + +#ifndef _AMU_NFS_PROT_H +#define _AMU_NFS_PROT_H + +#ifdef HAVE_RPCSVC_NFS_PROT_H +# include <rpcsvc/nfs_prot.h> +#endif /* HAVE_RPCSVC_NFS_PROT_H */ + +/* + * MACROS: + */ +#define dr_drok_u diropres +#define ca_where where +#define da_fhandle dir +#define da_name name +#define dl_entries entries +#define dl_eof eof +#define dr_status status +#define dr_u diropres_u +#define drok_attributes attributes +#define drok_fhandle file +#define fh_data data +#define la_fhandle from +#define la_to to +#define na_atime atime +#define na_ctime ctime +#define na_fileid fileid +#define na_fsid fsid +#define na_mode mode +#define na_mtime mtime +#define na_nlink nlink +#define na_size size +#define na_type type +#define ne_cookie cookie +#define ne_fileid fileid +#define ne_name name +#define ne_nextentry nextentry +#define ns_attr_u attributes +#define ns_status status +#define ns_u attrstat_u +#define nt_seconds seconds +#define nt_useconds useconds +#define rda_cookie cookie +#define rda_count count +#define rda_fhandle dir +#define rdr_reply_u reply +#define rdr_status status +#define rdr_u readdirres_u +#define rlr_data_u data +#define rlr_status status +#define rlr_u readlinkres_u +#define rna_from from +#define rna_to to +#define rr_status status +#define sag_fhandle file +#define sfr_reply_u reply +#define sfr_status status +#define sfr_u statfsres_u +#define sfrok_bavail bavail +#define sfrok_bfree bfree +#define sfrok_blocks blocks +#define sfrok_bsize bsize +#define sfrok_tsize tsize +#define sla_from from +#define wra_fhandle file + + +/* + * TYPEDEFS: + */ +typedef attrstat nfsattrstat; +typedef createargs nfscreateargs; +typedef dirlist nfsdirlist; +typedef diropargs nfsdiropargs; +typedef diropres nfsdiropres; +typedef entry nfsentry; +typedef fattr nfsfattr; +typedef ftype nfsftype; +typedef linkargs nfslinkargs; +typedef readargs nfsreadargs; +typedef readdirargs nfsreaddirargs; +typedef readdirres nfsreaddirres; +typedef readlinkres nfsreadlinkres; +typedef readres nfsreadres; +typedef renameargs nfsrenameargs; +typedef sattrargs nfssattrargs; +typedef statfsokres nfsstatfsokres; +typedef statfsres nfsstatfsres; +typedef symlinkargs nfssymlinkargs; +typedef writeargs nfswriteargs; + + +/* + * FreeBSD 2.2.x has NFS V3, but it does not define enough macros + * in the headers to automatically detect it. + * So fake it in the meant time. + */ +#if 0 +#define MOUNT_NFS3 MOUNT_NFS +#endif + + +#endif /* not _AMU_NFS_PROT_H */ diff --git a/contrib/amd/conf/nfs_prot/nfs_prot_freebsd3.h b/contrib/amd/conf/nfs_prot/nfs_prot_freebsd3.h new file mode 100644 index 0000000..915f014 --- /dev/null +++ b/contrib/amd/conf/nfs_prot/nfs_prot_freebsd3.h @@ -0,0 +1,211 @@ +/* + * Copyright (c) 1997-1998 Erez Zadok + * Copyright (c) 1990 Jan-Simon Pendry + * Copyright (c) 1990 Imperial College of Science, Technology & Medicine + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry at Imperial College, London. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * %W% (Berkeley) %G% + * + * $Id: nfs_prot_freebsd3.h,v 1.1 1996/01/13 23:23:39 ezk Exp ezk $ + * + */ + +#ifndef _AMU_NFS_PROT_H +#define _AMU_NFS_PROT_H + +#ifdef HAVE_RPCSVC_NFS_PROT_H +# include <rpcsvc/nfs_prot.h> +#endif /* HAVE_RPCSVC_NFS_PROT_H */ +#ifdef HAVE_NFS_RPCV2_H +# include <nfs/rpcv2.h> +#endif /* HAVE_NFS_RPCV2_H */ +#ifdef HAVE_NFS_NFS_H +# include <nfs/nfs.h> +#endif /* HAVE_NFS_NFS_H */ + +/* + * MACROS: + */ +#define dr_drok_u diropres +#define ca_where where +#define da_fhandle dir +#define da_name name +#define dl_entries entries +#define dl_eof eof +#define dr_status status +#define dr_u diropres_u +#define drok_attributes attributes +#define drok_fhandle file +#define fh_data data +#define la_fhandle from +#define la_to to +#define na_atime atime +#define na_ctime ctime +#define na_fileid fileid +#define na_fsid fsid +#define na_mode mode +#define na_mtime mtime +#define na_nlink nlink +#define na_size size +#define na_type type +#define ne_cookie cookie +#define ne_fileid fileid +#define ne_name name +#define ne_nextentry nextentry +#define ns_attr_u attributes +#define ns_status status +#define ns_u attrstat_u +#define nt_seconds seconds +#define nt_useconds useconds +#define rda_cookie cookie +#define rda_count count +#define rda_fhandle dir +#define rdr_reply_u reply +#define rdr_status status +#define rdr_u readdirres_u +#define rlr_data_u data +#define rlr_status status +#define rlr_u readlinkres_u +#define rna_from from +#define rna_to to +#define rr_status status +#define sag_fhandle file +#define sfr_reply_u reply +#define sfr_status status +#define sfr_u statfsres_u +#define sfrok_bavail bavail +#define sfrok_bfree bfree +#define sfrok_blocks blocks +#define sfrok_bsize bsize +#define sfrok_tsize tsize +#define sla_from from +#define wra_fhandle file + + +/* + * TYPEDEFS: + */ +typedef attrstat nfsattrstat; +typedef createargs nfscreateargs; +typedef dirlist nfsdirlist; +typedef diropargs nfsdiropargs; +typedef diropres nfsdiropres; +typedef entry nfsentry; +typedef fattr nfsfattr; +typedef ftype nfsftype; +typedef linkargs nfslinkargs; +typedef readargs nfsreadargs; +typedef readdirargs nfsreaddirargs; +typedef readdirres nfsreaddirres; +typedef readlinkres nfsreadlinkres; +typedef readres nfsreadres; +typedef renameargs nfsrenameargs; +typedef sattrargs nfssattrargs; +typedef statfsokres nfsstatfsokres; +typedef statfsres nfsstatfsres; +typedef symlinkargs nfssymlinkargs; +typedef writeargs nfswriteargs; + + +/* + * + * FreeBSD 3.0 has NFS V3, but you need to regenrate the rpcsc header files + * as follows: + * cd /usr/local/rpcsvc + * rpcgen -DWANT_NFS3 mount.x + * rpcgen -DWANT_NFS3 nfs_prot.x + * But that's not expected of everyone, plus there are additional things + * needed so I define everything that's neede for NFS V3 here. + */ +#ifdef NFSMNT_NFSV3 + +# define MOUNT_NFS3 MOUNT_NFS +# define MNTOPT_NFS3 "nfs" + +#define FHSIZE3 64 /* size in bytes of a file handle (v3) */ +#define NFS3_FHSIZE 64 +#define MOUNTVERS3 ((unsigned long)(3)) +#define NFS_V3 ((unsigned long)(3)) + +typedef struct { + u_int fhandle3_len; + char *fhandle3_val; +} fhandle3; + +enum mountstat3 { + MNT3_OK = 0, + MNT3ERR_PERM = 1, + MNT3ERR_NOENT = 2, + MNT3ERR_IO = 5, + MNT3ERR_ACCES = 13, + MNT3ERR_NOTDIR = 20, + MNT3ERR_INVAL = 22, + MNT3ERR_NAMETOOLONG = 63, + MNT3ERR_NOTSUPP = 10004, + MNT3ERR_SERVERFAULT = 10006 +}; +typedef enum mountstat3 mountstat3; + +struct mountres3_ok { + fhandle3 fhandle; + struct { + u_int auth_flavors_len; + int *auth_flavors_val; + } auth_flavors; +}; +typedef struct mountres3_ok mountres3_ok; + +struct mountres3 { + mountstat3 fhs_status; + union { + mountres3_ok mountinfo; + } mountres3_u; +}; +typedef struct mountres3 mountres3; + +struct nfs_fh3 { + u_int fh3_length; + union nfs_fh3_u { + struct nfs_fh3_i { + fhandle_t fh3_i; + } nfs_fh3_i; + char data[NFS3_FHSIZE]; + } fh3_u; +}; +typedef struct nfs_fh3 nfs_fh3; + +#endif /* NFSMNT_NFSV3 */ + +#endif /* not _AMU_NFS_PROT_H */ diff --git a/contrib/amd/conf/sa_dref/sa_dref_bsd44.h b/contrib/amd/conf/sa_dref/sa_dref_bsd44.h new file mode 100644 index 0000000..e76c16b --- /dev/null +++ b/contrib/amd/conf/sa_dref/sa_dref_bsd44.h @@ -0,0 +1,5 @@ +/* $srcdir/conf/sa_dref/sa_dref_bsd44.h */ +#define NFS_SA_DREF(dst, src) { \ + (dst)->addr = (struct sockaddr *) (src); \ + (dst)->addrlen = sizeof(*src); \ + } diff --git a/contrib/amd/conf/transp/transp_sockets.c b/contrib/amd/conf/transp/transp_sockets.c new file mode 100644 index 0000000..45aa01e --- /dev/null +++ b/contrib/amd/conf/transp/transp_sockets.c @@ -0,0 +1,399 @@ +/* + * Copyright (c) 1997-1998 Erez Zadok + * Copyright (c) 1990 Jan-Simon Pendry + * Copyright (c) 1990 Imperial College of Science, Technology & Medicine + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry at Imperial College, London. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * %W% (Berkeley) %G% + * + * $Id: transp_sockets.c,v 5.2.2.2 1992/07/18 18:57:03 jsp Exp jsp $ + * + * Socket specific utilities. + * -Erez Zadok <ezk@cs.columbia.edu> + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ +#include <am_defs.h> +#include <amu.h> + + +/* + * find the IP address that can be used to connect to the local host + */ +void +amu_get_myaddress(struct in_addr *iap) +{ + struct sockaddr_in sin; + + memset((char *) &sin, 0, sizeof(sin)); + get_myaddress(&sin); + iap->s_addr = sin.sin_addr.s_addr; +} + + +/* + * How to bind to reserved ports. + */ +int +bind_resv_port(int so, u_short *pp) +{ + struct sockaddr_in sin; + int rc; + u_short port; + + memset((voidp) &sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + + port = IPPORT_RESERVED; + + do { + --port; + sin.sin_port = htons(port); + rc = bind(so, (struct sockaddr *) &sin, sizeof(sin)); + } while (rc < 0 && (int) port > IPPORT_RESERVED / 2); + + if (pp && rc == 0) + *pp = port; + + return rc; +} + + +/* + * close a descriptor, Sockets style + */ +int +amu_close(int fd) +{ + return close(fd); +} + + +/* + * Create an rpc client attached to the mount daemon. + */ +CLIENT * +get_mount_client(char *unused_host, struct sockaddr_in *sin, struct timeval *tv, int *sock, u_long mnt_version) +{ + CLIENT *client; + + /* + * First try a TCP socket + */ + if ((*sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) > 0) { + /* + * Bind to a privileged port + */ + if (bind_resv_port(*sock, (u_short *) 0) < 0) + plog(XLOG_ERROR, "can't bind privileged port"); + + /* + * Find mountd port to connect to. + * Connect to mountd. + * Create a tcp client. + */ + if ((sin->sin_port = htons(pmap_getport(sin, MOUNTPROG, mnt_version, IPPROTO_TCP))) != 0) { + if (connect(*sock, (struct sockaddr *) sin, sizeof(*sin)) >= 0 + && ((client = clnttcp_create(sin, MOUNTPROG, mnt_version, sock, 0, 0)) != NULL)) + return client; + } + /* + * Failed so close socket + */ + (void) close(*sock); + } /* tcp socket opened */ + /* TCP failed so try UDP */ + if ((*sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + plog(XLOG_ERROR, "Can't create socket to connect to mountd: %m"); + *sock = RPC_ANYSOCK; + return NULL; + } + /* + * Bind to a privileged port + */ + if (bind_resv_port(*sock, (u_short *) 0) < 0) + plog(XLOG_ERROR, "can't bind privileged port"); + + /* + * Zero out the port - make sure we recompute + */ + sin->sin_port = 0; + + /* + * Make a UDP client + */ + if ((client = clntudp_create(sin, MOUNTPROG, mnt_version, *tv, sock)) == NULL) { + (void) close(*sock); + *sock = RPC_ANYSOCK; + return NULL; + } +#ifdef DEBUG + dlog("get_mount_client: Using udp, port %d", sin->sin_port); +#endif /* DEBUG */ + return client; +} + + +/* + * find the address of the caller of an RPC procedure. + */ +struct sockaddr_in * +amu_svc_getcaller(SVCXPRT *xprt) +{ + return svc_getcaller(xprt); +} + + +/* + * Bind NFS to a reserved port. + */ +static int +bindnfs_port(int so, u_short *nfs_portp) +{ + u_short port; + int error = bind_resv_port(so, &port); + + if (error == 0) + *nfs_portp = port; + return error; +} + + +/* + * Create the nfs service for amd + */ +int +create_nfs_service(int *soNFSp, u_short *nfs_portp, SVCXPRT **nfs_xprtp, void (*dispatch_fxn)(struct svc_req *rqstp, SVCXPRT *transp)) +{ + + *soNFSp = socket(AF_INET, SOCK_DGRAM, 0); + + if (*soNFSp < 0 || bindnfs_port(*soNFSp, nfs_portp) < 0) { + plog(XLOG_FATAL, "Can't create privileged nfs port"); + return 1; + } + + if ((*nfs_xprtp = svcudp_create(*soNFSp)) == NULL) { + plog(XLOG_FATAL, "cannot create rpc/udp service"); + return 2; + } + + if (!svc_register(*nfs_xprtp, NFS_PROGRAM, NFS_VERSION, dispatch_fxn, 0)) { + plog(XLOG_FATAL, "unable to register (NFS_PROGRAM, NFS_VERSION, 0)"); + return 3; + } + + return 0; /* all is well */ +} + + +/* + * Create the amq service for amd (both TCP and UDP) + */ +int +create_amq_service(int *udp_soAMQp, SVCXPRT **udp_amqpp, int *tcp_soAMQp, SVCXPRT **tcp_amqpp) +{ + /* first create TCP service */ + if (tcp_soAMQp) { + *tcp_soAMQp = socket(AF_INET, SOCK_STREAM, 0); + if (*tcp_soAMQp < 0) { + plog(XLOG_FATAL, "cannot create tcp socket for amq service: %m"); + return 1; + } + + /* now create RPC service handle for amq */ + if (tcp_amqpp && + (*tcp_amqpp = svctcp_create(*tcp_soAMQp, AMQ_SIZE, AMQ_SIZE)) == NULL) { + plog(XLOG_FATAL, "cannot create tcp service for amq: soAMQp=%d", *tcp_soAMQp); + return 2; + } + } + + /* next create UDP service */ + if (udp_soAMQp) { + *udp_soAMQp = socket(AF_INET, SOCK_DGRAM, 0); + if (*udp_soAMQp < 0) { + plog(XLOG_FATAL, "cannot create udp socket for amq service: %m"); + return 3; + } + + /* now create RPC service handle for amq */ + if (udp_amqpp && + (*udp_amqpp = svcudp_bufcreate(*udp_soAMQp, AMQ_SIZE, AMQ_SIZE)) == NULL) { + plog(XLOG_FATAL, "cannot create udp service for amq: soAMQp=%d", *udp_soAMQp); + return 4; + } + } + + return 0; /* all is well */ +} + + +/* + * Ping the portmapper on a remote system by calling the nullproc + */ +enum clnt_stat +pmap_ping(struct sockaddr_in *address) +{ + CLIENT *client; + enum clnt_stat clnt_stat = RPC_TIMEDOUT; /* assume failure */ + int socket = RPC_ANYSOCK; + struct timeval timeout; + + timeout.tv_sec = 3; + timeout.tv_usec = 0; + address->sin_port = htons(PMAPPORT); + client = clntudp_create(address, PMAPPROG, PMAPVERS, timeout, &socket); + if (client != (CLIENT *) NULL) { + clnt_stat = clnt_call(client, + PMAPPROC_NULL, + (XDRPROC_T_TYPE) xdr_void, + NULL, + (XDRPROC_T_TYPE) xdr_void, + NULL, + timeout); + clnt_destroy(client); + } + close(socket); + address->sin_port = 0; + + return clnt_stat; +} + + +/* + * Find the best NFS version for a host and protocol. + */ +u_long +get_nfs_version(char *host, struct sockaddr_in *sin, u_long nfs_version, const char *proto) +{ + CLIENT *clnt; + int again = 0; + enum clnt_stat clnt_stat; + struct timeval tv; + int sock; + + /* + * If not set or set wrong, then try from NFS_VERS_MAX on down. If + * set, then try from nfs_version on down. + */ + if (nfs_version <= 0 || nfs_version > NFS_VERS_MAX) { + nfs_version = NFS_VERS_MAX; + again = 1; + } + tv.tv_sec = 3; /* retry every 3 seconds, but also timeout */ + tv.tv_usec = 0; + + /* + * First check if remote portmapper is up (verify if remote host is up). + */ + clnt_stat = pmap_ping(sin); + if (clnt_stat == RPC_TIMEDOUT) { + plog(XLOG_ERROR, "get_nfs_version: failed to contact portmapper on host \"%s\": %s", host, clnt_sperrno(clnt_stat)); + return 0; + } + +#ifdef HAVE_FS_NFS3 +try_again: +#endif /* HAVE_FS_NFS3 */ + + sock = RPC_ANYSOCK; + if (STREQ(proto, "tcp")) + clnt = clnttcp_create(sin, NFS_PROGRAM, nfs_version, &sock, 0, 0); + else if (STREQ(proto, "udp")) + clnt = clntudp_create(sin, NFS_PROGRAM, nfs_version, tv, &sock); + else + clnt = NULL; + + if (clnt == NULL) { +#ifdef HAVE_CLNT_SPCREATEERROR + plog(XLOG_INFO, "get_nfs_version NFS(%d,%s) failed for %s :%s", + nfs_version, proto, host, clnt_spcreateerror("")); +#else /* not HAVE_CLNT_SPCREATEERROR */ + plog(XLOG_INFO, "get_nfs_version NFS(%d,%s) failed for %s", + nfs_version, proto, host); +#endif /* not HAVE_CLNT_SPCREATEERROR */ + return 0; + } + + /* Try a couple times to verify the CLIENT handle. */ + tv.tv_sec = 6; + clnt_stat = clnt_call(clnt, + NFSPROC_NULL, + (XDRPROC_T_TYPE) xdr_void, + 0, + (XDRPROC_T_TYPE) xdr_void, + 0, + tv); + close(sock); + clnt_destroy(clnt); + if (clnt_stat != RPC_SUCCESS) { + if (again) { +#ifdef HAVE_FS_NFS3 + if (nfs_version == NFS_VERSION3) { + plog(XLOG_INFO, "get_nfs_version trying a lower version"); + nfs_version = NFS_VERSION; + again = 0; + } + goto try_again; +#endif /* HAVE_FS_NFS3 */ + } + plog(XLOG_INFO, "get_nfs_version NFS(%d,%s) failed for %s", + nfs_version, proto, host); + return 0; + } + + plog(XLOG_INFO, "get_nfs_version: returning (%d,%s) on host %s", + nfs_version, proto, host); + return nfs_version; +} + + +/* + * AUTOFS FUNCTIONS FOR SOCKETS: + */ +#ifdef HAVE_FS_AUTOFS +/* + * Create the nfs service for amd + */ +int +create_autofs_service(int *soAUTOFSp, u_short *autofs_portp, SVCXPRT **autofs_xprtp, void (*dispatch_fxn)(struct svc_req *rqstp, SVCXPRT *transp)) +{ + /* NOT IMPLEMENTED! */ + return -1; +} +#endif /* HAVE_FS_AUTOFS */ diff --git a/contrib/amd/conf/trap/trap_default.h b/contrib/amd/conf/trap/trap_default.h new file mode 100644 index 0000000..a132b0e --- /dev/null +++ b/contrib/amd/conf/trap/trap_default.h @@ -0,0 +1,2 @@ +/* $srcdir/conf/trap/trap_default.h */ +#define MOUNT_TRAP(type, mnt, flags, mnt_data) mount(type, mnt->mnt_dir, flags, mnt_data) diff --git a/contrib/amd/conf/trap/trap_freebsd3.h b/contrib/amd/conf/trap/trap_freebsd3.h new file mode 100644 index 0000000..95c6642 --- /dev/null +++ b/contrib/amd/conf/trap/trap_freebsd3.h @@ -0,0 +1,3 @@ +/* $srcdir/conf/trap/trap_freebsd3.h */ +extern int mount_freebsd3(MTYPE_TYPE type, const char *dir, int flags, voidp data); +#define MOUNT_TRAP(type, mnt, flags, mnt_data) mount_freebsd3(type, mnt->mnt_dir, flags, mnt_data) diff --git a/contrib/amd/conf/umount/umount_bsd44.c b/contrib/amd/conf/umount/umount_bsd44.c new file mode 100644 index 0000000..4e241b3 --- /dev/null +++ b/contrib/amd/conf/umount/umount_bsd44.c @@ -0,0 +1,89 @@ +/* + * Copyright (c) 1997-1998 Erez Zadok + * Copyright (c) 1990 Jan-Simon Pendry + * Copyright (c) 1990 Imperial College of Science, Technology & Medicine + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry at Imperial College, London. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * %W% (Berkeley) %G% + * + * $Id: umount_bsd44.c,v 5.2.2.2 1993/01/27 07:32:45 jsp Exp $ + * + */ + +/* + * Unmounting filesystems under BSD 4.4. + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ +#include <am_defs.h> +#include <amu.h> + + +int +umount_fs(char *fs_name, const char *mnttabname) +{ + int error; + +eintr: + error = unmount(fs_name, 0); + if (error < 0) + error = errno; + + switch (error) { + case EINVAL: + case ENOTBLK: + case ENOENT: + plog(XLOG_WARNING, "unmount: %s is not mounted", fs_name); + error = 0; /* Not really an error */ + break; + + case EINTR: +#ifdef DEBUG + /* not sure why this happens, but it does. ask kirk one day... */ + dlog("%s: unmount: %m", fs_name); +#endif /* DEBUG */ + goto eintr; + +#ifdef DEBUG + default: + dlog("%s: unmount: %m", fs_name); + break; +#endif /* DEBUG */ + } + + return error; +} |