git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Version 1.10.10.
[libguestfs.git]
/
daemon
/
swap.c
diff --git
a/daemon/swap.c
b/daemon/swap.c
index
67d553a
..
99fb563
100644
(file)
--- a/
daemon/swap.c
+++ b/
daemon/swap.c
@@
-23,11
+23,16
@@
#include <string.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>
-#include "
../src/
guestfs_protocol.h"
+#include "guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
#include "optgroups.h"
#include "daemon.h"
#include "actions.h"
#include "optgroups.h"
+#include "ignore-value.h"
+
+/* Confirmed this is true for Linux swap partitions from the Linux sources. */
+#define SWAP_LABEL_MAX 16
+
/* Convenient place to test for the later version of e2fsprogs
* and util-linux which supports -U parameters to specify UUIDs.
* (Not supported in RHEL 5).
/* Convenient place to test for the later version of e2fsprogs
* and util-linux which supports -U parameters to specify UUIDs.
* (Not supported in RHEL 5).
@@
-39,7
+44,7
@@
optgroup_linuxfsuuid_available (void)
int av;
/* Ignore return code - mkswap --help *will* fail. */
int av;
/* Ignore return code - mkswap --help *will* fail. */
-
command (NULL, &err, "mkswap", "--help", NULL
);
+
ignore_value (command (NULL, &err, "mkswap", "--help", NULL)
);
av = strstr (err, "-U") != NULL;
free (err);
av = strstr (err, "-U") != NULL;
free (err);
@@
-77,6
+82,12
@@
do_mkswap (const char *device)
int
do_mkswap_L (const char *label, const char *device)
{
int
do_mkswap_L (const char *label, const char *device)
{
+ if (strlen (label) > SWAP_LABEL_MAX) {
+ reply_with_error ("%s: Linux swap labels are limited to %d bytes",
+ label, SWAP_LABEL_MAX);
+ return -1;
+ }
+
return mkswap (device, "-L", label);
}
return mkswap (device, "-L", label);
}
@@
-122,6
+133,11
@@
swaponoff (const char *cmd, const char *flag, const char *value)
free (err);
free (err);
+ /* Possible fix for RHBZ#516096. It probably doesn't hurt to do
+ * this in any case.
+ */
+ udev_settle ();
+
return 0;
}
return 0;
}
@@
-174,12
+190,24
@@
do_swapoff_file (const char *path)
int
do_swapon_label (const char *label)
{
int
do_swapon_label (const char *label)
{
+ if (strlen (label) > SWAP_LABEL_MAX) {
+ reply_with_error ("%s: Linux swap labels are limited to %d bytes",
+ label, SWAP_LABEL_MAX);
+ return -1;
+ }
+
return swaponoff ("swapon", "-L", label);
}
int
do_swapoff_label (const char *label)
{
return swaponoff ("swapon", "-L", label);
}
int
do_swapoff_label (const char *label)
{
+ if (strlen (label) > SWAP_LABEL_MAX) {
+ reply_with_error ("%s: Linux swap labels are limited to %d bytes",
+ label, SWAP_LABEL_MAX);
+ return -1;
+ }
+
return swaponoff ("swapoff", "-L", label);
}
return swaponoff ("swapoff", "-L", label);
}