3
Copyright (C) 1998-2001, 2007-2012 Free Software Foundation, Inc.
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 3 of the License, or
8
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#include <uuid/uuid.h>
26
fat_alloc (const PedGeometry* geom)
30
fs = (PedFileSystem*) ped_malloc (sizeof (PedFileSystem));
34
fs->type_specific = (FatSpecific*) ped_malloc (sizeof (FatSpecific));
35
if (!fs->type_specific)
38
fs->geom = ped_geometry_duplicate (geom);
40
goto error_free_type_specific;
45
error_free_type_specific:
46
free (fs->type_specific);
54
fat_free (PedFileSystem* fs)
56
ped_geometry_destroy (fs->geom);
57
free (fs->type_specific);
62
fat_probe (PedGeometry* geom, FatType* fat_type)
68
fs = fat_alloc (geom);
71
fs_info = (FatSpecific*) fs->type_specific;
73
if (!fat_boot_sector_read (&fs_info->boot_sector, geom))
75
if (!fat_boot_sector_analyse (&fs_info->boot_sector, fs))
78
*fat_type = fs_info->fat_type;
79
result = ped_geometry_new (geom->dev, geom->start,
80
fs_info->sector_count);
92
fat_probe_fat16 (PedGeometry* geom)
95
PedGeometry* probed_geom = fat_probe (geom, &fat_type);
98
if (fat_type == FAT_TYPE_FAT16)
100
ped_geometry_destroy (probed_geom);
106
fat_probe_fat32 (PedGeometry* geom)
109
PedGeometry* probed_geom = fat_probe (geom, &fat_type);
112
if (fat_type == FAT_TYPE_FAT32)
114
ped_geometry_destroy (probed_geom);
119
static PedFileSystemOps fat16_ops = {
120
probe: fat_probe_fat16,
123
static PedFileSystemOps fat32_ops = {
124
probe: fat_probe_fat32,
127
#define FAT_BLOCK_SIZES ((int[2]){512, 0})
129
PedFileSystemType fat16_type = {
133
block_sizes: FAT_BLOCK_SIZES
136
PedFileSystemType fat32_type = {
140
block_sizes: FAT_BLOCK_SIZES
144
ped_file_system_fat_init ()
146
if (sizeof (FatBootSector) != 512) {
147
ped_exception_throw (PED_EXCEPTION_BUG, PED_EXCEPTION_CANCEL,
148
_("GNU Parted was miscompiled: the FAT boot sector "
149
"should be 512 bytes. FAT support will be disabled."));
151
ped_file_system_type_register (&fat16_type);
152
ped_file_system_type_register (&fat32_type);
157
ped_file_system_fat_done ()
159
ped_file_system_type_unregister (&fat16_type);
160
ped_file_system_type_unregister (&fat32_type);