X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fsfdisk.c;h=5fb30c0eaabcefcab7840a808d4f8da1b3b2ffab;hb=99e28249d52ca5495b636e14ae3e4387ee62c8fe;hp=2f5206edd96a6bb4a63771a89b21528ee457d440;hpb=85ed8cef99c19b4143844991d14e0b848fecc5da;p=libguestfs.git diff --git a/daemon/sfdisk.c b/daemon/sfdisk.c index 2f5206e..5fb30c0 100644 --- a/daemon/sfdisk.c +++ b/daemon/sfdisk.c @@ -30,7 +30,7 @@ #include "actions.h" static int -sfdisk (const char *device, int n, int cyls, int heads, int sectors, +sfdisk (char *device, int n, int cyls, int heads, int sectors, char * const* const lines) { FILE *fp; @@ -63,30 +63,31 @@ sfdisk (const char *device, int n, int cyls, int heads, int sectors, for (i = 0; lines[i] != NULL; ++i) { if (fprintf (fp, "%s\n", lines[i]) < 0) { reply_with_perror (buf); - fclose (fp); + pclose (fp); return -1; } } - if (fclose (fp) == EOF) { - reply_with_perror (buf); - fclose (fp); + if (pclose (fp) != 0) { + reply_with_error ("%s: external command failed", buf); return -1; } + udev_settle (); + return 0; } int -do_sfdisk (const char *device, int cyls, int heads, int sectors, - char * const* const lines) +do_sfdisk (char *device, int cyls, int heads, int sectors, + char **lines) { return sfdisk (device, 0, cyls, heads, sectors, lines); } int -do_sfdisk_N (const char *device, int n, int cyls, int heads, int sectors, - const char *line) +do_sfdisk_N (char *device, int n, int cyls, int heads, int sectors, + char *line) { const char *lines[2] = { line, NULL }; @@ -94,7 +95,7 @@ do_sfdisk_N (const char *device, int n, int cyls, int heads, int sectors, } static char * -sfdisk_flag (const char *device, const char *flag) +sfdisk_flag (char *device, const char *flag) { char *out, *err; int r; @@ -111,23 +112,25 @@ sfdisk_flag (const char *device, const char *flag) free (err); + udev_settle (); + return out; /* caller frees */ } char * -do_sfdisk_l (const char *device) +do_sfdisk_l (char *device) { return sfdisk_flag (device, "-l"); } char * -do_sfdisk_kernel_geometry (const char *device) +do_sfdisk_kernel_geometry (char *device) { return sfdisk_flag (device, "-g"); } char * -do_sfdisk_disk_geometry (const char *device) +do_sfdisk_disk_geometry (char *device) { return sfdisk_flag (device, "-G"); }