gnome-format r12 - trunk/src



Author: mkanis
Date: Mon Apr  6 12:36:17 2009
New Revision: 12
URL: http://svn.gnome.org/viewvc/gnome-format?rev=12&view=rev

Log:
Create partition table if necessary. This fixes bug 575411.

Modified:
   trunk/src/gnome-format-partition.c

Modified: trunk/src/gnome-format-partition.c
==============================================================================
--- trunk/src/gnome-format-partition.c	(original)
+++ trunk/src/gnome-format-partition.c	Mon Apr  6 12:36:17 2009
@@ -53,13 +53,22 @@
 
         PedDevice *device;
         PedDisk *disk;
+        PedDiskType *label_type;
         PedFileSystemType *fs_type;
         PedPartition *part;
         
         ped_exception_set_handler(parted_exception_handler);
         
         try(device = ped_device_get(block_dev));
-        try(disk = ped_disk_new(device));
+        disk = ped_disk_new(device);
+        
+        if (disk == NULL) {
+                if(error_message) g_free(error_message);
+                error_message = NULL;
+                try(disk = ped_disk_new_fresh(device, ped_disk_type_get ("msdos")));
+        }
+        
+        // TODO bail out if disk still is NULL
         
         int last_part_num = ped_disk_get_last_partition_num(disk);
         if (last_part_num != -1) {
@@ -81,7 +90,7 @@
         try(ped_disk_commit_to_dev(disk));
         
         // this needs root priviliges
-//        try(ped_disk_commit_to_os(disk));
+        try(ped_disk_commit_to_os(disk));
 
 #ifdef DEBUG
         printf("device.sector_size: %lld\n", device->sector_size);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]