X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fsfdisk.c;h=e06d0bf0cdb6f2cad643502fefcd15b0e67286a4;hb=98bc29fda446f5c667f4bc799161b3446bfc2ca1;hp=5fb30c0eaabcefcab7840a808d4f8da1b3b2ffab;hpb=99e28249d52ca5495b636e14ae3e4387ee62c8fe;p=libguestfs.git diff --git a/daemon/sfdisk.c b/daemon/sfdisk.c index 5fb30c0..e06d0bf 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,7 +31,8 @@ static int sfdisk (char *device, int n, int cyls, int heads, int sectors, - char * const* const lines) + const char *extra_flag, + char * const* const lines) { FILE *fp; char buf[256]; @@ -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); @@ -80,18 +85,24 @@ sfdisk (char *device, int n, int cyls, int heads, int sectors, int do_sfdisk (char *device, int cyls, int heads, int sectors, - char **lines) + char **lines) { - return sfdisk (device, 0, cyls, heads, sectors, lines); + return sfdisk (device, 0, cyls, heads, sectors, NULL, lines); } int do_sfdisk_N (char *device, int n, int cyls, int heads, int sectors, - char *line) + char *line) { 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 *