svn commit: r343044 - stable/11/sbin/newfs_msdos
Kyle Evans
kevans at FreeBSD.org
Tue Jan 15 15:47:02 UTC 2019
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;
}
More information about the svn-src-stable
mailing list