/*
libparted
Copyright (C) 1998-2000, 2002, 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"
#ifndef DISCOVER_ONLY
/* returns the minimum size of clusters for a given file system type */
switch (fat_type) {
case FAT_TYPE_FAT12: return 1;
}
return 0;
}
static PedSector
{
result *= 2;
return result;
}
/* returns the minimum size of clusters for a given file system type */
switch (fat_type) {
case FAT_TYPE_FAT12: return 1;
case FAT_TYPE_FAT32:
}
return 0;
}
/* returns the maxmimum size of clusters for a given file system type */
switch (fat_type) {
}
return 0;
}
/* returns the minimum number of clusters for a given file system type */
switch (fat_type) {
case FAT_TYPE_FAT12:
case FAT_TYPE_FAT16:
case FAT_TYPE_FAT32: return 0xfff0;
}
return 0;
}
/* returns the maximum number of clusters for a given file system type */
switch (fat_type) {
case FAT_TYPE_FAT12: return 0xff0;
case FAT_TYPE_FAT16: return 0xfff0;
case FAT_TYPE_FAT32: return 0x0ffffff0;
}
return 0;
}
/* what is this supposed to be? What drugs are M$ on? (Can I have some? :-) */
{
}
int
const PedGeometry* geom,
{
return 0);
if (free_space < min_free_space) {
_("You need %s of free disk space to shrink this "
"partition to this size. Currently, only %s is "
"free."),
return 0;
}
return 1;
}
/******************************************************************************/
/* DO NOT EDIT THIS ALGORITHM!
* As far as I can tell, this is the same algorithm used by Microsoft to
* calculate the size of the file allocaion tables, and the number of clusters.
* I have not verified this by dissassembling Microsoft code - I came to this
* conclusion by empirical analysis (i.e. trial and error - this was HORRIBLE).
*
* If you think this code makes no sense, then you are right. I will restrain
* the urge to inflict serious bodily harm on Microsoft people.
*/
static int
{
switch (fat_type) {
case FAT_TYPE_FAT12:
return 512 * 3 / 2;
case FAT_TYPE_FAT16:
return 512 / 2;
case FAT_TYPE_FAT32:
return 512 / 4;
}
return 0;
}
static int
{
int i;
- align;
if (fat_type == FAT_TYPE_FAT16)
fat_space = 0;
for (i = 0; i < 2; i++) {
if (fat_type == FAT_TYPE_FAT32)
else
}
/* looks like this should be part of the loop condition?
* Need to build the Big Table TM again to check
*/
entries_per_sector (fat_type))) {
}
return 0;
return 1;
}
/****************************************************************************/
int
{
cluster_sectors *= 2) {
return 1;
}
}
cluster_sectors /= 2) {
return 1;
}
}
/* only make the cluster size really small (<4k) if a bigger one is
* isn't possible. Windows never makes FS's like this, but it
* seems to work... (do more tests!)
*/
return 1;
}
}
return 0;
}
/* Same as fat_calc_sizes, except it only attempts to match a particular
* cluster size. This is useful, because the FAT resizer can only shrink the
* cluster size.
*/
int
const PedGeometry* geom,
{
/* libparted can only reduce the cluster size at this point */
for (*out_cluster_sectors = cluster_sectors;
*out_cluster_sectors /= 2) {
return 1;
}
return 0;
}
/* Calculates the number of sectors needed to be added to cluster_offset,
to make the cluster on the new file system match up with the ones
on the old file system.
However, some space is reserved by fat_calc_resize_sizes() and
friends, to allow room for this space. If too much of this space is left
over, everyone will complain, so we have to be greedy, and use it all up...
*/
const PedFileSystem* old_fs)
{
else
% new_fs_info->cluster_sectors ))
<= new_data_size)
return align;
}
int
{
}
{
return 0);
}
{
}
{
}
{
}
{
return 0);
}
{
+ 2;
}
#endif /* !DISCOVER_ONLY */