parted/always-resize-part.dif

71 lines
2.6 KiB
Plaintext

--- parted/parted.c
+++ parted/parted.c 2006/03/22 10:06:03
@@ -1573,7 +1573,7 @@
{
PedDisk *disk;
PedPartition *part = NULL;
- PedFileSystem *fs;
+ PedFileSystem *fs = NULL;
PedConstraint *constraint;
PedSector start, end;
PedGeometry *range_start = NULL, *range_end = NULL;
@@ -1610,21 +1610,38 @@
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;
- constraint = constraint_intersect_and_destroy (
- ped_file_system_get_resize_constraint (fs),
- constraint_from_start_end (
- *dev, range_start, range_end));
+ 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))
- goto error_close_fs;
- /* may have changed... eg fat16 -> fat32 */
- ped_partition_set_system (part, fs->type);
- ped_file_system_close (fs);
+ 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);
@@ -1637,7 +1654,8 @@
return 1;
error_close_fs:
- ped_file_system_close (fs);
+ if (fs)
+ ped_file_system_close (fs);
error_destroy_constraint:
ped_constraint_destroy (constraint);
error_destroy_disk: