From owner-svn-src-all@freebsd.org Tue Jan 15 15:47:02 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ACAA0148E3B0; Tue, 15 Jan 2019 15:47:02 +0000 (UTC) (envelope-from kevans@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 49B478BFF2; Tue, 15 Jan 2019 15:47:02 +0000 (UTC) (envelope-from kevans@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 36AE21CEBA; Tue, 15 Jan 2019 15:47:02 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x0FFl2SN025256; Tue, 15 Jan 2019 15:47:02 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x0FFl2XQ025255; Tue, 15 Jan 2019 15:47:02 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201901151547.x0FFl2XQ025255@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 15 Jan 2019 15:47:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r343044 - stable/11/sbin/newfs_msdos X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/sbin/newfs_msdos X-SVN-Commit-Revision: 343044 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 49B478BFF2 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.972,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] 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: Tue, 15 Jan 2019 15:47:02 -0000 Author: kevans Date: Tue Jan 15 15:47:01 2019 New Revision: 343044 URL: https://svnweb.freebsd.org/changeset/base/343044 Log: MFC r305074-r305075, r327275, r327570: newfs_msdos updates r305074: Remove CHS alignment. It's not needed and causes problems for the BBB boot partition. NetBSD removed it in 1.10 in their repo some time ago. r305075: The code only converts from bpbHugeSectors to bpbSectors if the sum of the hidden and huge sectors is less than or equal MAXU16. When formatting in Windows bpbSectors is still used for 63488 sectors and 2048 hidden (sum > MAXU16). The hidden sectors count is the number of sectors before the FAT16 Boot Record so it shouldn't affect the sector count. Attached patch (huge_sec_conversion.patch) to only check for bpb.bpbHugeSectors <= MAXU16 when converting to bpbSectors. r327275: Close fd and fd1 before returning now that we're done with them. r327570: Only call close if fd and fd1 are not -1. PR: 183234 Modified: stable/11/sbin/newfs_msdos/mkfs_msdos.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/newfs_msdos/mkfs_msdos.c ============================================================================== --- stable/11/sbin/newfs_msdos/mkfs_msdos.c Tue Jan 15 15:35:14 2019 (r343043) +++ stable/11/sbin/newfs_msdos/mkfs_msdos.c Tue Jan 15 15:47:01 2019 (r343044) @@ -249,6 +249,7 @@ mkfs_msdos(const char *fname, const char *dtype, const img = NULL; rv = -1; + fd = fd1 = -1; if (o.block_size && o.sectors_per_cluster) { warnx("Cannot specify both block size and sectors per cluster"); @@ -315,15 +316,8 @@ mkfs_msdos(const char *fname, const char *dtype, const bpb.bpbHiddenSecs = o.hidden_sectors; if (!(o.floppy || (o.drive_heads && o.sectors_per_track && o.bytes_per_sector && o.size && o.hidden_sectors_set))) { - off_t delta; getdiskinfo(fd, fname, dtype, o.hidden_sectors_set, &bpb); bpb.bpbHugeSectors -= (o.offset / bpb.bpbBytesPerSec); - delta = bpb.bpbHugeSectors % bpb.bpbSecPerTrack; - if (delta != 0) { - warnx("trim %d sectors to adjust to a multiple of %d", - (int)delta, bpb.bpbSecPerTrack); - bpb.bpbHugeSectors -= delta; - } if (bpb.bpbSecPerClust == 0) { /* set defaults */ if (bpb.bpbHugeSectors <= 6000) /* about 3MB -> 512 bytes */ bpb.bpbSecPerClust = 1; @@ -598,7 +592,7 @@ mkfs_msdos(const char *fname, const char *dtype, const bpb.bpbMedia = !bpb.bpbHiddenSecs ? 0xf0 : 0xf8; if (fat == 32) bpb.bpbRootClust = RESFTE; - if (bpb.bpbHiddenSecs + bpb.bpbHugeSectors <= MAXU16) { + if (bpb.bpbHugeSectors <= MAXU16) { bpb.bpbSectors = bpb.bpbHugeSectors; bpb.bpbHugeSectors = 0; } @@ -758,6 +752,10 @@ mkfs_msdos(const char *fname, const char *dtype, const rv = 0; done: free(img); + if (fd != -1) + close(fd); + if (fd1 != -1) + close(fd1); return rv; }