1 /* 2 * $Id: mount_aix.c,v 5.2.1.1 90/10/21 22:30:41 jsp Exp $ 3 * 4 * Copyright (c) 1990 Jan-Simon Pendry 5 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine 6 * Copyright (c) 1990 The Regents of the University of California. 7 * All rights reserved. 8 * 9 * This code is derived from software contributed to Berkeley by 10 * Jan-Simon Pendry at Imperial College, London. 11 * 12 * %sccs.include.redist.c% 13 * 14 * @(#)mount_aix.c 5.2 (Berkeley) 03/17/91 15 */ 16 17 18 /* 19 * AIX 3 Mount helper 20 */ 21 22 #include "misc-aix3.h" 23 24 static int aix3_mkvp(p, gfstype, flags, object, stub, host, info, info_size, args) 25 char *p; 26 int gfstype; 27 int flags; 28 char *object; 29 char *stub; 30 char *host; 31 char *info; 32 int info_size; 33 char *args; 34 { 35 struct vmount *vp = (struct vmount *) p; 36 bzero((voidp) vp, sizeof(*vp)); 37 /* 38 * Fill in standard fields 39 */ 40 vp->vmt_revision = VMT_REVISION; 41 vp->vmt_flags = flags; 42 vp->vmt_gfstype = gfstype; 43 44 #define VMT_ROUNDUP(len) (4 * ((len + 3) / 4)) 45 #define VMT_ASSIGN(vp, idx, data, size) \ 46 vp->vmt_data[idx].vmt_off = p - (char *) vp; \ 47 vp->vmt_data[idx].vmt_size = size; \ 48 bcopy(data, p, size); \ 49 p += VMT_ROUNDUP(size); 50 51 /* 52 * Fill in all variable length data 53 */ 54 p += sizeof(*vp); 55 56 VMT_ASSIGN(vp, VMT_OBJECT, object, strlen(object) + 1); 57 VMT_ASSIGN(vp, VMT_STUB, stub, strlen(stub) + 1); 58 VMT_ASSIGN(vp, VMT_HOST, host, strlen(host) + 1); 59 VMT_ASSIGN(vp, VMT_HOSTNAME, host, strlen(host) + 1); 60 VMT_ASSIGN(vp, VMT_INFO, info, info_size); 61 VMT_ASSIGN(vp, VMT_ARGS, args, strlen(args) + 1); 62 63 #undef VMT_ASSIGN 64 #undef VMT_ROUNDUP 65 66 /* 67 * Return length 68 */ 69 return vp->vmt_length = p - (char *) vp; 70 } 71 72 /* 73 * Map from conventional mount arguments 74 * to AIX 3-style arguments. 75 */ 76 aix3_mount(fsname, dir, flags, type, data, args) 77 char *fsname; 78 char *dir; 79 int flags; 80 int type; 81 void *data; 82 char *args; 83 { 84 char buf[4096]; 85 int size; 86 87 #ifdef DEBUG 88 dlog("aix3_mount: fsname %s, dir %s, type %d", fsname, dir, type); 89 #endif /* DEBUG */ 90 91 /* aix3_mkvp(p, gfstype, flags, object, stub, host, info, info_size, args) */ 92 93 switch (type) { 94 95 case MOUNT_TYPE_NFS: { 96 char *host = strdup(fsname); 97 char *rfs = strchr(host, ':'); 98 int free_rfs = 0; 99 if (rfs) { 100 *rfs++ = '\0'; 101 } else { 102 rfs = host; 103 free_rfs = 1; 104 host = strdup(hostname); 105 } 106 107 size = aix3_mkvp(buf, type, flags, rfs, dir, host, data, sizeof(struct nfs_args), args); 108 if (free_rfs) 109 free((voidp) rfs); 110 free(host); 111 112 } break; 113 114 case MOUNT_TYPE_UFS: 115 /* Need to open block device and extract log device info from sblk. */ 116 return EINVAL; 117 118 default: 119 return EINVAL; 120 } 121 #ifdef DEBUG 122 /*dlog("aix3_mkvp: flags %#x, size %d, args %s", flags, size, args);*/ 123 #endif /* DEBUG */ 124 125 return vmount(buf, size); 126 } 127