/*
clear_fat - a tool to clear unused space (for testing purposes)
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
FatSpecific* fs_info = FAT_SPECIFIC (fs);
switch (fs_info->fat_type) {
+ case FAT_TYPE_FAT12:
+ PED_ASSERT (0, (void) 0);
+ break;
+
case FAT_TYPE_FAT16:
return cluster * 2;
struct stat dev_stat;
int dev_major;
int dev_minor;
- PedExceptionOption ex_status;
if (!_device_stat (dev, &dev_stat))
return 0;
ped_exception_catch ();
case PED_EXCEPTION_IGNORE:
dev->model = strdup(_("Generic IDE"));
+ break;
+ default:
+ PED_ASSERT (0, (void) 0);
+ break;
}
} else {
/* hdi.model is not guaranteed to be NULL terminated */
case PED_EXCEPTION_UNHANDLED:
ped_exception_catch ();
case PED_EXCEPTION_IGNORE:
- ;
+ break;
+ default:
+ PED_ASSERT (0, (void) 0);
+ break;
}
}
init_dasd (PedDevice* dev, char* model_name)
{
struct stat dev_stat;
- PedExceptionOption ex_status;
- dasd_information_t dasd_info;
struct hd_geometry geo;
- int f, blksize = 0;
char *errstr = 0;
if (!_device_stat (dev, &dev_stat))
ped_device_close (dev);
return 1;
-except:
ped_exception_throw ( PED_EXCEPTION_ERROR,
PED_EXCEPTION_IGNORE_CANCEL,
errstr );
case PED_EXCEPTION_UNHANDLED:
ped_exception_catch ();
case PED_EXCEPTION_IGNORE:
- ; // just workaround for gcc 3.0
+ break;
+ default:
+ PED_ASSERT (0, (void) 0);
+ break;
}
/* what should we stick in here? */
&& start + count - 1 == dev->length - 1)
return ped_device_read (dev, buffer, start, count - 1)
&& _read_lastoddsector (
- dev, buffer + (count-1) * 512);
+ dev, (char *) buffer + (count-1) * 512);
}
while (1) {
if (_device_seek (dev, start))
ped_exception_catch ();
case PED_EXCEPTION_CANCEL:
return 0;
+ default:
+ PED_ASSERT (0, (void) 0);
+ break;
}
}
if (status == count * dev->sector_size) break;
if (status > 0) {
read_length -= status;
- buffer += status;
+ buffer = (char *) buffer + status;
continue;
}
case PED_EXCEPTION_CANCEL:
free(diobuf);
return 0;
+ default:
+ PED_ASSERT (0, (void) 0);
+ break;
}
}
free(diobuf);
&& start + count - 1 == dev->length - 1)
return ped_device_write (dev, buffer, start, count - 1)
&& _write_lastoddsector (
- dev, buffer + (count-1) * 512);
+ dev, (char*) buffer + (count-1) * 512);
}
while (1) {
if (_device_seek (dev, start))
ped_exception_catch ();
case PED_EXCEPTION_CANCEL:
return 0;
+ default:
+ PED_ASSERT (0, (void) 0);
+ break;
}
}
if (status == count * dev->sector_size) break;
if (status > 0) {
write_length -= status;
- diobuf += status;
+ diobuf = (char *) diobuf + status;
continue;
}
case PED_EXCEPTION_CANCEL:
free(diobuf_start);
return 0;
+ default:
+ PED_ASSERT (0, (void) 0);
+ break;
}
}
free(diobuf_start);
ped_exception_catch ();
case PED_EXCEPTION_CANCEL:
return 0;
+ default:
+ PED_ASSERT (0, (void) 0);
+ break;
}
}
return 1;
/*
libparted - a library for manipulating disk partitions
- Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
PedSector min_start;
PedSector max_start;
PedGeometry start_min_max_range;
- PedGeometry* result;
if (constraint->min_size > constraint->max_size)
return NULL;
/*
libparted - a library for manipulating disk partitions
- Copyright (C) 1999, 2000, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2005, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
ped_geometry_read (const PedGeometry* geom, void* buffer, PedSector start,
PedSector count)
{
- int exception_status;
PedSector real_start;
PED_ASSERT (geom != NULL, return 0);
/*
libparted - a library for manipulating disk partitions
- Copyright (C) 2000, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2005, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#if HAVE_BACKTRACE
/* Print backtrace stack */
void *stack[20];
- size_t size;
char **strings, **string;
-
- size = backtrace(stack, 20);
+ int size = backtrace(stack, 20);
strings = backtrace_symbols(stack, size);
if (strings) {
/*
libparted - a library for manipulating disk partitions
- Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2007
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
disk->part_list = NULL;
return disk;
-error_free_disk:
ped_free (disk);
error:
return NULL;
int
ped_partition_set_system (PedPartition* part, const PedFileSystemType* fs_type)
{
- PedFileSystem* fs;
const PedDiskType* disk_type;
PED_ASSERT (part != NULL, return 0);
error_pop_update_mode:
_disk_pop_update_mode (disk);
-error:
ped_constraint_destroy (overlap_constraint);
ped_constraint_destroy (constraints);
part->geom = old_geom;
/*
libparted - a library for manipulating disk partitions
- Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
error_close_dev:
ped_device_close (dev);
-error:
return 0;
}
/*
affs.c -- parted support for affs file systems
- Copyright (C) 1998-2000 Free Software Foundation, Inc.
+ Copyright (C) 1998-2000, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
_generic_affs_probe (PedGeometry* geom, uint32_t kind)
{
uint32_t *block;
- int32_t i;
PedSector root, len, pos;
struct PartitionBlock * part;
int blocksize = 1, reserved = 2, prealloc = 0;
/*
libparted/fs_amiga - amiga file system support.
- Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
# define _(String) (String)
#endif /* ENABLE_NLS */
-/* String manipulation */
-static void _amiga_set_bstr (const char *cstr, char *bstr, int maxsize) {
- int size = strlen (cstr);
- int i;
-
- if (size >= maxsize) return;
- bstr[0] = size;
- for (i = 0; i<size; i++) bstr[i+1] = cstr[i];
-}
-static const char * _amiga_get_bstr (char * bstr) {
- char * cstr = bstr + 1;
- int size = bstr[0];
-
- cstr[size] = '\0';
- return cstr;
-}
-
#define IDNAME_RIGIDDISK (uint32_t)0x5244534B /* 'RDSK' */
#define IDNAME_BADBLOCK (uint32_t)0x42414442 /* 'BADB' */
#define IDNAME_PARTITION (uint32_t)0x50415254 /* 'PART' */
return "<unknown>";
}
}
-static int
-_amiga_valid_block_id (uint32_t id) {
- switch (id) {
- case IDNAME_RIGIDDISK :
- case IDNAME_BADBLOCK :
- case IDNAME_PARTITION :
- case IDNAME_FILESYSHEADER :
- case IDNAME_LOADSEG :
- case IDNAME_BOOT :
- return 1;
- case IDNAME_FREE :
- default :
- return 0;
- }
-}
struct AmigaIds *
_amiga_add_id (uint32_t id, struct AmigaIds *ids) {
/*
apfs.c -- parted support for apfs file systems
- Copyright (C) 1998-2000 Free Software Foundation, Inc.
+ Copyright (C) 1998-2000, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
_generic_apfs_probe (PedGeometry* geom, uint32_t kind)
{
uint32_t *block;
- int32_t i, sum;
PedSector root;
struct PartitionBlock * part;
uint32_t blocksize = 1, reserved = 2, prealloc = 0;
/*
asfs.c -- parted asfs filesystem support
- Copyright (C) 1998-2000 Free Software Foundation, Inc.
+ Copyright (C) 1998-2000, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
uint32_t *block;
struct PartitionBlock * part;
int blocksize = 1, reserved = 1, prealloc = 1;
- PedSector root, root2;
- int found = 0;
+ PedSector root;
+ int found = 0;
PED_ASSERT (geom != NULL, return NULL);
PED_ASSERT (geom->dev != NULL, return NULL);
/*
ext2.c -- generic ext2 stuff
- Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
fs->metadirty = 0;
return fs;
-error_free_gd:
ped_free(fs->gd);
error_deinit_bcache:
ext2_bcache_deinit(fs);
/*
ext2_mkfs.c -- ext2 fs creator
- Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
error_free_zero:
ped_free(zero);
-error_free_ib:
ped_free(ib);
error_free_bb:
ped_free(bb);
/*
libparted
- Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2002, 2004, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
fat_boot_sector_analyse (FatBootSector* bs, PedFileSystem* fs)
{
FatSpecific* fs_info = FAT_SPECIFIC (fs);
- PedExceptionOption ex_status;
int fat_entry_size;
PED_ASSERT (bs != NULL, return 0);
case PED_EXCEPTION_IGNORE:
break;
+
+ default:
+ break;
}
}
/*
libparted
- Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2002, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
FatCluster* out_cluster_count,
PedSector* out_fat_size)
{
- PedSector min_cluster_sectors;
-
PED_ASSERT (geom != NULL, return 0);
PED_ASSERT (out_cluster_sectors != NULL, return 0);
PED_ASSERT (out_cluster_count != NULL, return 0);
/*
libparted
- Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
int
fat_duplicate_clusters (FatOpContext* ctx, PedTimer* timer)
{
- FatSpecific* old_fs_info = FAT_SPECIFIC (ctx->old_fs);
FatFragment total_frags_to_dup;
init_remap (ctx);
/*
libparted
- Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
prints out the sequence of clusters for a given file chain, beginning
at start_cluster.
*/
+#ifdef PED_VERBOSE
static void
print_chain (PedFileSystem* fs, FatCluster start)
{
}
printf ("\n");
}
+#endif /* PED_VERBOSE */
static PedSector
remainder_round_up (PedSector a, PedSector b)
char* file_name_start;
FatCluster first_cluster;
PedSector size;
- PedExceptionOption ex_status;
PED_ASSERT (trav_info != NULL, return 0);
#if 0
if (fat_dir_entry_is_system_file (this_entry)
&& !is_movable_system_file (file_name)) {
+ PedExceptionOption ex_status;
ex_status = ped_exception_throw (
PED_EXCEPTION_WARNING,
PED_EXCEPTION_IGNORE_CANCEL,
{
FatSpecific* fs_info = FAT_SPECIFIC (fs);
FatCluster cluster;
- FatFragment frag;
for (cluster = 2; cluster < fs_info->cluster_count + 2; cluster++) {
if (fat_table_is_bad (fs_info->fat, cluster))
/*
libparted
- Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
_init_fats (PedFileSystem* fs)
{
FatSpecific* fs_info = FAT_SPECIFIC (fs);
- int i;
FatCluster table_size;
table_size = fs_info->fat_sectors * 512
/*
libparted
- Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
if (new_fs_info->fat_type == old_fs_info->fat_type) {
switch (old_fs_info->fat_type) {
+ case FAT_TYPE_FAT12:
+ PED_ASSERT (0, (void) 0);
+ break;
+
case FAT_TYPE_FAT16:
return fat_construct_legacy_root (ctx);
case PED_EXCEPTION_CANCEL:
return 0;
+
+ default:
+ PED_ASSERT (0, (void) 0);
+ break;
}
}
FatType* out_fat_type)
{
FatSpecific* fs_info = FAT_SPECIFIC (fs);
- PedExceptionOption status;
PedSector fat16_cluster_sectors;
PedSector fat32_cluster_sectors;
FatCluster dummy_cluster_count;
/*
libparted
- Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
_test_code_bad (const FatTable* ft, FatCluster code)
{
switch (ft->fat_type) {
+ case FAT_TYPE_FAT12:
+ if (code == 0xff7) return 1;
+ break;
+
case FAT_TYPE_FAT16:
if (code == 0xfff7) return 1;
break;
}
static int
-_test_code_active (const FatTable* ft, FatCluster code)
-{
- return code && !_test_code_bad (ft, code);
-}
-
-static int
_test_code_eof (const FatTable* ft, FatCluster code)
{
switch (ft->fat_type) {
+ case FAT_TYPE_FAT12:
+ if (code >= 0xff7) return 1;
+ break;
+
case FAT_TYPE_FAT16:
if (code >= 0xfff7) return 1;
break;
_update_stats (ft, cluster, value);
switch (ft->fat_type) {
+ case FAT_TYPE_FAT12:
+ PED_ASSERT (0, (void) 0);
+ break;
+
case FAT_TYPE_FAT16:
((unsigned short *) ft->table) [cluster]
= PED_CPU_TO_LE16 (value);
}
switch (ft->fat_type) {
+ case FAT_TYPE_FAT12:
+ PED_ASSERT (0, (void) 0);
+ break;
+
case FAT_TYPE_FAT16:
return PED_LE16_TO_CPU
(((unsigned short *) ft->table) [cluster]);
{
switch (ft->fat_type) {
+ case FAT_TYPE_FAT12:
+ PED_ASSERT (0, (void) 0);
+ break;
+
case FAT_TYPE_FAT16:
return fat_table_set (ft, cluster, 0xfff8);
ft->bad_cluster_count++;
switch (ft->fat_type) {
+ case FAT_TYPE_FAT12:
+ return fat_table_set (ft, cluster, 0xff7);
+
case FAT_TYPE_FAT16:
return fat_table_set (ft, cluster, 0xfff7);
/*
libparted
- Copyright (C) 1998, 1999, 2000, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2005, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
FatSpecific* fs_info = FAT_SPECIFIC (fs);
switch (fs_info->fat_type) {
+ case FAT_TYPE_FAT12:
+ PED_ASSERT (0, (void) 0);
+ break;
+
case FAT_TYPE_FAT16:
dir_entry->first_cluster = PED_CPU_TO_LE16 (cluster);
break;
/*
libparted - a library for manipulating disk partitions
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
HfsPPrivateExtent phy_area;
HfsPPrivateFSData* priv_data = (HfsPPrivateFSData*)
file->fs->type_specific;
+ char *b = buf;
if (sector+nb < sector /* detect overflow */
|| sector+nb > file->sect_nb) /* out of file */ {
sector, PED_BE32_TO_CPU(file->CNID));
return 0;
}
- if (!ped_geometry_read(priv_data->plus_geom, buf,
+ if (!ped_geometry_read(priv_data->plus_geom, b,
phy_area.start_sector,
phy_area.sector_count))
return 0;
nb -= phy_area.sector_count; /* < nb anyway ... */
sector += phy_area.sector_count;
- buf += phy_area.sector_count * PED_SECTOR_SIZE_DEFAULT;
+ b += phy_area.sector_count * PED_SECTOR_SIZE_DEFAULT;
}
return 1;
HfsPPrivateExtent phy_area;
HfsPPrivateFSData* priv_data = (HfsPPrivateFSData*)
file->fs->type_specific;
+ char *b = buf;
if (sector+nb < sector /* detect overflow */
|| sector+nb > file->sect_nb) /* out of file */ {
sector, PED_BE32_TO_CPU(file->CNID));
return 0;
}
- if (!ped_geometry_write(priv_data->plus_geom, buf,
+ if (!ped_geometry_write(priv_data->plus_geom, b,
phy_area.start_sector,
phy_area.sector_count))
return 0;
nb -= phy_area.sector_count; /* < nb anyway ... */
sector += phy_area.sector_count;
- buf += phy_area.sector_count * PED_SECTOR_SIZE_DEFAULT;
+ b += phy_area.sector_count * PED_SECTOR_SIZE_DEFAULT;
}
return 1;
/*
libparted - a library for manipulating disk partitions
- Copyright (C) 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "reloc.h"
#include "advfs.h"
+static PedFileSystemType hfs_type;
+static PedFileSystemType hfsplus_type;
+
/* ----- HFS ----- */
static PedConstraint*
hfsplus_get_resize_constraint (const PedFileSystem *fs)
{
- HfsPPrivateFSData* priv_data = (HfsPPrivateFSData*)
- fs->type_specific;
PedDevice* dev = fs->geom->dev;
PedAlignment start_align;
PedGeometry start_sector;
HfsNodeDescriptor* node_desc = (HfsNodeDescriptor*) node;
HfsExtentKey* ret_key;
HfsExtDescriptor* ret_data;
- unsigned int i, j;
+ unsigned int i;
HfsPPrivateFSData* priv_data = (HfsPPrivateFSData*)
fs->type_specific;
HfsPrivateFSData* hfs_priv_data = (HfsPrivateFSData*)
#endif /* HFS_EXTRACT_FS */
-static PedFileSystemType hfs_type;
-static PedFileSystemType hfsplus_type;
-
/* ----------------------------------- */
/*
reiserfs.c -- libparted / libreiserfs glue
- Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
reiserfs_gauge_t *);
FCLASS int (FPTR reiserfs_fs_resize) (reiserfs_fs_t *, blk_t, reiserfs_gauge_t *);
+#ifdef HAVE_REISERFS_FS_CHECK
FCLASS int (FPTR reiserfs_fs_check) (reiserfs_fs_t *, reiserfs_gauge_t *);
+#endif
FCLASS reiserfs_fs_t *(FPTR reiserfs_fs_copy) (reiserfs_fs_t *, dal_t *,
reiserfs_gauge_t *);
geom_dal_free(dal);
error_fs_geom_free:
ped_geometry_destroy(fs_geom);
-error:
return NULL;
}
static int reiserfs_check(PedFileSystem *fs, PedTimer *timer)
{
reiserfs_fs_t *fs_info;
+#ifdef HAVE_REISERFS_FS_CHECK
reiserfs_gauge_t *gauge = NULL;
+#endif
PED_ASSERT(fs != NULL, return 0);
error_free_gauge:
if (gauge)
libreiserfs_gauge_free(gauge);
-error:
ped_geometry_set_end (fs->geom, fs->geom->start + old_length - 1);
return 0;
}
geom_dal_free(dal);
error_free_fs_geom:
ped_geometry_destroy(fs_geom);
-error:
return NULL;
}
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
libparted - a library for manipulating disk partitions
- Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
static int
aix_probe (const PedDevice *dev)
{
- PedDiskType* disk_type;
AixLabel label;
- int i;
PED_ASSERT (dev != NULL, return 0);
const PedFileSystemType* fs_type,
PedSector start, PedSector end)
{
- PedPartition* part;
-
ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
PED_EXCEPTION_CANCEL,
_("Support for adding partitions to AIX disk "
static PedPartition*
aix_partition_duplicate (const PedPartition* part)
{
- PedPartition* new_part;
-
ped_exception_throw (PED_EXCEPTION_NO_FEATURE,
PED_EXCEPTION_CANCEL,
_("Support for duplicating partitions in AIX "
}
return part;
-error_free_dos_data:
ped_free (dos_data);
error_free_part:
ped_free (part);
_best_solution (const PedPartition* part, const PedCHSGeometry* bios_geom,
PedGeometry* a, PedGeometry* b)
{
- PedDevice* dev = part->disk->dev;
PedSector cyl_size = bios_geom->heads * bios_geom->sectors;
int a_cylinder;
int b_cylinder;
const PedConstraint* constraint)
{
PedDisk* disk = part->disk;
- PedDevice* dev = disk->dev;
PedGeometry* min_geom = NULL;
PedGeometry* solution = NULL;
_logical_min_start_head (PedPartition* part, const PedCHSGeometry* bios_geom,
PedPartition* ext_part, int is_start_ext_part)
{
- PedDevice* dev = part->disk->dev;
PedSector cylinder_size = bios_geom->sectors * bios_geom->heads;
PedSector base_head;
const PedConstraint* constraint)
{
PedDisk* disk = part->disk;
- PedDevice* dev = disk->dev;
PedPartition* ext_part = ped_disk_extended_partition (disk);
PedSector cyl_size = bios_geom->sectors * bios_geom->heads;
PedSector start_base;
{
PedPartition* ext_part = ped_disk_extended_partition (disk);
PedPartition* prev = log_part->prev;
- PedDevice* dev = disk->dev;
PedCHSGeometry bios_geom;
PedSector cyl_size;
PedSector metadata_start;
/*
libparted - a library for manipulating disk partitions
- Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2005, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
error_destroy_constraint_any:
ped_constraint_destroy (constraint_any);
-error_destroy_volume_part:
ped_partition_destroy (volume_part);
error_free_disk_specific:
ped_free (disk->disk_specific);
return 1;
case PED_EXCEPTION_FIX:
write_back = 1;
+ break;
+ default:
+ break;
}
#endif
}
error_delete_all:
ped_disk_delete_all (disk);
-error:
return 0;
}
dvh_partition_is_flag_available (const PedPartition* part,
PedPartitionFlag flag)
{
- DVHDiskData* dvh_disk_data = part->disk->disk_specific;
-
switch (flag) {
case PED_PARTITION_ROOT:
case PED_PARTITION_SWAP:
ped_constraint_destroy (constraint_exact);
return 1;
-error_destroy_constraint:
ped_constraint_destroy (constraint_exact);
error_destroy_part:
ped_partition_destroy (part);
anc->partno[dsn] = pos;
}
-static void
-fdasd_check_volser (char *s, int devno)
-{
- PDEBUG
- int i, j;
-
- for (i = 0; i < 6; i++) {
- if ((s[i] < 0x20) || (s[i] > 0x7a)
- || ((s[i] >= 0x21) && (s[i] <= 0x22))
- || /* !" */ ((s[i] >= 0x26) && (s[i] <= 0x2f))
- || /* &'()*+,-./ */ ((s[i] >= 0x3a) && (s[i] <= 0x3f))
- || /* :;<=>? */ ((s[i] >= 0x5b) && (s[i] <= 0x60)))
- /* \]^_´ */ s[i] = ' ';
- s[i] = toupper (s[i]);
- }
-
- s[6] = 0x00;
-
- for (i = 0; i < 6; i++) {
- if (s[i] == ' ')
- for (j = i; j < 6; j++)
- if (s[j] != ' ') {
- s[i] = s[j];
- s[j] = ' ';
- break;
- }
- }
-
- if (s[0] == ' ') {
- printf ("Usage error, switching to default.\n");
- sprintf (s, "0X%04x", devno);
- for (i = 0; i < 6; i++)
- s[i] = toupper (s[i]);
- }
-}
-
void
fdasd_cleanup (fdasd_anchor_t *anchor)
{
+ p->hh * geo->sectors + p->b);
}
-static char *fdasd_partition_type (char *str)
-{
- PDEBUG
-
- if (strncmp("NATIVE", str, 6) == 0)
- strcpy(str, "Linux native");
- else if (strncmp("NEW ", str, 6) == 0)
- strcpy(str, "Linux native");
- else if (strncmp("SWAP ", str, 6) == 0)
- strcpy(str, "Linux swap");
- else if (strncmp("RAID ", str, 6) == 0)
- strcpy(str, "Linux Raid");
- else
- strcpy(str, "unknown");
-
- return str;
-}
-
/*
* initializes the anchor structure and allocates some
* memory for the labels
}
/*
- * call IOCTL to re-read the partition table
- */
-static void
-fdasd_reread_partition_table (fdasd_anchor_t * anc, int fd)
-{
- PDEBUG
- char str[LINE_LENGTH];
- int f;
-
- if (ioctl (fd, BLKRRPART, NULL) != 0)
- fdasd_error (anc, unable_to_ioctl, "Error while rereading "
- "partition table.\nPlease reboot!");
-}
-
-/*
* writes all changes to dasd
*/
static void
}
/*
- * changes the volume serial
- */
-static void
-fdasd_change_volser (fdasd_anchor_t *anc, char *line_ptr)
-{
- PDEBUG
- char str[10];
-
- if (strcmp(line_ptr, "") != 0) {
- int i;
-
- /* fill with blanks if necessary and remove the linebreak */
- i = strlen(line_ptr);
- if (i <= 6)
- strncpy(line_ptr + i - 1, " ", 6);
-
- strncpy(str, line_ptr, 6);
-
- for (i=0; i<6; i++) str[i] = toupper(str[i]);
- str[6] = 0x00;
-
- fdasd_check_volser (str, anc->devno);
- vtoc_volume_label_set_volser(anc->vlabel, str);
-
- vtoc_set_cchhb(&anc->vlabel->vtoc, 0x0000, 0x0001, 0x01);
- anc->vlabel_changed++;
- anc->vtoc_changed++;
- }
-}
-
-/*
* sets some important partition data
* (like used, start_trk, end_trk, len_trk)
* by calculating these values with the
unsigned int limit, cc, hh;
cchh_t llimit, ulimit;
partition_info_t *q;
- char mesg[48];
u_int8_t b1, b2;
u_int16_t c, h;
unsigned int start = *start_ptr, stop = *stop_ptr;
original version by Matt Domsch <Matt_Domsch@dell.com>
Disclaimed into the Public Domain
- Portions Copyright (C) 2001, 2002, 2003, 2005, 2006
+ Portions Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007
Free Software Foundation, Inc.
EFI GUID Partition Table handling
static void
swap_uuid_and_efi_guid(uuid_t uuid)
{
- int i;
efi_guid_t *guid = (efi_guid_t *)uuid;
PED_ASSERT(uuid != NULL, return);
uint8_t* zeroed_pth_raw = ped_malloc (pth_get_size (dev));
uint8_t* pth_raw = ped_malloc (pth_get_size (dev));
GuidPartitionTableHeader_t* gpt;
- GuidPartitionEntry_t ptes[GPT_DEFAULT_PARTITION_ENTRIES];
PED_ASSERT (dev != NULL, return 0);
GuidPartitionTableHeader_t* gpt;
PedPartition* part;
int ptes_size;
- unsigned int i;
PED_ASSERT (disk != NULL, goto error);
PED_ASSERT (disk->dev != NULL, goto error);
error_destroy_constraint:
ped_constraint_destroy (constraint_exact);
-error_destroy_part:
ped_partition_destroy (part);
error:
return 0;
/*
libparted - a library for manipulating disk partitions
- Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
static PedDisk*
loop_alloc (const PedDevice* dev)
{
- PedDisk* disk;
-
PED_ASSERT (dev != NULL, return 0);
if (dev->length < 256)
/*
libparted - a library for manipulating disk partitions
- Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2004, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
memcpy (new_mac_data, old_mac_data, sizeof (MacDiskData));
return new_disk;
-error_free_new_disk:
_ped_disk_free (new_disk);
error:
return NULL;
}
return part;
-error_free_mac_data:
ped_free (mac_data);
error_free_part:
ped_free (part);
static int
mac_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
{
- PedFileSystemType* hfs = ped_file_system_type_get ("hfs");
MacPartitionData* mac_data;
PED_ASSERT (part != NULL, return 0);
/*
libparted - a library for manipulating disk partitions
- Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
static PedDisk*
pc98_alloc (const PedDevice* dev)
{
- PedDisk* disk;
-
PED_ASSERT (dev != NULL, return 0);
return _ped_disk_alloc (dev, &pc98_disk_type);
}
return part;
-error_free_pc98_data:
ped_free (pc98_data);
error_free_part:
ped_free (part);
static int
pc98_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
{
- PedDisk* disk;
PC98PartitionData* pc98_data;
PED_ASSERT (part != NULL, return 0);
static int
sun_probe (const PedDevice *dev)
{
- PedDiskType* disk_type;
SunRawLabel label;
- int i;
PED_ASSERT (dev != NULL, return 0);
return part;
-error_free_sun_data:
ped_free (sun_data);
error_free_part:
ped_free (part);
/*
libparted - a library for manipulating disk partitions
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
error_free_copy:
ped_free (copy);
-error:
*sector = 0;
if (range)
*range = NULL;
/*
parted - a frontend to libparted
- Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
static char* resize_msg_start = N_("The partition must have one of the "
"following FS-TYPEs: ");
-static char* version_msg = N_("GNU Parted Version information:\n");
static char* copyright_msg = N_(
"Copyright (C) 1998 - 2006 Free Software Foundation, Inc.\n"
"This program is free software, covered by the GNU General Public License.\n"
static char* resize_fs_type_msg;
static Command* commands [256] = {NULL};
-static PedTimer* timer;
+static PedTimer* g_timer;
static TimerContext timer_context;
static int _print_list (int cli);
printf ("%s... ", timer->state_name);
printf (_("%0.f%%\t(time left %.2d:%.2d)"),
100.0 * timer->frac,
- tcontext->predicted_time_left / 60,
- tcontext->predicted_time_left % 60);
+ (int) (tcontext->predicted_time_left / 60),
+ (int) (tcontext->predicted_time_left % 60));
fflush (stdout);
}
PedDisk* disk;
PedFileSystem* fs;
PedPartition* part = NULL;
- int part_num;
disk = ped_disk_new (*dev);
if (!disk)
fs = ped_file_system_open (&part->geom);
if (!fs)
goto error_destroy_disk;
- if (!ped_file_system_check (fs, timer))
+ if (!ped_file_system_check (fs, g_timer))
goto error_close_fs;
ped_file_system_close (fs);
ped_disk_destroy (disk);
{
PedDisk* src_disk;
PedDisk* dst_disk;
- PedDevice* src_device;
PedPartition* src = NULL;
PedPartition* dst = NULL;
PedFileSystem* src_fs;
src_fs = ped_file_system_open (&src->geom);
if (!src_fs)
goto error_destroy_disk;
- dst_fs = ped_file_system_copy (src_fs, &dst->geom, timer);
+ dst_fs = ped_file_system_copy (src_fs, &dst->geom, g_timer);
if (!dst_fs)
goto error_close_src_fs;
dst_fs_type = dst_fs->type; /* may be different to src_fs->type */
if (!command_line_get_fs_type (_("File system?"), &type))
goto error_destroy_disk;
- fs = ped_file_system_create (&part->geom, type, timer);
+ fs = ped_file_system_create (&part->geom, type, g_timer);
if (!fs)
goto error_destroy_disk;
ped_file_system_close (fs);
error_remove_part:
ped_disk_remove_partition (disk, part);
-error_destroy_all_constraints:
ped_constraint_destroy (final_constraint);
error_destroy_simple_constraints:
ped_constraint_destroy (user_constraint);
ped_constraint_destroy (dev_constraint);
-error_destroy_part:
ped_partition_destroy (part);
error_destroy_disk:
ped_disk_destroy (disk);
ped_partition_set_flag (part, PED_PARTITION_LBA, 1);
/* fs creation */
- fs = ped_file_system_create (&part->geom, fs_type, timer);
+ fs = ped_file_system_create (&part->geom, fs_type, g_timer);
if (!fs)
goto error_destroy_disk;
ped_file_system_close (fs);
error_remove_part:
ped_disk_remove_partition (disk, part);
-error_destroy_all_constraints:
ped_constraint_destroy (final_constraint);
error_destroy_simple_constraints:
ped_constraint_destroy (user_constraint);
ped_constraint_destroy (dev_constraint);
-error_destroy_part:
ped_partition_destroy (part);
error_destroy_disk:
ped_disk_destroy (disk);
}
/* do the move */
- fs_copy = ped_file_system_copy (fs, &part->geom, timer);
+ fs_copy = ped_file_system_copy (fs, &part->geom, g_timer);
if (!fs_copy)
goto error_close_fs;
ped_file_system_close (fs_copy);
do_print (PedDevice** dev)
{
PedDisk* disk;
- PedPartition* part;
Table* table;
StrList* row;
int has_extended;
PED_DISK_TYPE_PARTITION_NAME);
+ PedPartition* part;
if (!opt_machine_mode) {
if (ped_unit_get_default() == PED_UNIT_CHS) {
return 1;
-error_destroy_disk:
ped_disk_destroy (disk);
error:
return 0;
switch (ex_opt) {
case PED_EXCEPTION_CANCEL: return -1;
case PED_EXCEPTION_NO: return 0;
+ default: break;
}
ped_partition_set_system (part, fs_type);
ped_geometry_init (&entire_dev, disk->dev, 0, disk->dev->length);
- ped_timer_reset (timer);
- ped_timer_set_state_name (timer, _("searching for file systems"));
+ ped_timer_reset (g_timer);
+ ped_timer_set_state_name (g_timer, _("searching for file systems"));
for (start = start_range->start; start <= start_range->end; start++) {
- ped_timer_update (timer, 1.0 * (start - start_range->start)
+ ped_timer_update (g_timer, 1.0 * (start - start_range->start)
/ start_range->length);
ped_geometry_init (&start_geom_exact, disk->dev, start, 1);
ped_partition_destroy (part);
ped_constraint_done (&constraint);
}
- ped_timer_update (timer, 1.0);
+ ped_timer_update (g_timer, 1.0);
return 1;
error_remove_partition:
ped_disk_remove_partition (disk, part);
-error_partition_destroy:
ped_partition_destroy (part);
-error_constraint_done:
ped_constraint_done (&constraint);
-error:
return 0;
}
if (!ped_disk_set_partition_geom (disk, part, constraint,
new_geom.start, new_geom.end))
goto error_close_fs;
- if (!ped_file_system_resize (fs, &part->geom, timer))
+ if (!ped_file_system_resize (fs, &part->geom, g_timer))
goto error_close_fs;
/* may have changed... eg fat16 -> fat32 */
ped_partition_set_system (part, fs->type);
*argc_ptr -= optind;
*argv_ptr += optind;
return 1;
-
-error:
-return 0;
}
static PedDevice*
if (!dev)
goto error_done_commands;
-timer = ped_timer_new (_timer_handler, &timer_context);
-if (!timer)
+g_timer = ped_timer_new (_timer_handler, &timer_context);
+if (!g_timer)
goto error_done_commands;
timer_context.last_update = 0;
error_done_commands:
_done_commands ();
_done_messages ();
-error_done_ui:
done_ui ();
error:
return NULL;
ped_device_close (dev);
-ped_timer_destroy (timer);
+ped_timer_destroy (g_timer);
_done_commands ();
_done_messages ();
done_ui();
sigjmp_buf jmp_state;
} readline_state;
-static PedExceptionOption current_exception_opt = 0;
-
static struct sigaction sig_segv;
static struct sigaction sig_int;
static struct sigaction sig_fpe;
_readline (const char* prompt, const StrList* possibilities)
{
char* line;
- int val;
readline_state.possibilities = possibilities;
readline_state.cur_pos = NULL;
command_line_get_disk_type (const char* prompt, const PedDiskType*(* value))
{
char* disk_type_name;
- PedDiskType* disk_type;
disk_type_name = command_line_get_word (prompt,
*value ? (*value)->name : NULL,
int
interactive_mode (PedDevice** dev, Command* cmd_list[])
{
- char* line;
StrList* list;
StrList* command_names = command_get_names (cmd_list);