X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fsfdisk.c;h=f512e26b1b52191d0a2c512defd171ddd8e8b7b9;hp=6ff2736fc8f418b540d3308f0c25281d1125adac;hb=58e7e42033b1ac5044ae03f0aa5d5082c5fdb497;hpb=fe27753ae5925cbe50042e47115364a57aadbbd7 diff --git a/daemon/sfdisk.c b/daemon/sfdisk.c index 6ff2736..f512e26 100644 --- a/daemon/sfdisk.c +++ b/daemon/sfdisk.c @@ -1,5 +1,5 @@ /* libguestfs - the guestfsd daemon - * Copyright (C) 2009 Red Hat Inc. + * Copyright (C) 2009 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ static int sfdisk (char *device, int n, int cyls, int heads, int sectors, + const char *extra_flag, char * const* const lines) { FILE *fp; @@ -40,6 +41,7 @@ sfdisk (char *device, int n, int cyls, int heads, int sectors, IS_DEVICE (device, -1); strcpy (buf, "/sbin/sfdisk"); + if (n > 0) sprintf (buf + strlen (buf), " -N %d", n); if (cyls) @@ -48,6 +50,9 @@ sfdisk (char *device, int n, int cyls, int heads, int sectors, sprintf (buf + strlen (buf), " -H %d", heads); if (sectors) sprintf (buf + strlen (buf), " -S %d", sectors); + if (extra_flag) + sprintf (buf + strlen (buf), " %s", extra_flag); + /* Safe because of IS_DEVICE above: */ sprintf (buf + strlen (buf), " %s", device); @@ -73,6 +78,8 @@ sfdisk (char *device, int n, int cyls, int heads, int sectors, return -1; } + udev_settle (); + return 0; } @@ -80,7 +87,7 @@ int do_sfdisk (char *device, int cyls, int heads, int sectors, char **lines) { - return sfdisk (device, 0, cyls, heads, sectors, lines); + return sfdisk (device, 0, cyls, heads, sectors, NULL, lines); } int @@ -89,7 +96,13 @@ do_sfdisk_N (char *device, int n, int cyls, int heads, int sectors, { const char *lines[2] = { line, NULL }; - return sfdisk (device, n, cyls, heads, sectors, lines); + return sfdisk (device, n, cyls, heads, sectors, NULL, lines); +} + +int +do_sfdiskM (char *device, char **lines) +{ + return sfdisk (device, 0, 0, 0, 0, "-uM", lines); } static char * @@ -110,6 +123,8 @@ sfdisk_flag (char *device, const char *flag) free (err); + udev_settle (); + return out; /* caller frees */ }