aix_vmount(const char *cacheMountDir) { struct vmount *vmountp; int size, error; size = sizeof(struct vmount) + ROUNDUP(strlen(cacheMountDir) + 1) + 5 * 4; /* Malloc and zero the vmount structure */ if ((vmountp = calloc(1, size)) == NULL) { printf("Can't allocate space for the vmount structure (AIX)\n"); exit(1); } /* transfer info into the vmount structure */ vmountp->vmt_revision = VMT_REVISION; vmountp->vmt_length = size; vmountp->vmt_fsid.fsid_dev = 0; vmountp->vmt_fsid.fsid_type = AFS_MOUNT_AFS; vmountp->vmt_vfsnumber = 0; vmountp->vmt_time = 0; /* We'll put the time soon! */ vmountp->vmt_flags = VFS_DEVMOUNT; /* read/write permission */ vmountp->vmt_gfstype = AFS_MOUNT_AFS; vmountdata(vmountp, "AFS", cacheMountDir, "", "", "", "rw"); /* Do the actual mount system call */ error = vmount(vmountp, size); free(vmountp); return (error); }
/* * 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 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; #endif /* HAVE_FS_NFS3 */ #ifdef DEBUG dlog("mount_aix3: fsname %s, dir %s, type %d", fsname, dir, type); #endif /* DEBUG */ 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.x, 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: #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 = aix5_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"); } return ret; }