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