/*
libparted
Copyright (C) 1998-2000, 2002, 2004, 2007, 2009-2010 Free Software
Foundation, Inc.
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include "fat.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
/* Reads in the boot sector (superblock), and does a minimum of sanity
* checking. The goals are:
* - to detect fat file systems, even if they are damaged [i.e. not
* return an error / throw an exception]
* - to fail detection if there's not enough information for
* fat_boot_sector_probe_type() to work (or possibly crash on a divide-by-zero)
*/
int
{
return 0;
_("File system has an invalid signature for a FAT "
"file system."));
return 0;
}
_("File system has an invalid signature for a FAT "
"file system."));
return 0;
}
if (!bs->sector_size
_("File system has an invalid sector size for a FAT "
"file system."));
return 0;
}
if (!bs->cluster_size) {
_("File system has an invalid cluster size for a FAT "
"file system."));
return 0;
}
_("File system has an invalid number of reserved "
"sectors for a FAT file system."));
return 0;
}
_("File system has an invalid number of FATs."));
return 0;
}
return 1;
}
/*
Don't trust the FAT12, FAT16 or FAT32 label string.
*/
{
return FAT_TYPE_FAT32;
/ (512 / sizeof (FatDirEntry));
if (cluster_count > MAX_FAT12_CLUSTERS)
return FAT_TYPE_FAT16;
else
return FAT_TYPE_FAT12;
}
/* Analyses the boot sector, and sticks appropriate numbers in
fs->type_specific.
Note: you need to subtract (2 * cluster_sectors) off cluster offset,
because the first cluster is number 2. (0 and 1 are not real clusters,
and referencing them is a bug)
*/
int
{
int fat_entry_size;
if (ped_exception_throw (
_("This file system has a logical sector size of %d. "
"GNU Parted is known not to work properly with sector "
"sizes other than 512 bytes."),
return 0;
}
int cyl_count = 0;
switch (ped_exception_throw (
_("The file system's CHS geometry is (%d, %d, %d), "
"which is invalid. The partition table's CHS "
"geometry is (%d, %d, %d). If you select Ignore, "
"the file system's CHS geometry will be left "
"unchanged. If you select Fix, the file system's "
"CHS geometry will be set to match the partition "
"table's CHS geometry."),
case PED_EXCEPTION_FIX:
return 0;
break;
case PED_EXCEPTION_CANCEL:
return 0;
case PED_EXCEPTION_IGNORE:
break;
default:
break;
}
}
else
if (fs_info->logical_sector_size == 0) {
_("FAT boot sector says logical sector size is 0. "
"This is weird. "));
return 0;
}
if (fs_info->fat_table_count == 0) {
_("FAT boot sector says there are no FAT tables. This "
"is weird. "));
return 0;
}
if (fs_info->cluster_sectors == 0) {
_("FAT boot sector says clusters are 0 sectors. This "
"is weird. "));
return 0;
}
_("File system is FAT12, which is unsupported."));
return 0;
}
fs_info->root_cluster = 0;
}
fs_info->root_dir_offset = 0;
fs_info->root_dir_sector_count = 0;
}
return 1;
}
#ifndef DISCOVER_ONLY
int
{
return 1;
}
int
{
: 0;
} else {
bs->sector_count = 0;
}
bs->fat_length = 0;
} else {
}
return 1;
}
int
{
return 0;
return 0;
}
}
int
{
int status;
return 0;
_("The information sector has the wrong "
"signature (%x). Select cancel for now, "
"and send in a bug report. If you're "
"desperate, it's probably safe to ignore."),
if (status == PED_EXCEPTION_CANCEL) return 0;
}
return 1;
}
int
{
return 1;
}
int
{
return 0;
}
#endif /* !DISCOVER_ONLY */