diff --git a/usr.sbin/makefs/msdos.c b/usr.sbin/makefs/msdos.c index c3633825716d..9f2528a6987e 100644 --- a/usr.sbin/makefs/msdos.c +++ b/usr.sbin/makefs/msdos.c @@ -203,6 +203,8 @@ msdos_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts) 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'); diff --git a/usr.sbin/makefs/msdos.h b/usr.sbin/makefs/msdos.h index a5deb42960f3..d9f1cc4cdb11 100644 --- a/usr.sbin/makefs/msdos.h +++ b/usr.sbin/makefs/msdos.h @@ -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 *); diff --git a/usr.sbin/makefs/msdos/msdosfs_vfsops.c b/usr.sbin/makefs/msdos/msdosfs_vfsops.c index d48d0afe6709..b3b008a12f08 100644 --- a/usr.sbin/makefs/msdos/msdosfs_vfsops.c +++ b/usr.sbin/makefs/msdos/msdosfs_vfsops.c @@ -359,3 +359,33 @@ msdosfs_root(struct msdosfsmount *pmp, struct vnode *vp) { 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); +}