parted/always-resize-part.dif

64 lines
2.5 KiB
Plaintext

Index: parted/parted.c
===================================================================
--- parted/parted.c.orig 2009-07-30 16:28:06.000000000 +0200
+++ parted/parted.c 2009-07-30 16:28:07.000000000 +0200
@@ -1779,7 +1779,7 @@ do_resize (PedDevice** dev)
{
PedDisk *disk;
PedPartition *part = NULL;
- PedFileSystem *fs;
+ PedFileSystem *fs = NULL;
PedConstraint *constraint;
PedSector start, end;
PedGeometry *range_start = NULL, *range_end = NULL;
@@ -1816,22 +1816,39 @@ do_resize (PedDevice** dev)
goto error_destroy_constraint;
ped_partition_set_system (part, NULL);
} else {
+ int always_resize = getenv( "YAST_IS_RUNNING" ) != NULL;
+ const char* fsname = "";
+ if( always_resize )
+ {
+ PedFileSystemType* fst = ped_file_system_probe( &part->geom );
+ if( fst )
+ fsname = fst->name;
+ }
fs = ped_file_system_open (&part->geom);
- if (!fs)
+ if (!fs && (!always_resize || strncmp(fsname,"fat",3)==0) )
goto error_destroy_disk;
+ if (fs)
constraint = constraint_intersect_and_destroy (
ped_file_system_get_resize_constraint (fs),
constraint_from_start_end (
*dev, range_start, range_end));
+ else
+ {
+ new_geom.start = part->geom.start;
+ constraint = ped_constraint_exact(&new_geom);
+ }
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, g_timer))
+ if(fs)
+ {
+ if (!ped_file_system_resize (fs, &part->geom, g_timer) && !always_resize )
goto error_close_fs;
/* may have changed... eg fat16 -> fat32 */
ped_partition_set_system (part, fs->type);
ped_file_system_close (fs);
}
+ }
ped_disk_commit (disk);
ped_constraint_destroy (constraint);
@@ -1847,6 +1864,7 @@ do_resize (PedDevice** dev)
return 1;
error_close_fs:
+ if (fs)
ped_file_system_close (fs);
error_destroy_constraint:
ped_constraint_destroy (constraint);