Here's my final patch. This one fixes the two fixme's in partkit.c, one for getting a list of devices, the other for getting a default. I just use the first device returned as the default. michael -- michael cardenas | lead software engineer | lindows.com | hyperpoem.net "When you understand one thing through and through, you understand everything." - Shunryu Suzuki
--- partkit.c.orig Tue Aug 27 08:23:42 2002
+++ partkit.c Tue Aug 27 19:11:27 2002
@@ -406,28 +406,88 @@
}
+char *partkit_get_devices(PedDevice *dev)
+{
+ char *ptr = 0;
+ int drivelistlen = 0;
+
+ ped_device_probe_all();
+
+ //mbc - unfortunately, do two passes for now to do the malloc...
+ while((dev = ped_device_get_next(dev)))
+ {
+ drivelistlen += strlen(dev->path);
+ drivelistlen += 2;
+ }
+
+ if(drivelistlen)
+ {
+ ptr = (char *)malloc(drivelistlen);
+
+ if(ptr)
+ {
+ *ptr = 0;
+ dev = NULL;
+
+ while((dev = ped_device_get_next(dev)))
+ {
+ if(*ptr == 0)
+ strcpy(ptr, dev->path);
+ else if (*ptr != 0)
+ {
+ strcat(ptr, ", ");
+ strcat(ptr, dev->path);
+ }
+ }
+ }
+
+ }
+
+ return ptr;
+
+}
+
+//mbc - for now, just use the first device
+char *partkit_get_default_device(void)
+{
+ PedDevice *dev = NULL;
+ char *ptr = 0;
+
+ dev = ped_device_get_next(dev);
+
+ ptr = (char *)malloc(strlen(dev->path));
+
+ strcpy(ptr, dev->path);
+
+ return ptr;
+}
int
main (int argc, char *argv[])
{
int finished = 0;
PedDevice *dev = NULL;
- char *ptr;
+ char *ptr = 0;
client = debconfclient_new ();
client->command (client, "title", "Partition Editor", NULL);
+ //mbc - should install an exception handler here
+ ped_init();
+
do
{
- /* FIXME: how to get a list of available devices ? */
- ptr = /* get_device_list() */ "/dev/hdb";
-
+ ptr = partkit_get_devices(dev);
client->command (client, "subst", "partkit/select_device", "choices",
ptr, NULL);
- /*FIXME: how to get a default device? */
+ free(ptr);
+
+ ptr = partkit_get_default_device();
+
client->command (client, "subst", "partkit/select_device", "default",
ptr, NULL);
+ free(ptr);
if ((dev = ped_device_get (argv[1])) == NULL)
partkit_error (1);
@@ -452,6 +512,8 @@
finished = 1;
}
while (!finished);
+
+ ped_done();
return 0;
}
Attachment:
pgpZ89FU8PaBZ.pgp
Description: PGP signature