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