From owner-freebsd-stable@FreeBSD.ORG Tue Feb 5 20:08:09 2008 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 70FD516A41A for ; Tue, 5 Feb 2008 20:08:09 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.freebsd.org (Postfix) with ESMTP id 2EFE413C4D1 for ; Tue, 5 Feb 2008 20:08:08 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.2/8.14.2) id m15JSVjM096245; Tue, 5 Feb 2008 13:28:31 -0600 (CST) (envelope-from dan) Date: Tue, 5 Feb 2008 13:28:31 -0600 From: Dan Nelson To: Mike Andrews Message-ID: <20080205192830.GB17472@dan.emsphone.com> References: <20080204230945.J49853@mindcrime.int.bit0.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2oS5YaxWCcQjTEyO" Content-Disposition: inline In-Reply-To: <20080204230945.J49853@mindcrime.int.bit0.com> X-OS: FreeBSD 7.0-PRERELEASE User-Agent: Mutt/1.5.17 (2007-11-01) Cc: freebsd-stable@freebsd.org Subject: Re: mount -p and NFS options X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Feb 2008 20:08:09 -0000 --2oS5YaxWCcQjTEyO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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, ) devfs on /dev (devfs, local, <>) /dev/ufs/boot on /.boot (ufs, local, soft-updates, ) procfs on /proc (procfs, local, ) /dev/md0 on /tmp (ufs, NFS exported, local, <>) /dev/cd0 on /cdrom (cd9660, NFS exported, local, read-only, ) 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 --2oS5YaxWCcQjTEyO Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="mountopts.diff" 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. --2oS5YaxWCcQjTEyO--