Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Aug 2019 14:11:55 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r351215 - head/sys/kern
Message-ID:  <201908191411.x7JEBtmj058100@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Mon Aug 19 14:11:54 2019
New Revision: 351215
URL: https://svnweb.freebsd.org/changeset/base/351215

Log:
  vfs: fix up r351193 ("stop always overwriting ->mnt_stat in VFS_STATFS")
  
  fs-specific part of vfs_statfs routines only fill in small portion of the
  structure. Previous code was always copying everything at a higher layer to
  acoomodate it and this patch does the same.
  
  'df' (no arguments) worked fine because the caller uses mnt_stat itself as the
  target buffer, making all the copying a no-op for its own case.
  'df /' and similar use a different consumer which passes its own buffer and
  this is where you can run into trouble.
  
  Reported by:	cy
  Fixes: r351193
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/kern/vfs_mount.c

Modified: head/sys/kern/vfs_mount.c
==============================================================================
--- head/sys/kern/vfs_mount.c	Mon Aug 19 12:42:03 2019	(r351214)
+++ head/sys/kern/vfs_mount.c	Mon Aug 19 14:11:54 2019	(r351215)
@@ -1833,6 +1833,12 @@ __vfs_statfs(struct mount *mp, struct statfs *sbp)
 {
 
 	/*
+	 * Filesystems only fill in part of the structure for updates, we
+	 * have to read the entirety first to get all content.
+	 */
+	memcpy(sbp, &mp->mnt_stat, sizeof(*sbp));
+
+	/*
 	 * Set these in case the underlying filesystem fails to do so.
 	 */
 	sbp->f_version = STATFS_VERSION;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201908191411.x7JEBtmj058100>