4 * Copyright (c) 1997-2009 Erez Zadok
5 * Copyright (c) 1990 Jan-Simon Pendry
6 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
7 * Copyright (c) 1990 The Regents of the University of California.
10 * This code is derived from software contributed to Berkeley by
11 * Jan-Simon Pendry at Imperial College, London.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgment:
23 * This product includes software developed by the University of
24 * California, Berkeley and its contributors.
25 * 4. Neither the name of the University nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 * File: am-utils/conf/mount/mount_aix.c
47 * AIX 5.x Mount helper
52 #endif /* HAVE_CONFIG_H */
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 memmove(p, data, size); \
61 p += VMT_ROUNDUP(size);
63 /* missing external definitions from AIX's headers */
64 extern int vmount(struct vmount
*vmount
, int size
);
68 aix5_mkvp(char *p
, int gfstype
, int flags
, char *object
, char *stub
, char *host
, char *info
, int info_size
, char *args
)
70 struct vmount
*vp
= (struct vmount
*) p
;
72 memset((voidp
) vp
, 0, sizeof(*vp
));
74 * Fill in standard fields
76 vp
->vmt_revision
= VMT_REVISION
;
77 vp
->vmt_flags
= flags
;
78 vp
->vmt_gfstype
= gfstype
;
81 * Fill in all variable length data
85 VMT_ASSIGN(vp
, VMT_OBJECT
, object
, strlen(object
) + 1);
86 VMT_ASSIGN(vp
, VMT_STUB
, stub
, strlen(stub
) + 1);
87 VMT_ASSIGN(vp
, VMT_HOST
, host
, strlen(host
) + 1);
88 VMT_ASSIGN(vp
, VMT_HOSTNAME
, host
, strlen(host
) + 1);
89 VMT_ASSIGN(vp
, VMT_INFO
, info
, info_size
);
90 VMT_ASSIGN(vp
, VMT_ARGS
, args
, strlen(args
) + 1);
95 return vp
->vmt_length
= p
- (char *) vp
;
100 * Map from conventional mount arguments to AIX 3,x style arguments.
101 * But we avoid all the messy BIS stuff for AIX 5.x
104 mount_aix3(char *fsname
, char *dir
, int flags
, int type
, void *data
, char *mnt_opts
)
108 int real_size
= sizeof(nfs_args_t
); /* size passed to aix5_mkvp() */
109 char *real_args
= data
; /* args passed to aix5_mkvp() */
110 char *host
, *rfs
, *idx
;
113 struct nfs_args v2args
;
114 nfs_args_t
*v3args
= (nfs_args_t
*) data
;
115 #endif /* HAVE_FS_NFS3 */
118 dlog("mount_aix3: fsname %s, dir %s, type %d", fsname
, dir
, type
);
127 * This is tricky. If we have v3 support, but this nfs mount is v2,
128 * then I must copy the arguments from the v3 nfs_args to the v2 one.
130 memmove((voidp
) &v2args
.addr
, (voidp
) &v3args
->addr
, sizeof(struct sockaddr_in
));
131 v2args
.hostname
= v3args
->hostname
;
132 v2args
.netname
= v3args
->netname
;
133 memmove((voidp
) v2args
.fh
.x
, v3args
->fh
, FHSIZE
);
134 v2args
.flags
= v3args
->flags
;
135 v2args
.wsize
= v3args
->wsize
;
136 v2args
.rsize
= v3args
->rsize
;
137 v2args
.timeo
= v3args
->timeo
;
138 v2args
.retrans
= v3args
->retrans
;
139 v2args
.acregmin
= v3args
->acregmin
;
140 v2args
.acregmax
= v3args
->acregmax
;
141 v2args
.acdirmin
= v3args
->acdirmin
;
142 v2args
.acdirmax
= v3args
->acdirmax
;
143 v2args
.pathconf
= v3args
->pathconf
;
145 /* now set real_* stuff */
146 real_size
= sizeof(v2args
);
147 real_args
= (char *) &v2args
;
149 case MOUNT_TYPE_NFS3
:
150 #endif /* HAVE_FS_NFS3 */
152 idx
= strchr(fsname
, ':');
155 rfs
= strdup(idx
+ 1);
156 host
= strdup(fsname
);
159 rfs
= strdup(fsname
);
160 host
= strdup(am_get_hostname());
163 size
= aix5_mkvp(buf
, type
, flags
, rfs
, dir
, host
,
164 real_args
, real_size
, mnt_opts
);
170 /* Need to open block device and extract log device info from sblk. */
178 * XXX: Warning, if vmount() hangs your amd in AIX 5.1, it
179 * is because of a kernel bug in the NFS code. Get a patch from IBM
182 ret
= vmount((struct vmount
*)buf
, size
);
184 plog(XLOG_ERROR
, "mount_aix3: vmount failed with errno %d", errno
);