git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Regression test: Test reopening the handle in the same process.
[libguestfs.git]
/
daemon
/
sfdisk.c
diff --git
a/daemon/sfdisk.c
b/daemon/sfdisk.c
index
95f04af
..
f512e26
100644
(file)
--- a/
daemon/sfdisk.c
+++ b/
daemon/sfdisk.c
@@
-1,5
+1,5
@@
/* libguestfs - the guestfsd daemon
/* 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
*
* 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,
static int
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 (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 (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,17
+68,18
@@
sfdisk (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;
}
return 0;
}
@@
-81,7
+87,7
@@
int
do_sfdisk (char *device, int cyls, int heads, int sectors,
char **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
@@
-90,7
+96,13
@@
do_sfdisk_N (char *device, int n, int cyls, int heads, int sectors,
{
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 *
@@
-111,6
+123,8
@@
sfdisk_flag (char *device, const char *flag)
free (err);
free (err);
+ udev_settle ();
+
return out; /* caller frees */
}
return out; /* caller frees */
}