From 11a17b7f2ca8c8b50fc75d519c6b517f63dffb2b Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Wed, 6 Jul 2005 22:34:26 +0000 Subject: [PATCH] * conf/nfs_prot/nfs_prot_aix4_3.h: cleanup struct aix4_nfs_args_bis. * Makefile.am (EXTRA_DIST_CONF): include mount_aix3.c in distribution. * conf/mount/mount_aix.c: mount style for aix 5.x and newer. * conf/mount/mount_aix3.c: mount styles for aix 3.x/4.x. * m4/macros/check_mount_style.m4: split mount styles for aix3.x/4.x and the newer (and better) aix 5.x code. --- ChangeLog | 15 +++ Makefile.am | 1 + conf/mount/mount_aix.c | 70 ++-------- conf/mount/mount_aix3.c | 230 ++++++++++++++++++++++++++++++++ conf/nfs_prot/nfs_prot_aix4_3.h | 11 +- m4/macros/check_mount_style.m4 | 2 + 6 files changed, 262 insertions(+), 67 deletions(-) create mode 100644 conf/mount/mount_aix3.c diff --git a/ChangeLog b/ChangeLog index c802c06..8c5dcdf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2005-07-06 Erez Zadok + + * conf/nfs_prot/nfs_prot_aix4_3.h: cleanup struct + aix4_nfs_args_bis. + + * Makefile.am (EXTRA_DIST_CONF): include mount_aix3.c in + distribution. + + * conf/mount/mount_aix.c: mount style for aix 5.x and newer. + + * conf/mount/mount_aix3.c: mount styles for aix 3.x/4.x. + + * m4/macros/check_mount_style.m4: split mount styles for + aix3.x/4.x and the newer (and better) aix 5.x code. + 2005-07-05 Erez Zadok * amq/pawd.c (getawd): avoid buffer overflow. Bug fix from Graeme diff --git a/Makefile.am b/Makefile.am index 55dd055..23dfa1f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -174,6 +174,7 @@ EXTRA_DIST_CONF = \ conf/hn_dref/hn_dref_linux.h \ \ conf/mount/mount_aix.c \ + conf/mount/mount_aix3.c \ conf/mount/mount_bsdi3.c \ conf/mount/mount_default.c \ conf/mount/mount_hpux.c \ diff --git a/conf/mount/mount_aix.c b/conf/mount/mount_aix.c index bbb00e3..961f48a 100644 --- a/conf/mount/mount_aix.c +++ b/conf/mount/mount_aix.c @@ -38,12 +38,12 @@ * * %W% (Berkeley) %G% * - * $Id: mount_aix.c,v 1.15 2005/06/25 02:25:37 ezk Exp $ + * $Id: mount_aix.c,v 1.16 2005/07/06 22:34:26 ezk Exp $ * */ /* - * AIX 3-5 Mount helper + * AIX 5.x Mount helper */ #ifdef HAVE_CONFIG_H @@ -64,7 +64,7 @@ extern int vmount(struct vmount *vmount, int size); static int -aix3_mkvp(char *p, int gfstype, int flags, char *object, char *stub, char *host, char *info, int info_size, char *args) +aix5_mkvp(char *p, int gfstype, int flags, char *object, char *stub, char *host, char *info, int info_size, char *args) { struct vmount *vp = (struct vmount *) p; @@ -96,33 +96,27 @@ aix3_mkvp(char *p, int gfstype, int flags, char *object, char *stub, char *host, /* - * Map from conventional mount arguments - * to AIX 3-style arguments. + * Map from conventional mount arguments to AIX 3,x style arguments. + * But we avoid all the messy BIS stuff for AIX 5.x */ int mount_aix3(char *fsname, char *dir, int flags, int type, void *data, char *mnt_opts) { char buf[4096]; int size, ret; - int real_size = sizeof(nfs_args_t); /* size passed to aix3_mkvp() */ - char *real_args = data; /* args passed to aix3_mkvp() */ + int real_size = sizeof(nfs_args_t); /* size passed to aix5_mkvp() */ + char *real_args = data; /* args passed to aix5_mkvp() */ char *host, *rfs, *idx; int aix_type = type; #ifdef HAVE_FS_NFS3 struct nfs_args v2args; nfs_args_t *v3args = (nfs_args_t *) data; -#ifdef MOUNT_TYPE_NFS3_BIS - struct aix4_nfs_args_bis v3args_bis; -#endif /* MOUNT_TYPE_NFS3_BIS */ #endif /* HAVE_FS_NFS3 */ #ifdef DEBUG dlog("mount_aix3: fsname %s, dir %s, type %d", fsname, dir, type); #endif /* DEBUG */ -#ifdef MOUNT_TYPE_NFS3_BIS - retry_ibm_buggy_service_pack: -#endif /* MOUNT_TYPE_NFS3_BIS */ switch (aix_type) { case MOUNT_TYPE_NFS: @@ -133,20 +127,9 @@ mount_aix3(char *fsname, char *dir, int flags, int type, void *data, char *mnt_o * then I must copy the arguments from the v3 nfs_args to the v2 one. */ memmove((voidp) &v2args.addr, (voidp) &v3args->addr, sizeof(struct sockaddr_in)); - /* v2args.u0 = v3args->u0; */ - /* v2args.proto = v3args->proto; */ v2args.hostname = v3args->hostname; v2args.netname = v3args->netname; -#ifdef AIX_52 -#error do not use this code - v2args.fh = v3args->fh; - v2args.syncaddr = v3args->syncaddr; - v2args.proto = v3args->proto; - v2args.numclust = v3args->numclust; - v2args.biods = v3args->biods; -#else /* not AIX_52 */ memmove((voidp) v2args.fh.x, v3args->fh, FHSIZE); -#endif /* not AIX_52 */ v2args.flags = v3args->flags; v2args.wsize = v3args->wsize; v2args.rsize = v3args->rsize; @@ -156,7 +139,6 @@ mount_aix3(char *fsname, char *dir, int flags, int type, void *data, char *mnt_o v2args.acregmax = v3args->acregmax; v2args.acdirmin = v3args->acdirmin; v2args.acdirmax = v3args->acdirmax; - /* v2args.u14 = v3args->u14; */ v2args.pathconf = v3args->pathconf; /* now set real_* stuff */ @@ -164,33 +146,6 @@ mount_aix3(char *fsname, char *dir, int flags, int type, void *data, char *mnt_o real_args = (char *) &v2args; case MOUNT_TYPE_NFS3: -#ifdef MOUNT_TYPE_NFS3_BIS - case MOUNT_TYPE_NFS3_BIS: - /* just fall through */ - if (aix_type == MOUNT_TYPE_NFS3_BIS) { - dlog("mount_aix3: creating alternate nfs3_args structure"); - memmove((voidp) &v3args_bis.addr, (voidp) &v3args->addr, sizeof(struct sockaddr_in)); - v3args_bis.u0 = v3args->u0; - v3args_bis.proto = v3args->proto; - v3args_bis.hostname = v3args->hostname; - v3args_bis.netname = v3args->netname; - v3args_bis.fh = v3args->fh; - v3args_bis.flags = v3args->flags; - v3args_bis.wsize = v3args->wsize; - v3args_bis.rsize = v3args->rsize; - v3args_bis.timeo = v3args->timeo; - v3args_bis.retrans = v3args->retrans; - v3args_bis.acregmin = v3args->acregmin; - v3args_bis.acregmax = v3args->acregmax; - v3args_bis.acdirmin = v3args->acdirmin; - v3args_bis.acdirmax = v3args->acdirmax; - v3args_bis.u14 = v3args->u14; - v3args_bis.pathconf = v3args->pathconf; - /* now set real_* stuff */ - real_size = sizeof(v3args_bis); - real_args = (char *) &v3args_bis; - } -#endif /* MOUNT_TYPE_NFS3_BIS */ #endif /* HAVE_FS_NFS3 */ idx = strchr(fsname, ':'); @@ -204,7 +159,7 @@ mount_aix3(char *fsname, char *dir, int flags, int type, void *data, char *mnt_o host = strdup(am_get_hostname()); } - size = aix3_mkvp(buf, type, flags, rfs, dir, host, + size = aix5_mkvp(buf, type, flags, rfs, dir, host, real_args, real_size, mnt_opts); XFREE(rfs); XFREE(host); @@ -227,15 +182,6 @@ mount_aix3(char *fsname, char *dir, int flags, int type, void *data, char *mnt_o if (ret < 0) { plog(XLOG_ERROR, "mount_aix3: vmount failed with errno %d", errno); perror ("vmount"); -#ifdef MOUNT_TYPE_NFS3_BIS - if (aix_type == MOUNT_TYPE_NFS3 && errno == EINVAL) { - aix_type = MOUNT_TYPE_NFS3_BIS; -#ifdef DEBUG - dlog("mount_aix3: retrying with alternate nfs3_args structure"); -#endif /* DEBUG */ - goto retry_ibm_buggy_service_pack; - } -#endif /* MOUNT_TYPE_NFS3_BIS */ } return ret; } diff --git a/conf/mount/mount_aix3.c b/conf/mount/mount_aix3.c new file mode 100644 index 0000000..153077b --- /dev/null +++ b/conf/mount/mount_aix3.c @@ -0,0 +1,230 @@ +/* + * Copyright (c) 1997-2005 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 acknowledgment: + * 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_aix3.c,v 1.1 2005/07/06 22:34:26 ezk Exp $ + * + */ + +/* + * AIX 3.x/4.x Mount helper + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ +#include +#include + +#define VMT_ROUNDUP(len) (4 * ((len + 3) / 4)) +#define VMT_ASSIGN(vp, idx, data, size) \ + vp->vmt_data[idx].vmt_off = p - (char *) vp; \ + vp->vmt_data[idx].vmt_size = size; \ + memmove(p, data, size); \ + p += VMT_ROUNDUP(size); + +/* missing external definitions from AIX's headers */ +extern int vmount(struct vmount *vmount, int size); + + +static int +aix3_mkvp(char *p, int gfstype, int flags, char *object, char *stub, char *host, char *info, int info_size, char *args) +{ + struct vmount *vp = (struct vmount *) p; + + memset((voidp) vp, 0, sizeof(*vp)); + /* + * Fill in standard fields + */ + vp->vmt_revision = VMT_REVISION; + vp->vmt_flags = flags; + vp->vmt_gfstype = gfstype; + + /* + * Fill in all variable length data + */ + p += sizeof(*vp); + + VMT_ASSIGN(vp, VMT_OBJECT, object, strlen(object) + 1); + VMT_ASSIGN(vp, VMT_STUB, stub, strlen(stub) + 1); + VMT_ASSIGN(vp, VMT_HOST, host, strlen(host) + 1); + VMT_ASSIGN(vp, VMT_HOSTNAME, host, strlen(host) + 1); + VMT_ASSIGN(vp, VMT_INFO, info, info_size); + VMT_ASSIGN(vp, VMT_ARGS, args, strlen(args) + 1); + + /* + * Return length + */ + return vp->vmt_length = p - (char *) vp; +} + + +/* + * Map from conventional mount arguments + * to AIX 3-style arguments. + */ +int +mount_aix3(char *fsname, char *dir, int flags, int type, void *data, char *mnt_opts) +{ + char buf[4096]; + int size, ret; + int real_size = sizeof(nfs_args_t); /* size passed to aix3_mkvp() */ + char *real_args = data; /* args passed to aix3_mkvp() */ + char *host, *rfs, *idx; + int aix_type = type; +#ifdef HAVE_FS_NFS3 + struct nfs_args v2args; + nfs_args_t *v3args = (nfs_args_t *) data; +#ifdef MOUNT_TYPE_NFS3_BIS + struct aix4_nfs_args_bis v3args_bis; +#endif /* MOUNT_TYPE_NFS3_BIS */ +#endif /* HAVE_FS_NFS3 */ + +#ifdef DEBUG + dlog("mount_aix3: fsname %s, dir %s, type %d", fsname, dir, type); +#endif /* DEBUG */ + +#ifdef MOUNT_TYPE_NFS3_BIS + retry_ibm_buggy_service_pack: +#endif /* MOUNT_TYPE_NFS3_BIS */ + switch (aix_type) { + + case MOUNT_TYPE_NFS: + +#ifdef HAVE_FS_NFS3 + /* + * This is tricky. If we have v3 support, but this nfs mount is v2, + * then I must copy the arguments from the v3 nfs_args to the v2 one. + */ + memmove((voidp) &v2args.addr, (voidp) &v3args->addr, sizeof(struct sockaddr_in)); + v2args.hostname = v3args->hostname; + v2args.netname = v3args->netname; + memmove((voidp) v2args.fh, v3args->fh, FHSIZE); + v2args.flags = v3args->flags; + v2args.wsize = v3args->wsize; + v2args.rsize = v3args->rsize; + v2args.timeo = v3args->timeo; + v2args.retrans = v3args->retrans; + v2args.acregmin = v3args->acregmin; + v2args.acregmax = v3args->acregmax; + v2args.acdirmin = v3args->acdirmin; + v2args.acdirmax = v3args->acdirmax; + v2args.pathconf = v3args->pathconf; + + /* now set real_* stuff */ + real_size = sizeof(v2args); + real_args = (char *) &v2args; + + case MOUNT_TYPE_NFS3: +#ifdef MOUNT_TYPE_NFS3_BIS + case MOUNT_TYPE_NFS3_BIS: + /* just fall through */ + if (aix_type == MOUNT_TYPE_NFS3_BIS) { + dlog("mount_aix3: creating alternate nfs3_args structure"); + memmove((voidp) &v3args_bis.addr, (voidp) &v3args->addr, sizeof(struct sockaddr_in)); + v3args_bis.syncaddr = v3args->syncaddr; + v3args_bis.proto = v3args->proto; + v3args_bis.hostname = v3args->hostname; + v3args_bis.netname = v3args->netname; + v3args_bis.fh = v3args->fh; + v3args_bis.flags = v3args->flags; + v3args_bis.wsize = v3args->wsize; + v3args_bis.rsize = v3args->rsize; + v3args_bis.timeo = v3args->timeo; + v3args_bis.retrans = v3args->retrans; + v3args_bis.acregmin = v3args->acregmin; + v3args_bis.acregmax = v3args->acregmax; + v3args_bis.acdirmin = v3args->acdirmin; + v3args_bis.acdirmax = v3args->acdirmax; + v3args_bis.pathconf = v3args->pathconf; + v3args_bis.biods = v3args->biods; + v3args_bis.numclust = v3args->numclust; + /* now set real_* stuff */ + real_size = sizeof(v3args_bis); + real_args = (char *) &v3args_bis; + } +#endif /* MOUNT_TYPE_NFS3_BIS */ +#endif /* HAVE_FS_NFS3 */ + + idx = strchr(fsname, ':'); + if (idx) { + *idx = '\0'; + rfs = strdup(idx + 1); + host = strdup(fsname); + *idx = ':'; + } else { + rfs = strdup(fsname); + host = strdup(am_get_hostname()); + } + + size = aix3_mkvp(buf, type, flags, rfs, dir, host, + real_args, real_size, mnt_opts); + XFREE(rfs); + XFREE(host); + break; + + case MOUNT_TYPE_UFS: + /* Need to open block device and extract log device info from sblk. */ + return EINVAL; + + default: + return EINVAL; + } + + /* + * XXX: Warning, if vmount() hangs your amd in AIX 5.1, it + * is because of a kernel bug in the NFS code. Get a patch from IBM + * or upgrade to 5.2. + */ + ret = vmount((struct vmount *)buf, size); + if (ret < 0) { + plog(XLOG_ERROR, "mount_aix3: vmount failed with errno %d", errno); + perror ("vmount"); +#ifdef MOUNT_TYPE_NFS3_BIS + if (aix_type == MOUNT_TYPE_NFS3 && errno == EINVAL) { + aix_type = MOUNT_TYPE_NFS3_BIS; +#ifdef DEBUG + dlog("mount_aix3: retrying with alternate nfs3_args structure"); +#endif /* DEBUG */ + goto retry_ibm_buggy_service_pack; + } +#endif /* MOUNT_TYPE_NFS3_BIS */ + } + return ret; +} diff --git a/conf/nfs_prot/nfs_prot_aix4_3.h b/conf/nfs_prot/nfs_prot_aix4_3.h index 9369ed6..7053b55 100644 --- a/conf/nfs_prot/nfs_prot_aix4_3.h +++ b/conf/nfs_prot/nfs_prot_aix4_3.h @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * - * $Id: nfs_prot_aix4_3.h,v 1.14 2005/06/23 20:02:40 ezk Exp $ + * $Id: nfs_prot_aix4_3.h,v 1.15 2005/07/06 22:34:26 ezk Exp $ * */ @@ -277,12 +277,11 @@ struct aix4_nfs_args { #define MOUNT_TYPE_NFS3_BIS 0x12344321 struct aix4_nfs_args_bis { struct sockaddr_in addr; /* server address and port */ - caddr_t u0; /* ??? UNKNOWN ??? */ - unsigned long proto; /* IPPROTO_TCP/IPPROTO_UDP */ + struct sockaddr_in *syncaddr; /* secure NFS time sync addr */ + int proto; /* IPPROTO_TCP/IPPROTO_UDP ??? */ char *hostname; /* pointer to hostname? */ char *netname; /* pointer to netname? */ caddr_t fh; /* pointer to NFS v3 fh? */ - unsigned long junk; /* IBM sux, IBM sux, IBM sux... */ unsigned long flags; /* flags */ unsigned long wsize; /* wsize */ unsigned long rsize; /* rsize */ @@ -293,7 +292,9 @@ struct aix4_nfs_args_bis { unsigned long acdirmin; /* acdirmin */ unsigned long acdirmax; /* acdirmax */ unsigned long u14; /* ??? UNKNOWN ??? */ - struct pathcnf *pathconf; /* pathconf */ + struct ppathcnf *pathconf; /* static pathconf kludge */ + int biods; /* biods per mount */ + int numclust; /* numclust per mount */ }; #endif /* MNT_NFS3 */ diff --git a/m4/macros/check_mount_style.m4 b/m4/macros/check_mount_style.m4 index 9266b97..e34f943 100644 --- a/m4/macros/check_mount_style.m4 +++ b/m4/macros/check_mount_style.m4 @@ -15,6 +15,8 @@ case "${host_os_name}" in ac_cv_style_mount=svr4 ;; bsdi* ) ac_cv_style_mount=bsdi3 ;; + aix3* | aix4* ) + ac_cv_style_mount=aix3 ;; aix* ) ac_cv_style_mount=aix ;; irix5* ) -- 2.43.0