git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
daemon/Win32: Add contributed test script to test daemon using Wine.
[libguestfs.git]
/
daemon
/
lvm.c
diff --git
a/daemon/lvm.c
b/daemon/lvm.c
index
40377f1
..
564517c
100644
(file)
--- a/
daemon/lvm.c
+++ b/
daemon/lvm.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
@@
-22,17
+22,25
@@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <ctype.h>
#include "daemon.h"
#include "daemon.h"
+#include "c-ctype.h"
#include "actions.h"
#include "actions.h"
+#include "optgroups.h"
+
+int
+optgroup_lvm2_available (void)
+{
+ int r = access ("/sbin/lvm", X_OK);
+ return r == 0;
+}
/* LVM actions. Keep an eye on liblvm, although at the time
* of writing it hasn't progressed very far.
*/
static char **
/* LVM actions. Keep an eye on liblvm, although at the time
* of writing it hasn't progressed very far.
*/
static char **
-convert_lvm_output (char *out, char *prefix)
+convert_lvm_output (char *out, c
onst c
har *prefix)
{
char *p, *pend;
char **r = NULL;
{
char *p, *pend;
char **r = NULL;
@@
-49,12
+57,12
@@
convert_lvm_output (char *out, char *prefix)
pend++;
}
pend++;
}
- while (*p &&
isspace (*p))
/* Skip any leading whitespace. */
+ while (*p &&
c_isspace (*p))
/* Skip any leading whitespace. */
p++;
/* Sigh, skip trailing whitespace too. "pvs", I'm looking at you. */
len = strlen (p)-1;
p++;
/* Sigh, skip trailing whitespace too. "pvs", I'm looking at you. */
len = strlen (p)-1;
- while (*p && isspace (p[len]))
+ while (*p &&
c_
isspace (p[len]))
p[len--] = '\0';
if (!*p) { /* Empty line? Skip it. */
p[len--] = '\0';
if (!*p) { /* Empty line? Skip it. */
@@
-93,7
+101,7
@@
do_pvs (void)
int r;
r = command (&out, &err,
int r;
r = command (&out, &err,
- "/sbin/lvm", "pvs", "-o", "pv_name", "--noheadings", NULL);
+
"/sbin/lvm", "pvs", "-o", "pv_name", "--noheadings", NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (out);
if (r == -1) {
reply_with_error ("%s", err);
free (out);
@@
-113,7
+121,7
@@
do_vgs (void)
int r;
r = command (&out, &err,
int r;
r = command (&out, &err,
- "/sbin/lvm", "vgs", "-o", "vg_name", "--noheadings", NULL);
+
"/sbin/lvm", "vgs", "-o", "vg_name", "--noheadings", NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (out);
if (r == -1) {
reply_with_error ("%s", err);
free (out);
@@
-133,9
+141,9
@@
do_lvs (void)
int r;
r = command (&out, &err,
int r;
r = command (&out, &err,
- "/sbin/lvm", "lvs",
- "-o", "vg_name,lv_name", "--noheadings",
- "--separator", "/", NULL);
+
"/sbin/lvm", "lvs",
+
"-o", "vg_name,lv_name", "--noheadings",
+
"--separator", "/", NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (out);
if (r == -1) {
reply_with_error ("%s", err);
free (out);
@@
-152,19
+160,19
@@
do_lvs (void)
* the code. That code is in stubs.c, and it is generated as usual
* by generator.ml.
*/
* the code. That code is in stubs.c, and it is generated as usual
* by generator.ml.
*/
-guestfs_
lvm_int
_pv_list *
+guestfs_
int_lvm
_pv_list *
do_pvs_full (void)
{
return parse_command_line_pvs ();
}
do_pvs_full (void)
{
return parse_command_line_pvs ();
}
-guestfs_
lvm_int
_vg_list *
+guestfs_
int_lvm
_vg_list *
do_vgs_full (void)
{
return parse_command_line_vgs ();
}
do_vgs_full (void)
{
return parse_command_line_vgs ();
}
-guestfs_
lvm_int
_lv_list *
+guestfs_
int_lvm
_lv_list *
do_lvs_full (void)
{
return parse_command_line_lvs ();
do_lvs_full (void)
{
return parse_command_line_lvs ();
@@
-177,7
+185,7
@@
do_pvcreate (const char *device)
int r;
r = command (NULL, &err,
int r;
r = command (NULL, &err,
- "/sbin/lvm", "pvcreate", device, NULL);
+
"/sbin/lvm", "pvcreate", device, NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
@@
-185,11
+193,14
@@
do_pvcreate (const char *device)
}
free (err);
}
free (err);
+
+ udev_settle ();
+
return 0;
}
int
return 0;
}
int
-do_vgcreate (const char *volgroup, char *
const* const
physvols)
+do_vgcreate (const char *volgroup, char *
const *
physvols)
{
char *err;
int r, argc, i;
{
char *err;
int r, argc, i;
@@
-207,7
+218,7
@@
do_vgcreate (const char *volgroup, char * const* const physvols)
for (i = 3; i <= argc; ++i)
argv[i] = physvols[i-3];
for (i = 3; i <= argc; ++i)
argv[i] = physvols[i-3];
- r = commandv (NULL, &err, argv);
+ r = commandv (NULL, &err,
(const char * const*)
argv);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
@@
-215,6
+226,9
@@
do_vgcreate (const char *volgroup, char * const* const physvols)
}
free (err);
}
free (err);
+
+ udev_settle ();
+
return 0;
}
return 0;
}
@@
-228,8
+242,8
@@
do_lvcreate (const char *logvol, const char *volgroup, int mbytes)
snprintf (size, sizeof size, "%d", mbytes);
r = command (NULL, &err,
snprintf (size, sizeof size, "%d", mbytes);
r = command (NULL, &err,
- "/sbin/lvm", "lvcreate",
- "-L", size, "-n", logvol, volgroup, NULL);
+
"/sbin/lvm", "lvcreate",
+
"-L", size, "-n", logvol, volgroup, NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
@@
-237,6
+251,9
@@
do_lvcreate (const char *logvol, const char *volgroup, int mbytes)
}
free (err);
}
free (err);
+
+ udev_settle ();
+
return 0;
}
return 0;
}
@@
-247,13
+264,11
@@
do_lvresize (const char *logvol, int mbytes)
int r;
char size[64];
int r;
char size[64];
- IS_DEVICE (logvol, -1);
-
snprintf (size, sizeof size, "%d", mbytes);
r = command (NULL, &err,
snprintf (size, sizeof size, "%d", mbytes);
r = command (NULL, &err,
- "/sbin/lvm", "lvresize",
- "-L", size, logvol, NULL);
+
"/sbin/lvm", "lvresize",
+
"-L", size, logvol, NULL);
if (r == -1) {
reply_with_error ("lvresize: %s", err);
free (err);
if (r == -1) {
reply_with_error ("lvresize: %s", err);
free (err);
@@
-325,6
+340,8
@@
do_lvm_remove_all (void)
}
free_strings (xs);
}
free_strings (xs);
+ udev_settle ();
+
/* There, that was easy, sorry about your data. */
return 0;
}
/* There, that was easy, sorry about your data. */
return 0;
}
@@
-336,7
+353,7
@@
do_lvremove (const char *device)
int r;
r = command (NULL, &err,
int r;
r = command (NULL, &err,
- "/sbin/lvm", "lvremove", "-f", device, NULL);
+
"/sbin/lvm", "lvremove", "-f", device, NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
@@
-344,6
+361,9
@@
do_lvremove (const char *device)
}
free (err);
}
free (err);
+
+ udev_settle ();
+
return 0;
}
return 0;
}
@@
-354,7
+374,7
@@
do_vgremove (const char *device)
int r;
r = command (NULL, &err,
int r;
r = command (NULL, &err,
- "/sbin/lvm", "vgremove", "-f", device, NULL);
+
"/sbin/lvm", "vgremove", "-f", device, NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
@@
-362,6
+382,9
@@
do_vgremove (const char *device)
}
free (err);
}
free (err);
+
+ udev_settle ();
+
return 0;
}
return 0;
}
@@
-372,7
+395,7
@@
do_pvremove (const char *device)
int r;
r = command (NULL, &err,
int r;
r = command (NULL, &err,
- "/sbin/lvm", "pvremove", "-ff", device, NULL);
+
"/sbin/lvm", "pvremove", "-ff", device, NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
@@
-380,6
+403,9
@@
do_pvremove (const char *device)
}
free (err);
}
free (err);
+
+ udev_settle ();
+
return 0;
}
return 0;
}
@@
-390,7
+416,7
@@
do_pvresize (const char *device)
int r;
r = command (NULL, &err,
int r;
r = command (NULL, &err,
- "/sbin/lvm", "pvresize", device, NULL);
+
"/sbin/lvm", "pvresize", device, NULL);
if (r == -1) {
reply_with_error ("pvresize: %s: %s", device, err);
free (err);
if (r == -1) {
reply_with_error ("pvresize: %s: %s", device, err);
free (err);
@@
-402,7
+428,7
@@
do_pvresize (const char *device)
}
int
}
int
-do_vg_activate (int activate, char *
const* const
volgroups)
+do_vg_activate (int activate, char *
const *
volgroups)
{
char *err;
int r, i, argc;
{
char *err;
int r, i, argc;
@@
-422,7
+448,7
@@
do_vg_activate (int activate, char * const* const volgroups)
for (i = 4; i <= argc; ++i)
argv[i] = volgroups[i-4];
for (i = 4; i <= argc; ++i)
argv[i] = volgroups[i-4];
- r = commandv (NULL, &err, argv);
+ r = commandv (NULL, &err,
(const char * const*)
argv);
if (r == -1) {
reply_with_error ("vgchange: %s", err);
free (err);
if (r == -1) {
reply_with_error ("vgchange: %s", err);
free (err);
@@
-430,6
+456,9
@@
do_vg_activate (int activate, char * const* const volgroups)
}
free (err);
}
free (err);
+
+ udev_settle ();
+
return 0;
}
return 0;
}