mkfs.fat: Fix calculation of FAT32 cluster size on non 512 bytes sector disks
This commit is contained in:
parent
f8a3f323a3
commit
3f129da5eb
@ -0,0 +1,40 @@
|
|||||||
|
From b71c7c400276cc48acc257c294e01825773100dc Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali.rohar@gmail.com>
|
||||||
|
Date: Sat, 11 Aug 2018 20:34:08 +0200
|
||||||
|
Subject: [PATCH] mkfs.fat: Fix calculation of FAT32 cluster size on non 512
|
||||||
|
bytes sector disks
|
||||||
|
|
||||||
|
Previous FAT32 calculation worked correctly only for disks with 512 byte
|
||||||
|
sectors. New calculation formula is generalized variant of previous one,
|
||||||
|
but to be sector size independent.
|
||||||
|
---
|
||||||
|
src/mkfs.fat.c | 12 ++++++------
|
||||||
|
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c
|
||||||
|
index ff89013..f7d8607 100644
|
||||||
|
--- a/src/mkfs.fat.c
|
||||||
|
+++ b/src/mkfs.fat.c
|
||||||
|
@@ -588,13 +588,13 @@ static void establish_params(struct device_info *info)
|
||||||
|
* fs size <= 16G: 8k clusters
|
||||||
|
* fs size <= 32G: 16k clusters
|
||||||
|
* fs size > 32G: 32k clusters
|
||||||
|
- *
|
||||||
|
- * This only works correctly for 512 byte sectors!
|
||||||
|
*/
|
||||||
|
- uint32_t sz_mb = info->size / (1024 * 1024);
|
||||||
|
- cluster_size =
|
||||||
|
- sz_mb > 32 * 1024 ? 64 : sz_mb > 16 * 1024 ? 32 : sz_mb >
|
||||||
|
- 8 * 1024 ? 16 : sz_mb > 260 ? 8 : 1;
|
||||||
|
+ unsigned long long int sectors = info->size / sector_size;
|
||||||
|
+ cluster_size = sectors > 32*1024*1024*2 ? 64 :
|
||||||
|
+ sectors > 16*1024*1024*2 ? 32 :
|
||||||
|
+ sectors > 8*1024*1024*2 ? 16 :
|
||||||
|
+ sectors > 260*1024*2 ? 8 : 1;
|
||||||
|
+
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info->geom_heads > 0) {
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: dosfstools
|
Name: dosfstools
|
||||||
Version: 4.1
|
Version: 4.1
|
||||||
Release: 12
|
Release: 13
|
||||||
Summary: FAT file system userspace tools
|
Summary: FAT file system userspace tools
|
||||||
License: GPLv3+
|
License: GPLv3+
|
||||||
URL: http://www.github.com/dosfstools/dosfstools
|
URL: http://www.github.com/dosfstools/dosfstools
|
||||||
@ -8,16 +8,17 @@ Source0: http://www.github.com/%{name}/%{name}/releases/download/v%{versi
|
|||||||
|
|
||||||
BuildRequires: gcc autoconf automake systemd-devel
|
BuildRequires: gcc autoconf automake systemd-devel
|
||||||
|
|
||||||
Patch0: 0000-Fix-signed-integer-overflow-in-FSTART.patch
|
Patch0: 0000-Fix-signed-integer-overflow-in-FSTART.patch
|
||||||
Patch1: 0001-Avoid-returning-deleted-directory-entries-as-labels.patch
|
Patch1: 0001-Avoid-returning-deleted-directory-entries-as-labels.patch
|
||||||
Patch2: 0002-src-check.c-Fix-up-mtools-created-bad-dir-entries.patch
|
Patch2: 0002-src-check.c-Fix-up-mtools-created-bad-dir-entries.patch
|
||||||
Patch3: 0003-Remove-long-file-name-when-changing-short-file-name.patch
|
Patch3: 0003-Remove-long-file-name-when-changing-short-file-name.patch
|
||||||
Patch4: 0004-Fix-gcc-sprintf-length-warnings.patch
|
Patch4: 0004-Fix-gcc-sprintf-length-warnings.patch
|
||||||
Patch5: 0005-fsck.fat-Fix-Year-2038-Bug.patch
|
Patch5: 0005-fsck.fat-Fix-Year-2038-Bug.patch
|
||||||
Patch6: 0006-mkfs.fat-Fix-parsing-of-block-number.patch
|
Patch6: 0006-mkfs.fat-Fix-parsing-of-block-number.patch
|
||||||
Patch7: 0007-device_info-Fix-parsing-partition-number.patch
|
Patch7: 0007-device_info-Fix-parsing-partition-number.patch
|
||||||
Patch8: 0008-Fix-memory-leaks-in-read_fat-function.patch
|
Patch8: 0008-Fix-memory-leaks-in-read_fat-function.patch
|
||||||
Patch9: 0009-Turn-label-in-struct-DOS_FS-into-char-array-from-poi.patch
|
Patch9: 0009-Turn-label-in-struct-DOS_FS-into-char-array-from-poi.patch
|
||||||
|
Patch10: 0010-mkfs.fat-Fix-calculation-of-FAT32-cluster-size-on-no.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
The dosfstools package contains programs mkfs.fat, fsck.fat and fatlabel to
|
The dosfstools package contains programs mkfs.fat, fsck.fat and fatlabel to
|
||||||
@ -54,6 +55,9 @@ make check
|
|||||||
%{_mandir}/man8/*
|
%{_mandir}/man8/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Nov 30 2023 wuguanghao <wuguanghao3@huawei.com> - 4.1-13
|
||||||
|
- mkfs.fat: Fix calculation of FAT32 cluster size on no 512 bytes sector disks
|
||||||
|
|
||||||
* Tue Jul 5 2022 zhanchengbin <zhanchengbin1@huawei.com> - 4.1-12
|
* Tue Jul 5 2022 zhanchengbin <zhanchengbin1@huawei.com> - 4.1-12
|
||||||
- fix execution successd when format a disk with partitions.
|
- fix execution successd when format a disk with partitions.
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user