From owner-svn-src-all@freebsd.org Fri Aug 23 05:23:46 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C1A5DDA948; Fri, 23 Aug 2019 05:23:46 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46F8vQ4gG7z4KTv; Fri, 23 Aug 2019 05:23:46 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 81E25FD47; Fri, 23 Aug 2019 05:23:46 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7N5Nk91012289; Fri, 23 Aug 2019 05:23:46 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7N5Nk0M012287; Fri, 23 Aug 2019 05:23:46 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201908230523.x7N5Nk0M012287@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Fri, 23 Aug 2019 05:23:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r351415 - in head/usr.sbin/makefs: . msdos X-SVN-Group: head X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: in head/usr.sbin/makefs: . msdos X-SVN-Commit-Revision: 351415 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Aug 2019 05:23:46 -0000 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); +}