git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
touch fakeroot.log
[libguestfs.git]
/
daemon
/
sfdisk.c
diff --git
a/daemon/sfdisk.c
b/daemon/sfdisk.c
index
2f5206e
..
f1726fc
100644
(file)
--- a/
daemon/sfdisk.c
+++ b/
daemon/sfdisk.c
@@
-30,7
+30,8
@@
#include "actions.h"
static int
#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,
+ const char *extra_flag,
char * const* const lines)
{
FILE *fp;
char * const* const lines)
{
FILE *fp;
@@
-40,6
+41,7
@@
sfdisk (const char *device, int n, int cyls, int heads, int sectors,
IS_DEVICE (device, -1);
strcpy (buf, "/sbin/sfdisk");
IS_DEVICE (device, -1);
strcpy (buf, "/sbin/sfdisk");
+
if (n > 0)
sprintf (buf + strlen (buf), " -N %d", n);
if (cyls)
if (n > 0)
sprintf (buf + strlen (buf), " -N %d", n);
if (cyls)
@@
-48,6
+50,9
@@
sfdisk (const 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);
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);
/* Safe because of IS_DEVICE above: */
sprintf (buf + strlen (buf), " %s", device);
@@
-63,38
+68,45
@@
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);
for (i = 0; lines[i] != NULL; ++i) {
if (fprintf (fp, "%s\n", lines[i]) < 0) {
reply_with_perror (buf);
-
f
close (fp);
+
p
close (fp);
return -1;
}
}
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;
}
return -1;
}
+ udev_settle ();
+
return 0;
}
int
return 0;
}
int
-do_sfdisk (c
onst c
har *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);
+ return sfdisk (device, 0, cyls, heads, sectors,
NULL,
lines);
}
int
}
int
-do_sfdisk_N (c
onst c
har *device, int n, int cyls, int heads, int sectors,
- c
onst c
har *line)
+do_sfdisk_N (char *device, int n, int cyls, int heads, int sectors,
+ char *line)
{
const char *lines[2] = { line, NULL };
{
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 *
}
static char *
-sfdisk_flag (c
onst c
har *device, const char *flag)
+sfdisk_flag (char *device, const char *flag)
{
char *out, *err;
int r;
{
char *out, *err;
int r;
@@
-111,23
+123,25
@@
sfdisk_flag (const char *device, const char *flag)
free (err);
free (err);
+ udev_settle ();
+
return out; /* caller frees */
}
char *
return out; /* caller frees */
}
char *
-do_sfdisk_l (c
onst c
har *device)
+do_sfdisk_l (char *device)
{
return sfdisk_flag (device, "-l");
}
char *
{
return sfdisk_flag (device, "-l");
}
char *
-do_sfdisk_kernel_geometry (c
onst c
har *device)
+do_sfdisk_kernel_geometry (char *device)
{
return sfdisk_flag (device, "-g");
}
char *
{
return sfdisk_flag (device, "-g");
}
char *
-do_sfdisk_disk_geometry (c
onst c
har *device)
+do_sfdisk_disk_geometry (char *device)
{
return sfdisk_flag (device, "-G");
}
{
return sfdisk_flag (device, "-G");
}