summaryrefslogtreecommitdiffstats
path: root/daemon/sfdisk.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2009-07-02 21:50:30 +0100
committerRichard W.M. Jones <rjones@redhat.com>2009-07-02 21:50:30 +0100
commitb2c76a898b9d6fff09af05e4e3bd1d54c8816a95 (patch)
tree8113fa4be8bd379a7064c1c5bf9aafcb9a113a9f /daemon/sfdisk.c
parentc95f61b0a2e273c9376fe92c58ef6c4914d4ef17 (diff)
downloadlibguestfs-b2c76a898b9d6fff09af05e4e3bd1d54c8816a95.tar.gz
libguestfs-b2c76a898b9d6fff09af05e4e3bd1d54c8816a95.tar.xz
libguestfs-b2c76a898b9d6fff09af05e4e3bd1d54c8816a95.zip
Add 'sfdiskM' command.
This command is a saner interface to partitioning. All partition sizes are specified in megabytes (not cylinders). You don't need to specify the cyls/heads/secs parameters. All the test code has been updated to use this, so it is now CHS-independent (eg. when CHS changes as between IDE and virtio).
Diffstat (limited to 'daemon/sfdisk.c')
-rw-r--r--daemon/sfdisk.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/daemon/sfdisk.c b/daemon/sfdisk.c
index 5fb30c0e..f1726fc9 100644
--- a/daemon/sfdisk.c
+++ b/daemon/sfdisk.c
@@ -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);
@@ -82,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
@@ -91,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 *