Fixed mkfs.fat cluster size calculation for disks with 4k sectors
This commit is contained in:
parent
07624ad5c2
commit
604c66a540
@ -0,0 +1,30 @@
|
||||
diff --git a/src/mkfs.fat.c b/src/mkfs.fat.c
|
||||
index 5843550..29fbf55 100644
|
||||
--- a/src/mkfs.fat.c
|
||||
+++ b/src/mkfs.fat.c
|
||||
@@ -507,6 +507,7 @@ static void establish_params(struct device_info *info)
|
||||
unsigned int heads = 255;
|
||||
unsigned int media = 0xf8;
|
||||
unsigned int cluster_size = 4; /* starting point for FAT12 and FAT16 */
|
||||
+ unsigned int sector_size_mult = 1; /* x 512 == sector_size */
|
||||
int def_root_dir_entries = 512;
|
||||
|
||||
if (info->size < 512 * 1024 * 1024) {
|
||||
@@ -580,11 +581,15 @@ static void establish_params(struct device_info *info)
|
||||
* fs size > 32G: 32k clusters
|
||||
*
|
||||
* This only works correctly for 512 byte sectors!
|
||||
+ * For other sector sizes it tries to approximate.
|
||||
*/
|
||||
uint32_t sz_mb = info->size / (1024 * 1024);
|
||||
+ if (info->sector_size > 0)
|
||||
+ sector_size_mult = info->sector_size / 512;
|
||||
cluster_size =
|
||||
- sz_mb > 32 * 1024 ? 64 : sz_mb > 16 * 1024 ? 32 : sz_mb >
|
||||
- 8 * 1024 ? 16 : sz_mb > 260 ? 8 : 1;
|
||||
+ sz_mb > 32 * 1024 * sector_size_mult ? 64 : sz_mb >
|
||||
+ 16 * 1024 * sector_size_mult ? 32 : sz_mb >
|
||||
+ 8 * 1024 * sector_size_mult ? 16 : sz_mb > 260 * sector_size_mult ? 8 : 1;
|
||||
}
|
||||
|
||||
if (info->geom_heads > 0) {
|
||||
@ -1,10 +1,12 @@
|
||||
Name: dosfstools
|
||||
Summary: Utilities for making and checking MS-DOS FAT filesystems on Linux
|
||||
Version: 4.1
|
||||
Release: 6%{?dist}
|
||||
Release: 7%{?dist}
|
||||
License: GPLv3+
|
||||
Source0: http://github.com/%{name}/%{name}/releases/download/v%{version}/%{name}-%{version}.tar.xz
|
||||
URL: http://github.com/dosfstools/dosfstools
|
||||
# https://github.com/dosfstools/dosfstools/issues/111
|
||||
Patch0: dosfstools-4.1-fix-cluster-size-auto-detect-for-4k-disks.patch
|
||||
|
||||
BuildRequires: gcc
|
||||
|
||||
@ -15,6 +17,7 @@ drives or on floppies.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1 -b .fix-cluster-size-auto-detect-for-4k-disks
|
||||
|
||||
%build
|
||||
%configure --enable-compat-symlinks
|
||||
@ -31,6 +34,9 @@ make DESTDIR=%{buildroot} install PREFIX=%{_prefix}
|
||||
|
||||
|
||||
%changelog
|
||||
* Wed Jan 9 2019 Jaroslav Škarvada <jskarvad@redhat.com> - 4.1-7
|
||||
- Fixed mkfs.fat cluster size calculation for disks with 4k sectors
|
||||
|
||||
* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.1-6
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user