Date: Tue, 5 Feb 2008 13:28:31 -0600 From: Dan Nelson <dnelson@allantgroup.com> To: Mike Andrews <mandrews@bit0.com> Cc: freebsd-stable@freebsd.org Subject: Re: mount -p and NFS options Message-ID: <20080205192830.GB17472@dan.emsphone.com> In-Reply-To: <20080204230945.J49853@mindcrime.int.bit0.com> References: <20080204230945.J49853@mindcrime.int.bit0.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
In the last episode (Feb 04), Mike Andrews said:
> Is there anything like "mount -p" that will print the current NFS
> options in use? TCP vs UDP, v2 vs v3, read/write sizes etc. It
> doesn't have to be in fstab format; I just need to be able to see
> what the flags are for an active mount.
>
> This would be useful in tracking down an irritating NFS problem I've
> been experiencing with diskless systems in every 6.x release and
> 7.0-RC1, namely libc.so.6 appears to be truncated or corrupt to the
> client at somewhat random times... I think it may be related to
> mount options, hence the question.
Theoretically, any filesystem that uses nmount(2) should have its
options recored in an easy-to-extract format, since one of the
arguments to nmount is an array of options. I patched my kernel and
/sbin/mount binary to do this (borrowing the f_charspare field in
struct statfs), and it mostly works. The stuff below in <> brackets
are from the options array. You can see that cd9660 was mounted with
the option "ssector=0":
(root@dan) /root># mount
local/root on / (zfs, NFS exported, local, <rw,noro>)
devfs on /dev (devfs, local, <>)
/dev/ufs/boot on /.boot (ufs, local, soft-updates, <rw,noro>)
procfs on /proc (procfs, local, <rw,noro>)
/dev/md0 on /tmp (ufs, NFS exported, local, <>)
/dev/cd0 on /cdrom (cd9660, NFS exported, local, read-only, <ro,ssector=0>)
Unfortunately, mount_nfs simply calls nmount with a single "nfs_args"
option whose value is the same binary "struct nfs_args" it used to call
mount(2) with :( The fix would be to make nfs_vfsops.c and mount_nfs.c
use the options array instead of a custom struct, but
nfs_vfsops.c:nfs_decode_args scares me off every time I look at it.
--
Dan Nelson
dnelson@allantgroup.com
[-- Attachment #2 --]
Index: sys/kern/vfs_mount.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/vfs_mount.c,v
retrieving revision 1.265.2.2
diff -u -p -r1.265.2.2 vfs_mount.c
--- sys/kern/vfs_mount.c 17 Jan 2008 04:24:53 -0000 1.265.2.2
+++ sys/kern/vfs_mount.c 18 Jan 2008 23:13:48 -0000
@@ -1020,6 +1020,40 @@ vfs_domount(
if (mp->mnt_opt != NULL)
vfs_freeopts(mp->mnt_opt);
mp->mnt_opt = mp->mnt_optnew;
+
+ /* Collapse the mount options into a readable string */
+ mp->mnt_stat.f_charspare[0]=0;
+ if (mp->mnt_opt) {
+ struct vfsopt *opt;
+ struct sbuf *sb;
+
+ sb = sbuf_new(NULL, mp->mnt_stat.f_charspare,
+ sizeof(mp->mnt_stat.f_charspare),
+ SBUF_FIXEDLEN);
+ TAILQ_FOREACH(opt, mp->mnt_opt, link) {
+ /*
+ * Skip options that are temporary, stored
+ * elsewhere in struct statfs, or are structs
+ */
+ if (strcmp(opt->name,"errmsg") == 0 ||
+ strcmp(opt->name,"from") == 0 ||
+ strcmp(opt->name,"fspath") == 0 ||
+ strcmp(opt->name,"fstype") == 0 ||
+ strcmp(opt->name,"nfs_args") == 0 ||
+ strcmp(opt->name,"update") == 0 )
+ continue;
+ if (sbuf_len(sb))
+ sbuf_cat(sb, ",");
+ sbuf_cat(sb, opt->name);
+ if (opt->len) {
+ sbuf_cat(sb, "=");
+ sbuf_cat(sb, opt->value);
+ }
+ }
+ sbuf_finish(sb);
+ sbuf_delete(sb);
+ }
+
(void)VFS_STATFS(mp, &mp->mnt_stat, td);
}
/*
Index: sbin/mount/mount.c
===================================================================
RCS file: /home/ncvs/src/sbin/mount/mount.c,v
retrieving revision 1.96
diff -u -p -r1.96 mount.c
--- sbin/mount/mount.c 25 Jun 2007 05:06:54 -0000 1.96
+++ sbin/mount/mount.c 2 Oct 2007 21:20:18 -0000
@@ -596,6 +596,7 @@ prmount(struct statfs *sfp)
(void)printf(", %s", o->o_name);
flags &= ~o->o_opt;
}
+ printf(", <%s>",sfp->f_charspare);
/*
* Inform when file system is mounted by an unprivileged user
* or privileged non-root user.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080205192830.GB17472>
