1*47509Spendry /* 2*47509Spendry * $Id: mount_aix.c,v 5.2.1.1 90/10/21 22:30:41 jsp Exp $ 3*47509Spendry * 4*47509Spendry * Copyright (c) 1990 Jan-Simon Pendry 5*47509Spendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine 6*47509Spendry * Copyright (c) 1990 The Regents of the University of California. 7*47509Spendry * All rights reserved. 8*47509Spendry * 9*47509Spendry * This code is derived from software contributed to Berkeley by 10*47509Spendry * Jan-Simon Pendry at Imperial College, London. 11*47509Spendry * 12*47509Spendry * Redistribution and use in source and binary forms are permitted provided 13*47509Spendry * that: (1) source distributions retain this entire copyright notice and 14*47509Spendry * comment, and (2) distributions including binaries display the following 15*47509Spendry * acknowledgement: ``This product includes software developed by the 16*47509Spendry * University of California, Berkeley and its contributors'' in the 17*47509Spendry * documentation or other materials provided with the distribution and in 18*47509Spendry * all advertising materials mentioning features or use of this software. 19*47509Spendry * Neither the name of the University nor the names of its contributors may 20*47509Spendry * be used to endorse or promote products derived from this software without 21*47509Spendry * specific prior written permission. 22*47509Spendry * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 23*47509Spendry * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 24*47509Spendry * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 25*47509Spendry * 26*47509Spendry * @(#)mount_aix.c 5.1 (Berkeley) 03/17/91 27*47509Spendry */ 28*47509Spendry 29*47509Spendry 30*47509Spendry /* 31*47509Spendry * AIX 3 Mount helper 32*47509Spendry */ 33*47509Spendry 34*47509Spendry #include "misc-aix3.h" 35*47509Spendry 36*47509Spendry static int aix3_mkvp(p, gfstype, flags, object, stub, host, info, info_size, args) 37*47509Spendry char *p; 38*47509Spendry int gfstype; 39*47509Spendry int flags; 40*47509Spendry char *object; 41*47509Spendry char *stub; 42*47509Spendry char *host; 43*47509Spendry char *info; 44*47509Spendry int info_size; 45*47509Spendry char *args; 46*47509Spendry { 47*47509Spendry struct vmount *vp = (struct vmount *) p; 48*47509Spendry bzero((voidp) vp, sizeof(*vp)); 49*47509Spendry /* 50*47509Spendry * Fill in standard fields 51*47509Spendry */ 52*47509Spendry vp->vmt_revision = VMT_REVISION; 53*47509Spendry vp->vmt_flags = flags; 54*47509Spendry vp->vmt_gfstype = gfstype; 55*47509Spendry 56*47509Spendry #define VMT_ROUNDUP(len) (4 * ((len + 3) / 4)) 57*47509Spendry #define VMT_ASSIGN(vp, idx, data, size) \ 58*47509Spendry vp->vmt_data[idx].vmt_off = p - (char *) vp; \ 59*47509Spendry vp->vmt_data[idx].vmt_size = size; \ 60*47509Spendry bcopy(data, p, size); \ 61*47509Spendry p += VMT_ROUNDUP(size); 62*47509Spendry 63*47509Spendry /* 64*47509Spendry * Fill in all variable length data 65*47509Spendry */ 66*47509Spendry p += sizeof(*vp); 67*47509Spendry 68*47509Spendry VMT_ASSIGN(vp, VMT_OBJECT, object, strlen(object) + 1); 69*47509Spendry VMT_ASSIGN(vp, VMT_STUB, stub, strlen(stub) + 1); 70*47509Spendry VMT_ASSIGN(vp, VMT_HOST, host, strlen(host) + 1); 71*47509Spendry VMT_ASSIGN(vp, VMT_HOSTNAME, host, strlen(host) + 1); 72*47509Spendry VMT_ASSIGN(vp, VMT_INFO, info, info_size); 73*47509Spendry VMT_ASSIGN(vp, VMT_ARGS, args, strlen(args) + 1); 74*47509Spendry 75*47509Spendry #undef VMT_ASSIGN 76*47509Spendry #undef VMT_ROUNDUP 77*47509Spendry 78*47509Spendry /* 79*47509Spendry * Return length 80*47509Spendry */ 81*47509Spendry return vp->vmt_length = p - (char *) vp; 82*47509Spendry } 83*47509Spendry 84*47509Spendry /* 85*47509Spendry * Map from conventional mount arguments 86*47509Spendry * to AIX 3-style arguments. 87*47509Spendry */ 88*47509Spendry aix3_mount(fsname, dir, flags, type, data, args) 89*47509Spendry char *fsname; 90*47509Spendry char *dir; 91*47509Spendry int flags; 92*47509Spendry int type; 93*47509Spendry void *data; 94*47509Spendry char *args; 95*47509Spendry { 96*47509Spendry char buf[4096]; 97*47509Spendry int size; 98*47509Spendry 99*47509Spendry #ifdef DEBUG 100*47509Spendry dlog("aix3_mount: fsname %s, dir %s, type %d", fsname, dir, type); 101*47509Spendry #endif /* DEBUG */ 102*47509Spendry 103*47509Spendry /* aix3_mkvp(p, gfstype, flags, object, stub, host, info, info_size, args) */ 104*47509Spendry 105*47509Spendry switch (type) { 106*47509Spendry 107*47509Spendry case MOUNT_TYPE_NFS: { 108*47509Spendry char *host = strdup(fsname); 109*47509Spendry char *rfs = strchr(host, ':'); 110*47509Spendry int free_rfs = 0; 111*47509Spendry if (rfs) { 112*47509Spendry *rfs++ = '\0'; 113*47509Spendry } else { 114*47509Spendry rfs = host; 115*47509Spendry free_rfs = 1; 116*47509Spendry host = strdup(hostname); 117*47509Spendry } 118*47509Spendry 119*47509Spendry size = aix3_mkvp(buf, type, flags, rfs, dir, host, data, sizeof(struct nfs_args), args); 120*47509Spendry if (free_rfs) 121*47509Spendry free((voidp) rfs); 122*47509Spendry free(host); 123*47509Spendry 124*47509Spendry } break; 125*47509Spendry 126*47509Spendry case MOUNT_TYPE_UFS: 127*47509Spendry /* Need to open block device and extract log device info from sblk. */ 128*47509Spendry return EINVAL; 129*47509Spendry 130*47509Spendry default: 131*47509Spendry return EINVAL; 132*47509Spendry } 133*47509Spendry #ifdef DEBUG 134*47509Spendry /*dlog("aix3_mkvp: flags %#x, size %d, args %s", flags, size, args);*/ 135*47509Spendry #endif /* DEBUG */ 136*47509Spendry 137*47509Spendry return vmount(buf, size); 138*47509Spendry } 139