[Lxc-users] [PATCH 1/1] lxc_clone.c: Allow size subfixes for -L parameter
zoolook
nbensa+lxcusers at gmail.com
Thu Jul 11 23:38:02 UTC 2013
lxc-clone ignores size subfixes (K, M, G) when using -L parameter. The
following is a quick patch to allow, for example, lxc-clone -L 10G.
Signed-off-by: Norberto Bensa <nbensa at gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
--- lxc.orig/lxc-0.9.0.0~staging~20130708-2041/src/lxc/lxc_clone.c
2013-07-08 17:46:33.000000000 -0300
+++ lxc.new/lxc-0.9.0.0~staging~20130708-2041/src/lxc/lxc_clone.c
2013-07-10 23:06:07.156501219 -0300
@@ -6,6 +6,7 @@
#include <sys/wait.h>
#include <stdlib.h>
#include <errno.h>
+#include <ctype.h>
#include "log.h"
#include "config.h"
@@ -16,6 +17,27 @@
lxc_log_define(lxc_clone, lxc);
+static unsigned long get_fssize(char *s)
+{
+ unsigned long ret;
+ char *end;
+
+ ret = strtoul(s, &end, 0);
+ if (end == s)
+ return 0;
+ while (isblank(*end))
+ end++;
+ if (!(*end))
+ return ret;
+ if (*end == 'g' || *end == 'G')
+ ret *= 1000000000;
+ else if (*end == 'm' || *end == 'M')
+ ret *= 1000000;
+ else if (*end == 'k' || *end == 'K')
+ ret *= 1000;
+ return ret;
+}
+
void usage(const char *me)
{
printf("Usage: %s [-s] [-B backingstore] [-L size] [-K] [-M]
[-H]\n", me);
@@ -73,7 +95,7 @@
switch (c) {
case 's': snapshot = 1; break;
case 'B': bdevtype = optarg; break;
- case 'L': newsize = atol(optarg); break;
+ case 'L': newsize = get_fssize(optarg); break;
case 'o': orig = optarg; break;
case 'n': new = optarg; break;
case 'v': vgname = optarg; break;
More information about the lxc-users
mailing list