1
From 3d8df854148da2c5178f5a286bbef6db26c0a9d7 Mon Sep 17 00:00:00 2001
1
From ba9dd9e3bf56f3f6650f8dd45edc219ba666ef60 Mon Sep 17 00:00:00 2001
2
2
From: Phillip Susi <psusi@ubuntu.com>
3
3
Date: Sun, 6 Apr 2014 19:13:07 -0400
4
4
Subject: Fix fat and ntfs detection on non 512 byte sectors
7
7
code to differentiate between those filesystem boot sectors and an msdos
8
8
MBR, but the code crashed with non 512 byte sector sizes.
10
Last-Update: 2014-04-08
10
Last-Update: 2014-04-14
12
12
Patch-Name: fat-ntfs-large-sectors.patch
14
libparted/fs/fat/bootsector.c | 23 ++++++-----------------
15
libparted/fs/fat/bootsector.h | 2 +-
16
libparted/fs/fat/fat.c | 42 ++++++++++++++++++++++++------------------
14
libparted/fs/fat/bootsector.c | 31 +++++++++++--------------------
15
libparted/fs/fat/bootsector.h | 4 ++--
16
libparted/fs/fat/fat.c | 40 +++++++++++++++++++++++-----------------
17
17
libparted/fs/fat/fat.h | 4 ++--
18
18
libparted/fs/fat/resize.c | 8 ++++----
19
19
libparted/fs/fat/table.c | 4 ++--
20
20
libparted/fs/ntfs/ntfs.c | 10 +++++-----
21
7 files changed, 44 insertions(+), 49 deletions(-)
21
7 files changed, 49 insertions(+), 52 deletions(-)
23
23
diff --git a/libparted/fs/fat/bootsector.c b/libparted/fs/fat/bootsector.c
24
index b987918..5e75561 100644
24
index b987918..30891fa 100644
25
25
--- a/libparted/fs/fat/bootsector.c
26
26
+++ b/libparted/fs/fat/bootsector.c
27
27
@@ -36,13 +36,14 @@
74
74
* fs_info->logical_sector_size;
75
75
fs_info->root_cluster
76
76
= PED_LE32_TO_CPU (bs->u.fat32.root_dir_cluster);
77
@@ -395,15 +384,17 @@ fat_boot_sector_write (const FatBootSector* bs, PedFileSystem* fs)
81
-fat_info_sector_read (FatInfoSector* is, const PedFileSystem* fs)
82
+fat_info_sector_read (FatInfoSector** isp, const PedFileSystem* fs)
84
FatSpecific* fs_info = FAT_SPECIFIC (fs);
87
- PED_ASSERT (is != NULL, return 0);
88
+ PED_ASSERT (isp != NULL, return 0);
90
- if (!ped_geometry_read (fs->geom, is, fs_info->info_sector_offset, 1))
91
+ if (!ped_geometry_read_alloc (fs->geom, (void **)isp,
92
+ fs_info->info_sector_offset, 1))
94
+ FatInfoSector *is = *isp;
96
if (PED_LE32_TO_CPU (is->signature_2) != FAT32_INFO_MAGIC2) {
97
status = ped_exception_throw (PED_EXCEPTION_WARNING,
77
98
diff --git a/libparted/fs/fat/bootsector.h b/libparted/fs/fat/bootsector.h
78
index 5a12fdf..6f743f1 100644
99
index 5a12fdf..f063e94 100644
79
100
--- a/libparted/fs/fat/bootsector.h
80
101
+++ b/libparted/fs/fat/bootsector.h
81
102
@@ -117,7 +117,7 @@ struct __attribute__ ((packed)) _FatInfoSector {
85
106
-int fat_boot_sector_read (FatBootSector* bs, const PedGeometry* geom);
86
+int fat_boot_sector_read (FatBootSector** bs, const PedGeometry* geom);
107
+int fat_boot_sector_read (FatBootSector** bsp, const PedGeometry* geom);
87
108
FatType fat_boot_sector_probe_type (const FatBootSector* bs,
88
109
const PedGeometry* geom);
89
110
int fat_boot_sector_analyse (FatBootSector* bs, PedFileSystem* fs);
111
@@ -125,7 +125,7 @@ int fat_boot_sector_set_boot_code (FatBootSector* bs);
112
int fat_boot_sector_generate (FatBootSector* bs, const PedFileSystem* fs);
113
int fat_boot_sector_write (const FatBootSector* bs, PedFileSystem* fs);
115
-int fat_info_sector_read (FatInfoSector* is, const PedFileSystem* fs);
116
+int fat_info_sector_read (FatInfoSector** isp, const PedFileSystem* fs);
117
int fat_info_sector_generate (FatInfoSector* is, const PedFileSystem* fs);
118
int fat_info_sector_write (const FatInfoSector* is, PedFileSystem* fs);
90
120
diff --git a/libparted/fs/fat/fat.c b/libparted/fs/fat/fat.c
91
index efc8d79..53dd361 100644
121
index efc8d79..25083c0 100644
92
122
--- a/libparted/fs/fat/fat.c
93
123
+++ b/libparted/fs/fat/fat.c
94
124
@@ -35,7 +35,9 @@ fat_alloc (const PedGeometry* geom)
153
@@ -222,13 +228,13 @@ fat_open (PedGeometry* geom)
183
@@ -222,7 +228,7 @@ fat_open (PedGeometry* geom)
155
185
if (!fat_boot_sector_read (&fs_info->boot_sector, geom))
156
186
goto error_free_fs;
159
189
goto error_free_fs;
160
190
fs->type = (fs_info->fat_type == FAT_TYPE_FAT16)
163
if (fs_info->fat_type == FAT_TYPE_FAT32) {
164
- if (!fat_info_sector_read (&fs_info->info_sector, fs))
165
+ if (!fat_info_sector_read (fs_info->info_sector, fs))
169
192
@@ -377,16 +383,16 @@ fat_create (PedGeometry* geom, FatType fat_type, PedTimer* timer)
171
194
fs_info->serial_number = _gen_new_serial_number ();