svn commit: r351415 - in head/usr.sbin/makefs: . msdos

Xin LI delphij at FreeBSD.org
Fri Aug 23 05:23:46 UTC 2019


Author: delphij
Date: Fri Aug 23 05:23:45 2019
New Revision: 351415
URL: https://svnweb.freebsd.org/changeset/base/351415

Log:
  Properly update FSInfo block after generation.
  
  After populating the filesystem, write a FSInfo block with
  proper information.
  
  Reviewed by:	emaste, cem
  MFC after:	2 weeks
  Differential Revision:	https://reviews.freebsd.org/D21363

Modified:
  head/usr.sbin/makefs/msdos.c
  head/usr.sbin/makefs/msdos.h
  head/usr.sbin/makefs/msdos/msdosfs_vfsops.c

Modified: head/usr.sbin/makefs/msdos.c
==============================================================================
--- head/usr.sbin/makefs/msdos.c	Fri Aug 23 05:04:41 2019	(r351414)
+++ head/usr.sbin/makefs/msdos.c	Fri Aug 23 05:23:45 2019	(r351415)
@@ -203,6 +203,8 @@ msdos_makefs(const char *image, const char *dir, fsnod
 		errx(1, "Image file `%s' not created.", image);
 	TIMER_RESULTS(start, "msdos_populate_dir");
 
+	if (msdosfs_fsiflush(pmp) != 0)
+		errx(1, "Unable to update FSInfo block.");
 	if (debug & DEBUG_FS_MAKEFS)
 		putchar('\n');
 

Modified: head/usr.sbin/makefs/msdos.h
==============================================================================
--- head/usr.sbin/makefs/msdos.h	Fri Aug 23 05:04:41 2019	(r351414)
+++ head/usr.sbin/makefs/msdos.h	Fri Aug 23 05:23:45 2019	(r351415)
@@ -51,6 +51,7 @@ struct componentname {
 	size_t cn_namelen;
 };
 
+int msdosfs_fsiflush(struct msdosfsmount *);
 struct msdosfsmount *msdosfs_mount(struct vnode *);
 int msdosfs_root(struct msdosfsmount *, struct vnode *);
 

Modified: head/usr.sbin/makefs/msdos/msdosfs_vfsops.c
==============================================================================
--- head/usr.sbin/makefs/msdos/msdosfs_vfsops.c	Fri Aug 23 05:04:41 2019	(r351414)
+++ head/usr.sbin/makefs/msdos/msdosfs_vfsops.c	Fri Aug 23 05:23:45 2019	(r351415)
@@ -359,3 +359,33 @@ msdosfs_root(struct msdosfsmount *pmp, struct vnode *v
 	vp->v_data = ndep;
 	return 0;
 }
+
+/*
+ * If we have an FSInfo block, update it.
+ */
+int
+msdosfs_fsiflush(struct msdosfsmount *pmp)
+{
+	struct fsinfo *fp;
+	struct buf *bp;
+	int error;
+
+	if (pmp->pm_fsinfo == 0 || (pmp->pm_flags & MSDOSFS_FSIMOD) == 0) {
+		error = 0;
+		goto out;
+	}
+	error = bread(pmp->pm_devvp, pmp->pm_fsinfo, pmp->pm_BytesPerSec,
+	    NOCRED, &bp);
+	if (error != 0) {
+		brelse(bp);
+		goto out;
+	}
+	fp = (struct fsinfo *)bp->b_data;
+	putulong(fp->fsinfree, pmp->pm_freeclustercount);
+	putulong(fp->fsinxtfree, pmp->pm_nxtfree);
+	pmp->pm_flags &= ~MSDOSFS_FSIMOD;
+	error = bwrite(bp);
+
+out:
+	return (error);
+}


More information about the svn-src-head mailing list