from amd5.3 alpha11
[unix-history] / usr / src / usr.sbin / amd / config / mount_aix.c
CommitLineData
c245cb54
JSP
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 *
2f619045 12 * %sccs.include.redist.c%
c245cb54 13 *
2f619045 14 * @(#)mount_aix.c 5.2 (Berkeley) %G%
c245cb54
JSP
15 */
16
17
18/*
19 * AIX 3 Mount helper
20 */
21
22#include "misc-aix3.h"
23
24static int aix3_mkvp(p, gfstype, flags, object, stub, host, info, info_size, args)
25char *p;
26int gfstype;
27int flags;
28char *object;
29char *stub;
30char *host;
31char *info;
32int info_size;
33char *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 */
76aix3_mount(fsname, dir, flags, type, data, args)
77char *fsname;
78char *dir;
79int flags;
80int type;
81void *data;
82char *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}