No empty .Rs/.Re
[netbsd-mini2440.git] / external / bsd / am-utils / dist / libamu / mount_fs.c
blob0f9c9bc5ca06018d87aa0b202ec5e59e55665a29
1 /* $NetBSD$ */
3 /*
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.
8 * All rights reserved.
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
15 * are met:
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
39 * SUCH DAMAGE.
42 * File: am-utils/libamu/mount_fs.c
46 #ifdef HAVE_CONFIG_H
47 # include <config.h>
48 #endif /* HAVE_CONFIG_H */
49 #include <am_defs.h>
50 #include <amu.h>
53 /* ensure that mount table options are delimited by a comma */
54 #define append_opts(old, l, new) { \
55 if (*(old) != '\0') \
56 xstrlcat(old, ",", l); \
57 xstrlcat(old, new, l); }
60 * Standard mount flags
62 struct opt_tab mnt_flags[] =
64 #if defined(MNT2_GEN_OPT_RDONLY) && defined(MNTTAB_OPT_RO)
65 {MNTTAB_OPT_RO, MNT2_GEN_OPT_RDONLY},
66 #endif /* defined(MNT2_GEN_OPT_RDONLY) && defined(MNTTAB_OPT_RO) */
68 #if defined(MNT2_GEN_OPT_NOCACHE) && defined(MNTTAB_OPT_NOCACHE)
69 {MNTTAB_OPT_NOCACHE, MNT2_GEN_OPT_NOCACHE},
70 #endif /* defined(MNT2_GEN_OPT_NOCACHE) && defined(MNTTAB_OPT_NOCACHE) */
72 /* the "grpid" mount option can be offered as generic of NFS */
73 #ifdef MNTTAB_OPT_GRPID
74 # ifdef MNT2_GEN_OPT_GRPID
75 {MNTTAB_OPT_GRPID, MNT2_GEN_OPT_GRPID},
76 # endif /* MNT2_GEN_OPT_GRPID */
77 # ifdef MNT2_NFS_OPT_GRPID
78 {MNTTAB_OPT_GRPID, MNT2_NFS_OPT_GRPID},
79 # endif /* MNT2_NFS_OPT_GRPID */
80 #endif /* MNTTAB_OPT_GRPID */
82 #if defined(MNT2_GEN_OPT_MULTI) && defined(MNTTAB_OPT_MULTI)
83 {MNTTAB_OPT_MULTI, MNT2_GEN_OPT_MULTI},
84 #endif /* defined(MNT2_GEN_OPT_MULTI) && defined(MNTTAB_OPT_MULTI) */
86 #if defined(MNT2_GEN_OPT_NODEV) && defined(MNTTAB_OPT_NODEV)
87 {MNTTAB_OPT_NODEV, MNT2_GEN_OPT_NODEV},
88 #endif /* defined(MNT2_GEN_OPT_NODEV) && defined(MNTTAB_OPT_NODEV) */
90 #if defined(MNT2_GEN_OPT_NOEXEC) && defined(MNTTAB_OPT_NOEXEC)
91 {MNTTAB_OPT_NOEXEC, MNT2_GEN_OPT_NOEXEC},
92 #endif /* defined(MNT2_GEN_OPT_NOEXEC) && defined(MNTTAB_OPT_NOEXEC) */
94 #if defined(MNT2_GEN_OPT_NOSUB) && defined(MNTTAB_OPT_NOSUB)
95 {MNTTAB_OPT_NOSUB, MNT2_GEN_OPT_NOSUB},
96 #endif /* defined(MNT2_GEN_OPT_NOSUB) && defined(MNTTAB_OPT_NOSUB) */
98 #if defined(MNT2_GEN_OPT_NOSUID) && defined(MNTTAB_OPT_NOSUID)
99 {MNTTAB_OPT_NOSUID, MNT2_GEN_OPT_NOSUID},
100 #endif /* defined(MNT2_GEN_OPT_NOSUID) && defined(MNTTAB_OPT_NOSUID) */
102 #if defined(MNT2_GEN_OPT_SYNC) && defined(MNTTAB_OPT_SYNC)
103 {MNTTAB_OPT_SYNC, MNT2_GEN_OPT_SYNC},
104 #endif /* defined(MNT2_GEN_OPT_SYNC) && defined(MNTTAB_OPT_SYNC) */
106 #if defined(MNT2_GEN_OPT_OVERLAY) && defined(MNTTAB_OPT_OVERLAY)
107 {MNTTAB_OPT_OVERLAY, MNT2_GEN_OPT_OVERLAY},
108 #endif /* defined(MNT2_GEN_OPT_OVERLAY) && defined(MNTTAB_OPT_OVERLAY) */
110 #if defined(MNT2_GEN_OPT_LOG) && defined(MNTTAB_OPT_LOG)
111 {MNTTAB_OPT_LOG, MNT2_GEN_OPT_LOG},
112 #endif /* defined(MNT2_GEN_OPT_LOG) && defined(MNTTAB_OPT_LOG) */
114 #if defined(MNT2_GEN_OPT_NOATIME) && defined(MNTTAB_OPT_NOATIME)
115 {MNTTAB_OPT_NOATIME, MNT2_GEN_OPT_NOATIME},
116 #endif /* defined(MNT2_GEN_OPT_NOATIME) && defined(MNTTAB_OPT_NOATIME) */
118 #if defined(MNT2_GEN_OPT_NODEVMTIME) && defined(MNTTAB_OPT_NODEVMTIME)
119 {MNTTAB_OPT_NODEVMTIME, MNT2_GEN_OPT_NODEVMTIME},
120 #endif /* defined(MNT2_GEN_OPT_NODEVMTIME) && defined(MNTTAB_OPT_NODEVMTIME) */
122 #if defined(MNT2_GEN_OPT_SOFTDEP) && defined(MNTTAB_OPT_SOFTDEP)
123 {MNTTAB_OPT_SOFTDEP, MNT2_GEN_OPT_SOFTDEP},
124 #endif /* defined(MNT2_GEN_OPT_SOFTDEP) && defined(MNTTAB_OPT_SOFTDEP) */
126 #if defined(MNT2_GEN_OPT_SYMPERM) && defined(MNTTAB_OPT_SYMPERM)
127 {MNTTAB_OPT_SYMPERM, MNT2_GEN_OPT_SYMPERM},
128 #endif /* defined(MNT2_GEN_OPT_SYMPERM) && defined(MNTTAB_OPT_SYMPERM) */
130 #if defined(MNT2_GEN_OPT_UNION) && defined(MNTTAB_OPT_UNION)
131 {MNTTAB_OPT_UNION, MNT2_GEN_OPT_UNION},
132 #endif /* defined(MNT2_GEN_OPT_UNION) && defined(MNTTAB_OPT_UNION) */
135 * Do not define MNT2_NFS_OPT_* entries here! This is for generic
136 * mount(2) options only, not for NFS mount options. If you need to put
137 * something here, it's probably not the right place: see
138 * include/am_compat.h.
141 {0, 0}
145 /* compute generic mount flags */
147 compute_mount_flags(mntent_t *mntp)
149 struct opt_tab *opt;
150 int flags = 0;
152 #ifdef MNT2_GEN_OPT_NEWTYPE
153 flags |= MNT2_GEN_OPT_NEWTYPE;
154 #endif /* MNT2_GEN_OPT_NEWTYPE */
155 #ifdef MNT2_GEN_OPT_AUTOMOUNTED
156 flags |= MNT2_GEN_OPT_AUTOMOUNTED;
157 #endif /* not MNT2_GEN_OPT_AUTOMOUNTED */
160 * Crack basic mount options
162 for (opt = mnt_flags; opt->opt; opt++) {
163 flags |= amu_hasmntopt(mntp, opt->opt) ? opt->flag : 0;
166 return flags;
170 /* compute generic mount flags for automounter mounts */
172 compute_automounter_mount_flags(mntent_t *mntp)
174 int flags = 0;
176 #ifdef MNT2_GEN_OPT_IGNORE
177 flags |= MNT2_GEN_OPT_IGNORE;
178 #endif /* not MNT2_GEN_OPT_IGNORE */
179 #ifdef MNT2_GEN_OPT_AUTOMNTFS
180 flags |= MNT2_GEN_OPT_AUTOMNTFS;
181 #endif /* not MNT2_GEN_OPT_AUTOMNTFS */
183 return flags;
188 mount_fs(mntent_t *mnt, int flags, caddr_t mnt_data, int retry, MTYPE_TYPE type, u_long nfs_version, const char *nfs_proto, const char *mnttabname, int on_autofs)
190 int error = 0;
191 #ifdef MOUNT_TABLE_ON_FILE
192 char *zopts = NULL, *xopts = NULL;
193 size_t l;
194 #endif /* MOUNT_TABLE_ON_FILE */
195 char *mnt_dir = NULL;
197 #ifdef NEED_AUTOFS_SPACE_HACK
198 char *old_mnt_dir = NULL;
199 /* perform space hack */
200 if (on_autofs) {
201 old_mnt_dir = mnt->mnt_dir;
202 mnt->mnt_dir = mnt_dir = autofs_strdup_space_hack(old_mnt_dir);
203 } else
204 #endif /* NEED_AUTOFS_SPACE_HACK */
205 mnt_dir = strdup(mnt->mnt_dir);
207 dlog("'%s' fstype " MTYPE_PRINTF_TYPE " (%s) flags %#x (%s)",
208 mnt_dir, type, mnt->mnt_type, flags, mnt->mnt_opts);
210 again:
211 error = MOUNT_TRAP(type, mnt, flags, mnt_data);
213 if (error < 0) {
214 plog(XLOG_ERROR, "'%s': mount: %m", mnt_dir);
216 * The following code handles conditions which shouldn't
217 * occur. They are possible either because amd screws up
218 * in preparing for the mount, or because some human
219 * messed with the mount point. Both have been known to
220 * happen. -- stolcke 2/22/95
222 if (errno == EBUSY) {
224 * Also, sometimes unmount isn't called, e.g., because
225 * our mountlist is garbled. This leaves old mount
226 * points around which need to be removed before we
227 * can mount something new in their place.
229 errno = umount_fs(mnt_dir, mnttabname, on_autofs);
230 if (errno != 0)
231 plog(XLOG_ERROR, "'%s': umount: %m", mnt_dir);
232 else {
233 plog(XLOG_WARNING, "extra umount required for '%s'", mnt_dir);
234 error = MOUNT_TRAP(type, mnt, flags, mnt_data);
239 if (error < 0 && --retry > 0) {
240 sleep(1);
241 goto again;
244 #ifdef NEED_AUTOFS_SPACE_HACK
245 /* Undo space hack */
246 if (on_autofs)
247 mnt->mnt_dir = old_mnt_dir;
248 #endif /* NEED_AUTOFS_SPACE_HACK */
250 if (error < 0) {
251 error = errno;
252 goto out;
255 #ifdef MOUNT_TABLE_ON_FILE
257 * Allocate memory for options:
258 * dev=..., vers={2,3}, proto={tcp,udp}
260 l = strlen(mnt->mnt_opts) + 48;
261 zopts = (char *) xmalloc(l);
263 /* copy standard options */
264 xopts = mnt->mnt_opts;
266 xstrlcpy(zopts, xopts, l);
268 # ifdef MNTTAB_OPT_DEV
270 /* add the extra dev= field to the mount table */
271 struct stat stb;
272 if (lstat(mnt_dir, &stb) == 0) {
273 char optsbuf[48];
274 if (sizeof(stb.st_dev) == 2) /* e.g. SunOS 4.1 */
275 xsnprintf(optsbuf, sizeof(optsbuf), "%s=%04lx",
276 MNTTAB_OPT_DEV, (u_long) stb.st_dev & 0xffff);
277 else /* e.g. System Vr4 */
278 xsnprintf(optsbuf, sizeof(optsbuf), "%s=%08lx",
279 MNTTAB_OPT_DEV, (u_long) stb.st_dev);
280 append_opts(zopts, l, optsbuf);
283 # endif /* MNTTAB_OPT_DEV */
285 # if defined(HAVE_FS_NFS3) && defined(MNTTAB_OPT_VERS)
287 * add the extra vers={2,3} field to the mount table,
288 * unless already specified by user
290 if (nfs_version == NFS_VERSION3 &&
291 hasmntval(mnt, MNTTAB_OPT_VERS) != NFS_VERSION3) {
292 char optsbuf[48];
293 xsnprintf(optsbuf, sizeof(optsbuf),
294 "%s=%d", MNTTAB_OPT_VERS, NFS_VERSION3);
295 append_opts(zopts, l, optsbuf);
297 # endif /* defined(HAVE_FS_NFS3) && defined(MNTTAB_OPT_VERS) */
299 # ifdef MNTTAB_OPT_PROTO
301 * add the extra proto={tcp,udp} field to the mount table,
302 * unless already specified by user.
304 if (nfs_proto && !amu_hasmntopt(mnt, MNTTAB_OPT_PROTO)) {
305 char optsbuf[48];
306 xsnprintf(optsbuf, sizeof(optsbuf), "%s=%s", MNTTAB_OPT_PROTO, nfs_proto);
307 append_opts(zopts, l, optsbuf);
309 # endif /* MNTTAB_OPT_PROTO */
311 /* finally, store the options into the mount table structure */
312 mnt->mnt_opts = zopts;
315 * Additional fields in mntent_t
316 * are fixed up here
318 # ifdef HAVE_MNTENT_T_MNT_CNODE
319 mnt->mnt_cnode = 0;
320 # endif /* HAVE_MNTENT_T_MNT_CNODE */
322 # ifdef HAVE_MNTENT_T_MNT_RO
323 mnt->mnt_ro = (amu_hasmntopt(mnt, MNTTAB_OPT_RO) != NULL);
324 # endif /* HAVE_MNTENT_T_MNT_RO */
326 # ifdef HAVE_MNTENT_T_MNT_TIME
327 # ifdef HAVE_MNTENT_T_MNT_TIME_STRING
328 { /* allocate enough space for a long */
329 size_t l = 13 * sizeof(char);
330 char *str = (char *) xmalloc(l);
331 xsnprintf(str, l, "%ld", time((time_t *) NULL));
332 mnt->mnt_time = str;
334 # else /* not HAVE_MNTENT_T_MNT_TIME_STRING */
335 mnt->mnt_time = time((time_t *) NULL);
336 # endif /* not HAVE_MNTENT_T_MNT_TIME_STRING */
337 # endif /* HAVE_MNTENT_T_MNT_TIME */
339 write_mntent(mnt, mnttabname);
341 # ifdef MNTTAB_OPT_DEV
342 if (xopts) {
343 XFREE(mnt->mnt_opts);
344 mnt->mnt_opts = xopts;
346 # endif /* MNTTAB_OPT_DEV */
347 #endif /* MOUNT_TABLE_ON_FILE */
349 out:
350 XFREE(mnt_dir);
351 return error;
356 * Compute all NFS attribute cache related flags separately. Note that this
357 * function now computes attribute-cache flags for both Amd's automount
358 * points (NFS) as well as any normal NFS mount that Amd performs. Edit
359 * with caution.
361 static void
362 compute_nfs_attrcache_flags(nfs_args_t *nap, mntent_t *mntp)
364 int acval = 0;
365 int err_acval = 1; /* 1 means we found no 'actimeo' value */
366 #if defined(HAVE_NFS_ARGS_T_ACREGMIN) || defined(HAVE_NFS_ARGS_T_ACREGMAX) || defined(HAVE_NFS_ARGS_T_ACDIRMIN) || defined(HAVE_NFS_ARGS_T_ACDIRMAX)
367 int err_acrdmm; /* for ac{reg,dir}{min,max} */
368 #endif /* HAVE_NFS_ARGS_T_AC{REG,DIR}{MIN,MAX} */
370 /************************************************************************/
371 /*** ATTRIBUTE CACHES ***/
372 /************************************************************************/
374 * acval is set to 0 at the top of the function. If actimeo mount option
375 * exists and defined in mntopts, then its acval is set to it.
376 * If the value is non-zero, then we set all attribute cache fields to it.
377 * If acval is zero, it means it was never defined in mntopts or the
378 * actimeo mount option does not exist, in which case we check for
379 * individual mount options per attribute cache.
380 * Regardless of the value of acval, mount flags are set based directly
381 * on the values of the attribute caches.
383 #ifdef MNTTAB_OPT_ACTIMEO
384 err_acval = hasmntvalerr(mntp, MNTTAB_OPT_ACTIMEO, &acval); /* attr cache timeout (sec) */
385 #endif /* MNTTAB_OPT_ACTIMEO */
387 /*** acregmin ***/
388 #ifdef HAVE_NFS_ARGS_T_ACREGMIN
389 err_acrdmm = 1; /* 1 means we found no acregmin value */
390 if (!err_acval) {
391 nap->acregmin = acval; /* min ac timeout for reg files (sec) */
392 } else {
393 # ifdef MNTTAB_OPT_ACREGMIN
394 err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACREGMIN, (int *) &nap->acregmin);
395 # else /* not MNTTAB_OPT_ACREGMIN */
396 nap->acregmin = 0;
397 # endif /* not MNTTAB_OPT_ACREGMIN */
399 /* set this flag iff we changed acregmin (possibly to zero) */
400 # ifdef MNT2_NFS_OPT_ACREGMIN
401 if (!err_acval || !err_acrdmm)
402 nap->flags |= MNT2_NFS_OPT_ACREGMIN;
403 # endif /* MNT2_NFS_OPT_ACREGMIN */
404 #endif /* HAVE_NFS_ARGS_T_ACREGMIN */
406 /*** acregmax ***/
407 #ifdef HAVE_NFS_ARGS_T_ACREGMAX
408 err_acrdmm = 1; /* 1 means we found no acregmax value */
409 if (!err_acval) {
410 nap->acregmax = acval; /* max ac timeout for reg files (sec) */
411 } else {
412 # ifdef MNTTAB_OPT_ACREGMAX
413 err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACREGMAX, (int *) &nap->acregmax);
414 # else /* not MNTTAB_OPT_ACREGMAX */
415 nap->acregmax = 0;
416 # endif /* not MNTTAB_OPT_ACREGMAX */
418 /* set this flag iff we changed acregmax (possibly to zero) */
419 # ifdef MNT2_NFS_OPT_ACREGMAX
420 if (!err_acval || !err_acrdmm)
421 nap->flags |= MNT2_NFS_OPT_ACREGMAX;
422 # endif /* MNT2_NFS_OPT_ACREGMAX */
423 #endif /* HAVE_NFS_ARGS_T_ACREGMAX */
425 /*** acdirmin ***/
426 #ifdef HAVE_NFS_ARGS_T_ACDIRMIN
427 err_acrdmm = 1; /* 1 means we found no acdirmin value */
428 if (!err_acval) {
429 nap->acdirmin = acval; /* min ac timeout for dirs (sec) */
430 } else {
431 # ifdef MNTTAB_OPT_ACDIRMIN
432 err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACDIRMIN, (int *) &nap->acdirmin);
433 # else /* not MNTTAB_OPT_ACDIRMIN */
434 nap->acdirmin = 0;
435 # endif /* not MNTTAB_OPT_ACDIRMIN */
437 /* set this flag iff we changed acdirmin (possibly to zero) */
438 # ifdef MNT2_NFS_OPT_ACDIRMIN
439 if (!err_acval || !err_acrdmm)
440 nap->flags |= MNT2_NFS_OPT_ACDIRMIN;
441 # endif /* MNT2_NFS_OPT_ACDIRMIN */
442 #endif /* HAVE_NFS_ARGS_T_ACDIRMIN */
444 /*** acdirmax ***/
445 #ifdef HAVE_NFS_ARGS_T_ACDIRMAX
446 err_acrdmm = 1; /* 1 means we found no acdirmax value */
447 if (!err_acval) {
448 nap->acdirmax = acval; /* max ac timeout for dirs (sec) */
449 } else {
450 # ifdef MNTTAB_OPT_ACDIRMAX
451 err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACDIRMAX, (int *) &nap->acdirmax);
452 # else /* not MNTTAB_OPT_ACDIRMAX */
453 nap->acdirmax = 0;
454 # endif /* not MNTTAB_OPT_ACDIRMAX */
456 /* set this flag iff we changed acdirmax (possibly to zero) */
457 # ifdef MNT2_NFS_OPT_ACDIRMAX
458 if (!err_acval || !err_acrdmm)
459 nap->flags |= MNT2_NFS_OPT_ACDIRMAX;
460 # endif /* MNT2_NFS_OPT_ACDIRMAX */
461 #endif /* HAVE_NFS_ARGS_T_ACDIRMAX */
464 /* don't cache attributes */
465 #if defined(MNTTAB_OPT_NOAC) && defined(MNT2_NFS_OPT_NOAC)
466 if (amu_hasmntopt(mntp, MNTTAB_OPT_NOAC) != NULL)
467 nap->flags |= MNT2_NFS_OPT_NOAC;
468 #endif /* defined(MNTTAB_OPT_NOAC) && defined(MNT2_NFS_OPT_NOAC) */
473 * Fill in the many possible fields and flags of struct nfs_args.
475 * nap: pre-allocated structure to fill in.
476 * mntp: mount entry structure (includes options)
477 * genflags: generic mount flags already determined
478 * nfsncp: (TLI only) netconfig entry for this NFS mount
479 * ip_addr: IP address of file server
480 * nfs_version: 2, 3, (4 in the future), or 0 if unknown
481 * nfs_proto: "udp", "tcp", or NULL.
482 * fhp: file handle structure pointer
483 * host_name: name of remote NFS host
484 * fs_name: remote file system name to mount
486 void
487 compute_nfs_args(nfs_args_t *nap,
488 mntent_t *mntp,
489 int genflags,
490 struct netconfig *nfsncp,
491 struct sockaddr_in *ip_addr,
492 u_long nfs_version,
493 char *nfs_proto,
494 am_nfs_handle_t *fhp,
495 char *host_name,
496 char *fs_name)
498 /* initialize just in case */
499 memset((voidp) nap, 0, sizeof(nfs_args_t));
501 /* compute all of the NFS attribute-cache flags */
502 compute_nfs_attrcache_flags(nap, mntp);
504 /************************************************************************/
505 /*** FILEHANDLE DATA AND LENGTH ***/
506 /************************************************************************/
507 #ifdef HAVE_FS_NFS3
508 if (nfs_version == NFS_VERSION3) {
509 # if defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN)
511 * Some systems (Irix/bsdi3) have a separate field in nfs_args for
512 * the length of the file handle for NFS V3. They insist that
513 * the file handle set in nfs_args be plain bytes, and not
514 * include the length field.
516 NFS_FH_DREF(nap->NFS_FH_FIELD, &fhp->v3.am_fh3_data);
517 # else /* not defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN) */
518 NFS_FH_DREF(nap->NFS_FH_FIELD, &fhp->v3);
519 # endif /* not defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN) */
520 # ifdef MNT2_NFS_OPT_NFSV3
521 nap->flags |= MNT2_NFS_OPT_NFSV3;
522 # endif /* MNT2_NFS_OPT_NFSV3 */
523 # ifdef MNT2_NFS_OPT_VER3
524 nap->flags |= MNT2_NFS_OPT_VER3;
525 # endif /* MNT2_NFS_OPT_VER3 */
526 } else
527 #endif /* HAVE_FS_NFS3 */
528 NFS_FH_DREF(nap->NFS_FH_FIELD, &fhp->v2);
530 #ifdef HAVE_NFS_ARGS_T_FHSIZE
531 # ifdef HAVE_FS_NFS3
532 if (nfs_version == NFS_VERSION3)
533 nap->fhsize = fhp->v3.am_fh3_length;
534 else
535 # endif /* HAVE_FS_NFS3 */
536 nap->fhsize = FHSIZE;
537 #endif /* HAVE_NFS_ARGS_T_FHSIZE */
539 /* this is the version of the nfs_args structure, not of NFS! */
540 #ifdef HAVE_NFS_ARGS_T_FH_LEN
541 # ifdef HAVE_FS_NFS3
542 if (nfs_version == NFS_VERSION3)
543 nap->fh_len = fhp->v3.am_fh3_length;
544 else
545 # endif /* HAVE_FS_NFS3 */
546 nap->fh_len = FHSIZE;
547 #endif /* HAVE_NFS_ARGS_T_FH_LEN */
549 /************************************************************************/
550 /*** HOST NAME ***/
551 /************************************************************************/
553 * XXX: warning, using xstrlcpy in NFS_HN_DREF, which may corrupt a
554 * struct nfs_args, or truncate our concocted "hostname:/path"
555 * string prematurely.
557 NFS_HN_DREF(nap->hostname, host_name);
558 #ifdef MNT2_NFS_OPT_HOSTNAME
559 nap->flags |= MNT2_NFS_OPT_HOSTNAME;
560 #endif /* MNT2_NFS_OPT_HOSTNAME */
562 /************************************************************************/
563 /*** IP ADDRESS OF REMOTE HOST ***/
564 /************************************************************************/
565 if (ip_addr) {
566 #ifdef HAVE_TRANSPORT_TYPE_TLI
567 nap->addr = ALLOC(struct netbuf); /* free()'ed at end of mount_nfs_fh() */
568 #endif /* HAVE_TRANSPORT_TYPE_TLI */
569 NFS_SA_DREF(nap, ip_addr);
572 /************************************************************************/
573 /*** NFS PROTOCOL (UDP, TCP) AND VERSION ***/
574 /************************************************************************/
575 #ifdef MNT2_NFS_OPT_TCP
576 if (nfs_proto && STREQ(nfs_proto, "tcp"))
577 nap->flags |= MNT2_NFS_OPT_TCP;
578 #endif /* MNT2_NFS_OPT_TCP */
580 #ifdef HAVE_NFS_ARGS_T_SOTYPE
581 /* bsdi3 uses this */
582 if (nfs_proto) {
583 if (STREQ(nfs_proto, "tcp"))
584 nap->sotype = SOCK_STREAM;
585 else if (STREQ(nfs_proto, "udp"))
586 nap->sotype = SOCK_DGRAM;
588 #endif /* HAVE_NFS_ARGS_T_SOTYPE */
590 #ifdef HAVE_NFS_ARGS_T_PROTO
591 nap->proto = 0; /* bsdi3 sets this field to zero */
592 # ifdef IPPROTO_TCP
593 if (nfs_proto) {
594 if (STREQ(nfs_proto, "tcp")) /* AIX 4.2.x needs this */
595 nap->proto = IPPROTO_TCP;
596 else if (STREQ(nfs_proto, "udp"))
597 nap->proto = IPPROTO_UDP;
599 # endif /* IPPROTO_TCP */
600 #endif /* HAVE_NFS_ARGS_T_SOTYPE */
602 #ifdef HAVE_NFS_ARGS_T_VERSION
603 # ifdef NFS_ARGSVERSION
604 nap->version = NFS_ARGSVERSION; /* BSDI 3.0 and OpenBSD 2.2 */
605 # endif /* NFS_ARGSVERSION */
606 # ifdef DG_MOUNT_NFS_VERSION
607 nap->version = DG_MOUNT_NFS_VERSION; /* dg-ux */
608 # endif /* DG_MOUNT_NFS_VERSION */
609 #endif /* HAVE_NFS_ARGS_VERSION */
611 /************************************************************************/
612 /*** OTHER NFS SOCKET RELATED OPTIONS AND FLAGS ***/
613 /************************************************************************/
614 #ifdef MNT2_NFS_OPT_NOCONN
615 /* check if user specified to use unconnected or connected sockets */
616 if (amu_hasmntopt(mntp, MNTTAB_OPT_NOCONN) != NULL)
617 nap->flags |= MNT2_NFS_OPT_NOCONN;
618 else if (amu_hasmntopt(mntp, MNTTAB_OPT_CONN) != NULL)
619 nap->flags &= ~MNT2_NFS_OPT_NOCONN;
620 else {
622 * Some OSs want you to set noconn always. Some want you to always turn
623 * it off. Others want you to turn it on/off only if NFS V.3 is used.
624 * And all of that changes from revision to another. This is
625 * particularly true of OpenBSD, NetBSD, and FreeBSD. So, rather than
626 * attempt to auto-detect this, I'm forced to "fix" it in the individual
627 * conf/nfs_prot/nfs_prot_*.h files.
629 # ifdef USE_UNCONNECTED_NFS_SOCKETS
630 if (!(nap->flags & MNT2_NFS_OPT_NOCONN)) {
631 nap->flags |= MNT2_NFS_OPT_NOCONN;
632 plog(XLOG_WARNING, "noconn option not specified, and was just turned ON (OS override)! (May cause NFS hangs on some systems...)");
634 # endif /* USE_UNCONNECTED_NFS_SOCKETS */
635 # ifdef USE_CONNECTED_NFS_SOCKETS
636 if (nap->flags & MNT2_NFS_OPT_NOCONN) {
637 nap->flags &= ~MNT2_NFS_OPT_NOCONN;
638 plog(XLOG_WARNING, "noconn option specified, and was just turned OFF (OS override)! (May cause NFS hangs on some systems...)");
640 # endif /* USE_CONNECTED_NFS_SOCKETS */
642 #endif /* MNT2_NFS_OPT_NOCONN */
644 #ifdef MNT2_NFS_OPT_RESVPORT
645 # ifdef MNTTAB_OPT_RESVPORT
646 if (amu_hasmntopt(mntp, MNTTAB_OPT_RESVPORT) != NULL)
647 nap->flags |= MNT2_NFS_OPT_RESVPORT;
648 # else /* not MNTTAB_OPT_RESVPORT */
649 nap->flags |= MNT2_NFS_OPT_RESVPORT;
650 # endif /* not MNTTAB_OPT_RESVPORT */
651 #endif /* MNT2_NFS_OPT_RESVPORT */
653 /************************************************************************/
654 /*** OTHER FLAGS AND OPTIONS ***/
655 /************************************************************************/
657 #ifdef HAVE_TRANSPORT_TYPE_TLI
658 /* set up syncaddr field */
659 nap->syncaddr = (struct netbuf *) NULL;
661 /* set up knconf field */
662 if (get_knetconfig(&nap->knconf, nfsncp, nfs_proto) < 0) {
663 plog(XLOG_FATAL, "cannot fill knetconfig structure for nfs_args");
664 going_down(1);
666 /* update the flags field for knconf */
667 nap->flags |= MNT2_NFS_OPT_KNCONF;
668 #endif /* HAVE_TRANSPORT_TYPE_TLI */
670 #ifdef MNT2_NFS_OPT_FSNAME
671 nap->fsname = fs_name;
672 nap->flags |= MNT2_NFS_OPT_FSNAME;
673 #endif /* MNT2_NFS_OPT_FSNAME */
675 nap->rsize = hasmntval(mntp, MNTTAB_OPT_RSIZE);
676 #ifdef MNT2_NFS_OPT_RSIZE
677 if (nap->rsize)
678 nap->flags |= MNT2_NFS_OPT_RSIZE;
679 #endif /* MNT2_NFS_OPT_RSIZE */
680 if (nfs_version == NFS_VERSION && nap->rsize > 8192)
681 nap->rsize = 8192;
683 nap->wsize = hasmntval(mntp, MNTTAB_OPT_WSIZE);
684 #ifdef MNT2_NFS_OPT_WSIZE
685 if (nap->wsize)
686 nap->flags |= MNT2_NFS_OPT_WSIZE;
687 #endif /* MNT2_NFS_OPT_WSIZE */
688 if (nfs_version == NFS_VERSION && nap->wsize > 8192)
689 nap->wsize = 8192;
691 nap->timeo = hasmntval(mntp, MNTTAB_OPT_TIMEO);
692 #ifdef MNT2_NFS_OPT_TIMEO
693 if (nap->timeo)
694 nap->flags |= MNT2_NFS_OPT_TIMEO;
695 #endif /* MNT2_NFS_OPT_TIMEO */
697 nap->retrans = hasmntval(mntp, MNTTAB_OPT_RETRANS);
698 #ifdef MNT2_NFS_OPT_RETRANS
699 if (nap->retrans)
700 nap->flags |= MNT2_NFS_OPT_RETRANS;
701 #endif /* MNT2_NFS_OPT_RETRANS */
703 #ifdef MNT2_NFS_OPT_BIODS
704 if ((nap->biods = hasmntval(mntp, MNTTAB_OPT_BIODS)))
705 nap->flags |= MNT2_NFS_OPT_BIODS;
706 #endif /* MNT2_NFS_OPT_BIODS */
708 #ifdef MNT2_NFS_OPT_SOFT
709 if (amu_hasmntopt(mntp, MNTTAB_OPT_SOFT) != NULL)
710 nap->flags |= MNT2_NFS_OPT_SOFT;
711 #endif /* MNT2_NFS_OPT_SOFT */
713 #ifdef MNT2_NFS_OPT_SPONGY
714 if (amu_hasmntopt(mntp, MNTTAB_OPT_SPONGY) != NULL) {
715 nap->flags |= MNT2_NFS_OPT_SPONGY;
716 if (nap->flags & MNT2_NFS_OPT_SOFT) {
717 plog(XLOG_USER, "Mount opts soft and spongy are incompatible - soft ignored");
718 nap->flags &= ~MNT2_NFS_OPT_SOFT;
721 #endif /* MNT2_NFS_OPT_SPONGY */
723 #if defined(MNT2_GEN_OPT_RONLY) && defined(MNT2_NFS_OPT_RONLY)
724 /* Ultrix has separate generic and NFS ro flags */
725 if (genflags & MNT2_GEN_OPT_RONLY)
726 nap->flags |= MNT2_NFS_OPT_RONLY;
727 #endif /* defined(MNT2_GEN_OPT_RONLY) && defined(MNT2_NFS_OPT_RONLY) */
729 #ifdef MNTTAB_OPT_INTR
730 if (amu_hasmntopt(mntp, MNTTAB_OPT_INTR) != NULL)
732 * Either turn on the "allow interrupts" option, or
733 * turn off the "disallow interrupts" option"
735 # ifdef MNT2_NFS_OPT_INTR
736 nap->flags |= MNT2_NFS_OPT_INTR;
737 # endif /* MNT2_NFS_OPT_INTR */
738 # ifdef MNT2_NFS_OPT_NOINTR
739 nap->flags &= ~MNT2_NFS_OPT_NOINTR;
740 # endif /* MNT2_NFS_OPT_NOINTR */
741 # ifdef MNT2_NFS_OPT_INT
742 nap->flags |= MNT2_NFS_OPT_INT;
743 # endif /* MNT2_NFS_OPT_INT */
744 # ifdef MNT2_NFS_OPT_NOINT
745 nap->flags &= ~MNT2_NFS_OPT_NOINT;
746 # endif /* MNT2_NFS_OPT_NOINT */
747 #endif /* MNTTAB_OPT_INTR */
749 #ifdef MNTTAB_OPT_NODEVS
750 if (amu_hasmntopt(mntp, MNTTAB_OPT_NODEVS) != NULL)
751 nap->flags |= MNT2_NFS_OPT_NODEVS;
752 #endif /* MNTTAB_OPT_NODEVS */
754 #ifdef MNTTAB_OPT_COMPRESS
755 if (amu_hasmntopt(mntp, MNTTAB_OPT_COMPRESS) != NULL)
756 nap->flags |= MNT2_NFS_OPT_COMPRESS;
757 #endif /* MNTTAB_OPT_COMPRESS */
759 #ifdef MNTTAB_OPT_PRIVATE /* mount private, single-client tree */
760 if (amu_hasmntopt(mntp, MNTTAB_OPT_PRIVATE) != NULL)
761 nap->flags |= MNT2_NFS_OPT_PRIVATE;
762 #endif /* MNTTAB_OPT_PRIVATE */
764 #ifdef MNTTAB_OPT_SYMTTL /* symlink cache time-to-live */
765 if ((nap->symttl = hasmntval(mntp, MNTTAB_OPT_SYMTTL)))
766 nap->flags |= MNT2_NFS_OPT_SYMTTL;
767 #endif /* MNTTAB_OPT_SYMTTL */
769 #ifdef MNT2_NFS_OPT_PGTHRESH /* paging threshold */
770 if ((nap->pg_thresh = hasmntval(mntp, MNTTAB_OPT_PGTHRESH)))
771 nap->flags |= MNT2_NFS_OPT_PGTHRESH;
772 #endif /* MNT2_NFS_OPT_PGTHRESH */
774 #if defined(MNT2_NFS_OPT_NOCTO) && defined(MNTTAB_OPT_NOCTO)
775 if (amu_hasmntopt(mntp, MNTTAB_OPT_NOCTO) != NULL)
776 nap->flags |= MNT2_NFS_OPT_NOCTO;
777 #endif /* defined(MNT2_NFS_OPT_NOCTO) && defined(MNTTAB_OPT_NOCTO) */
779 #if defined(MNT2_NFS_OPT_POSIX) && defined(MNTTAB_OPT_POSIX)
780 if (amu_hasmntopt(mntp, MNTTAB_OPT_POSIX) != NULL) {
781 nap->flags |= MNT2_NFS_OPT_POSIX;
782 # ifdef HAVE_NFS_ARGS_T_PATHCONF
783 nap->pathconf = NULL;
784 # endif /* HAVE_NFS_ARGS_T_PATHCONF */
786 #endif /* MNT2_NFS_OPT_POSIX && MNTTAB_OPT_POSIX */
788 #if defined(MNT2_NFS_OPT_PROPLIST) && defined(MNTTAB_OPT_PROPLIST)
789 if (amu_hasmntopt(mntp, MNTTAB_OPT_PROPLIST) != NULL)
790 nap->flags |= MNT2_NFS_OPT_PROPLIST;
791 #endif /* defined(MNT2_NFS_OPT_PROPLIST) && defined(MNTTAB_OPT_PROPLIST) */
793 #if defined(MNT2_NFS_OPT_MAXGRPS) && defined(MNTTAB_OPT_MAXGROUPS)
794 nap->maxgrouplist = hasmntval(mntp, MNTTAB_OPT_MAXGROUPS);
795 if (nap->maxgrouplist != 0)
796 nap->flags |= MNT2_NFS_OPT_MAXGRPS;
797 #endif /* defined(MNT2_NFS_OPT_MAXGRPS) && defined(MNTTAB_OPT_MAXGROUPS) */
799 #if defined(MNT2_NFS_OPT_NONLM) && defined(MNTTAB_OPT_NOLOCK)
800 if (amu_hasmntopt(mntp, MNTTAB_OPT_NOLOCK) != NULL)
801 nap->flags |= MNT2_NFS_OPT_NONLM;
802 #endif /* defined(MNT2_NFS_OPT_NONLM) && defined(MNTTAB_OPT_NOLOCK) */
804 #if defined(MNT2_NFS_OPT_XLATECOOKIE) && defined(MNTTAB_OPT_XLATECOOKIE)
805 if (amu_hasmntopt(mntp, MNTTAB_OPT_XLATECOOKIE) != NULL)
806 nap->flags |= MNT2_NFS_OPT_XLATECOOKIE;
807 #endif /* defined(MNT2_NFS_OPT_XLATECOOKIE) && defined(MNTTAB_OPT_XLATECOOKIE) */
809 #ifdef HAVE_NFS_ARGS_T_OPTSTR
810 nap->optstr = mntp->mnt_opts;
811 #endif /* HAVE_NFS_ARGS_T_OPTSTR */
813 /************************************************************************/
814 /*** FINAL ACTIONS ***/
815 /************************************************************************/
817 #ifdef HAVE_NFS_ARGS_T_GFS_FLAGS
818 /* Ultrix stores generic flags in nfs_args.gfs_flags. */
819 nap->gfs_flags = genflags;
820 #endif /* HAVE_NFS_ARGS_T_FLAGS */
822 return; /* end of compute_nfs_args() function */
827 * Fill in special values for flags and fields of nfs_args, for an
828 * automounter NFS mount.
830 void
831 compute_automounter_nfs_args(nfs_args_t *nap, mntent_t *mntp)
833 #ifdef MNT2_NFS_OPT_SYMTTL
835 * Don't let the kernel cache symbolic links we generate, or else lookups
836 * will bypass amd and fail to remount stuff as needed.
838 plog(XLOG_INFO, "turning on NFS option symttl and setting value to 0");
839 nap->flags |= MNT2_NFS_OPT_SYMTTL;
840 nap->symttl = 0;
841 #endif /* MNT2_NFS_OPT_SYMTTL */
844 * This completes the flags for the HIDE_MOUNT_TYPE code in the
845 * mount_amfs_toplvl() function in amd/amfs_toplvl.c.
846 * Some systems don't have a mount type, but a mount flag.
848 #ifdef MNT2_NFS_OPT_AUTO
849 nap->flags |= MNT2_NFS_OPT_AUTO;
850 #endif /* MNT2_NFS_OPT_AUTO */
851 #ifdef MNT2_NFS_OPT_IGNORE
852 nap->flags |= MNT2_NFS_OPT_IGNORE;
853 #endif /* MNT2_NFS_OPT_IGNORE */
854 #ifdef MNT2_GEN_OPT_AUTOMNTFS
855 nap->flags |= MNT2_GEN_OPT_AUTOMNTFS;
856 #endif /* not MNT2_GEN_OPT_AUTOMNTFS */
858 #ifdef MNT2_NFS_OPT_DUMBTIMR
860 * Don't let the kernel start computing throughput of Amd. The numbers
861 * will be meaningless because of the way Amd does mount retries.
863 plog(XLOG_INFO, "%s: disabling nfs congestion window", mntp->mnt_dir);
864 nap->flags |= MNT2_NFS_OPT_DUMBTIMR;
865 #endif /* MNT2_NFS_OPT_DUMBTIMR */
867 /* compute all of the NFS attribute-cache flags */
868 compute_nfs_attrcache_flags(nap, mntp);
871 * Provide a slight bit more security by requiring the kernel to use
872 * reserved ports.
874 #ifdef MNT2_NFS_OPT_RESVPORT
875 nap->flags |= MNT2_NFS_OPT_RESVPORT;
876 #endif /* MNT2_NFS_OPT_RESVPORT */
880 #ifdef DEBUG
881 /* get string version (in hex) of identifier */
882 static char *
883 get_hex_string(u_int len, const char *fhdata)
885 u_int i;
886 static char buf[128]; /* better not go over it! */
887 char str[16];
888 short int arr[64];
890 if (!fhdata)
891 return NULL;
892 buf[0] = '\0';
893 memset(&arr[0], 0, (64 * sizeof(short int)));
894 memcpy(&arr[0], &fhdata[0], len);
895 for (i=0; i<len/sizeof(unsigned short int); i++) {
896 xsnprintf(str, sizeof(str), "%04x", ntohs(arr[i]));
897 xstrlcat(buf, str, sizeof(buf));
899 return buf;
904 * print a subset of fields from "struct nfs_args" that are otherwise
905 * not being provided anywhere else.
907 void
908 print_nfs_args(const nfs_args_t *nap, u_long nfs_version)
910 int fhlen = 32; /* default: NFS V.2 file handle length is 32 */
911 #ifdef HAVE_TRANSPORT_TYPE_TLI
912 struct netbuf *nbp;
913 struct knetconfig *kncp;
914 #else /* not HAVE_TRANSPORT_TYPE_TLI */
915 struct sockaddr_in *sap;
916 #endif /* not HAVE_TRANSPORT_TYPE_TLI */
918 if (!nap) {
919 plog(XLOG_DEBUG, "NULL nfs_args!");
920 return;
923 /* override default file handle size */
924 #ifdef FHSIZE
925 fhlen = FHSIZE;
926 #endif /* FHSIZE */
927 #ifdef NFS_FHSIZE
928 fhlen = NFS_FHSIZE;
929 #endif /* NFS_FHSIZE */
931 #ifdef HAVE_TRANSPORT_TYPE_TLI
932 nbp = nap->addr;
933 plog(XLOG_DEBUG, "NA->addr {netbuf} (maxlen=%d, len=%d) = \"%s\"",
934 nbp->maxlen, nbp->len,
935 get_hex_string(nbp->len, nbp->buf));
936 nbp = nap->syncaddr;
937 plog(XLOG_DEBUG, "NA->syncaddr {netbuf} %p", nbp);
938 kncp = nap->knconf;
939 plog(XLOG_DEBUG, "NA->knconf->semantics %lu", (u_long) kncp->knc_semantics);
940 plog(XLOG_DEBUG, "NA->knconf->protofmly \"%s\"", kncp->knc_protofmly);
941 plog(XLOG_DEBUG, "NA->knconf->proto \"%s\"", kncp->knc_proto);
942 plog(XLOG_DEBUG, "NA->knconf->rdev %lu", (u_long) kncp->knc_rdev);
943 /* don't print knconf->unused field */
944 #else /* not HAVE_TRANSPORT_TYPE_TLI */
945 # ifdef NFS_ARGS_T_ADDR_IS_POINTER
946 sap = (struct sockaddr_in *) nap->addr;
947 # else /* not NFS_ARGS_T_ADDR_IS_POINTER */
948 sap = (struct sockaddr_in *) &nap->addr;
949 # endif /* not NFS_ARGS_T_ADDR_IS_POINTER */
950 plog(XLOG_DEBUG, "NA->addr {sockaddr_in} (len=%d) = \"%s\"",
951 (int) sizeof(struct sockaddr_in),
952 get_hex_string(sizeof(struct sockaddr_in), (const char *)sap));
953 #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
954 /* as per POSIX, sin_len need not be set (used internally by kernel) */
955 plog(XLOG_DEBUG, "NA->addr.sin_len = %d", sap->sin_len);
956 #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
957 plog(XLOG_DEBUG, "NA->addr.sin_family = %d", sap->sin_family);
958 plog(XLOG_DEBUG, "NA->addr.sin_port = %d", sap->sin_port);
959 plog(XLOG_DEBUG, "NA->addr.sin_addr = \"%s\"",
960 get_hex_string(sizeof(struct in_addr), (const char *) &sap->sin_addr));
961 #endif /* not HAVE_TRANSPORT_TYPE_TLI */
962 #ifdef HAVE_NFS_ARGS_T_ADDRLEN
963 plog(XLOG_DEBUG, "NA->addrlen = %d", nap->addrlen);
964 #endif /* ifdef HAVE_NFS_ARGS_T_ADDRLEN */
966 plog(XLOG_DEBUG, "NA->hostname = \"%s\"", nap->hostname ? nap->hostname : "null");
967 #ifdef HAVE_NFS_ARGS_T_NAMLEN
968 plog(XLOG_DEBUG, "NA->namlen = %d", nap->namlen);
969 #endif /* HAVE_NFS_ARGS_T_NAMLEN */
971 #ifdef MNT2_NFS_OPT_FSNAME
972 plog(XLOG_DEBUG, "NA->fsname = \"%s\"", nap->fsname ? nap->fsname : "null");
973 #endif /* MNT2_NFS_OPT_FSNAME */
975 #ifdef HAVE_NFS_ARGS_T_FHSIZE
976 plog(XLOG_DEBUG, "NA->fhsize = %d", nap->fhsize);
977 fhlen = nap->fhsize;
978 #endif /* HAVE_NFS_ARGS_T_FHSIZE */
979 #ifdef HAVE_NFS_ARGS_T_FH_LEN
980 plog(XLOG_DEBUG, "NA->fh_len = %d", nap->fh_len);
981 fhlen = nap->fh_len;
982 #endif /* HAVE_NFS_ARGS_T_FH_LEN */
985 * XXX: need to figure out how to correctly print file handles,
986 * since some times they are pointers, and sometimes the real structure
987 * is stored in nfs_args. Even if it is a pointer, it can be the actual
988 * char[] array, or a structure containing multiple fields.
990 plog(XLOG_DEBUG, "NA->filehandle = \"%s\"",
991 get_hex_string(fhlen, (const char *) &nap->NFS_FH_FIELD));
993 #ifdef HAVE_NFS_ARGS_T_SOTYPE
994 plog(XLOG_DEBUG, "NA->sotype = %d", nap->sotype);
995 #endif /* HAVE_NFS_ARGS_T_SOTYPE */
996 #ifdef HAVE_NFS_ARGS_T_PROTO
997 plog(XLOG_DEBUG, "NA->proto = %d", (int) nap->proto);
998 #endif /* HAVE_NFS_ARGS_T_PROTO */
999 #ifdef HAVE_NFS_ARGS_T_VERSION
1000 plog(XLOG_DEBUG, "NA->version = %d", nap->version);
1001 #endif /* HAVE_NFS_ARGS_T_VERSION */
1003 plog(XLOG_DEBUG, "NA->flags = 0x%x", (int) nap->flags);
1005 plog(XLOG_DEBUG, "NA->rsize = %d", (int) nap->rsize);
1006 plog(XLOG_DEBUG, "NA->wsize = %d", (int) nap->wsize);
1007 #ifdef HAVE_NFS_ARGS_T_BSIZE
1008 plog(XLOG_DEBUG, "NA->bsize = %d", nap->bsize);
1009 #endif /* HAVE_NFS_ARGS_T_BSIZE */
1010 plog(XLOG_DEBUG, "NA->timeo = %d", (int) nap->timeo);
1011 plog(XLOG_DEBUG, "NA->retrans = %d", (int) nap->retrans);
1013 #ifdef HAVE_NFS_ARGS_T_ACREGMIN
1014 plog(XLOG_DEBUG, "NA->acregmin = %d", (int) nap->acregmin);
1015 plog(XLOG_DEBUG, "NA->acregmax = %d", (int) nap->acregmax);
1016 plog(XLOG_DEBUG, "NA->acdirmin = %d", (int) nap->acdirmin);
1017 plog(XLOG_DEBUG, "NA->acdirmax = %d", (int) nap->acdirmax);
1018 #endif /* HAVE_NFS_ARGS_T_ACREGMIN */
1019 #ifdef MNTTAB_OPT_SYMTTL
1020 plog(XLOG_DEBUG, "NA->symttl = %d", nap->symttl);
1021 #endif /* MNTTAB_OPT_SYMTTL */
1022 #ifdef MNTTAB_OPT_PG_THRESH
1023 plog(XLOG_DEBUG, "NA->pg_thresh = %d", nap->pg_thresh);
1024 #endif /* MNTTAB_OPT_PG_THRESH */
1026 #ifdef MNT2_NFS_OPT_BIODS
1027 plog(XLOG_DEBUG, "NA->biods = %d", nap->biods);
1028 #endif /* MNT2_NFS_OPT_BIODS */
1031 #endif /* DEBUG */