echo_daemon is a simple echo which can be used to test connectivity between the
client and daemon.
---
 daemon/Makefile.am    |    1 +
 daemon/echo_daemon.c  |   66 +++++++++++++++++++++++++++++++++++++++++++++++++
 daemon/m4/stddef_h.m4 |   45 +++++++++++++++++++++++++++++++++
 po/POTFILES.in        |    1 +
 src/MAX_PROC_NR       |    2 +-
 src/generator.ml      |    7 +++++
 6 files changed, 121 insertions(+), 1 deletions(-)
 create mode 100644 daemon/echo_daemon.c
 create mode 100644 daemon/m4/stddef_h.m4
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 83ee408..ae74699 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -36,6 +36,7 @@ guestfsd_SOURCES = \
 	dmesg.c \
 	dropcaches.c \
 	du.c \
+	echo_daemon.c \
 	ext2.c \
 	fallocate.c \
 	file.c \
diff --git a/daemon/echo_daemon.c b/daemon/echo_daemon.c
new file mode 100644
index 0000000..dbede2f
--- /dev/null
+++ b/daemon/echo_daemon.c
@@ -0,0 +1,66 @@
+/* libguestfs - the guestfsd daemon
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include "actions.h"
+
+char *
+do_echo_daemon (char *const *argv)
+{
+  char *out = NULL;
+  size_t out_len = 0;
+
+  /* Iterate over argv entries until reaching the NULL terminator */
+  while (*argv) {
+    char add_space = 0;
+
+    /* Store the end of current output */
+    size_t out_end = out_len;
+
+    /* Calculate the new output size */
+    size_t arg_len = strlen(*argv);
+    out_len += arg_len;
+
+    /* We will prepend a space if this isn't the first argument added */
+    if (NULL != out) {
+      out_len++;
+      add_space = 1;
+    }
+
+    /* Make the output buffer big enough for the string and its terminator */
+    out = realloc (out, out_len + 1);
+
+    /* Prepend a space if required */
+    if (add_space) {
+      out[out_end++] = ' ';
+    }
+
+    /* Copy the argument to the output */
+    memcpy(&out[out_end], *argv, arg_len);
+
+    argv++;
+  }
+
+  /* NULL terminate the output */
+  out[out_len] = '\0';
+
+  return out;
+}
diff --git a/daemon/m4/stddef_h.m4 b/daemon/m4/stddef_h.m4
new file mode 100644
index 0000000..682e9c6
--- /dev/null
+++ b/daemon/m4/stddef_h.m4
@@ -0,0 +1,45 @@
+dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have
issues.
+# stddef_h.m4 serial 1
+dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_STDDEF_H],
+[
+  AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
+  AC_REQUIRE([gt_TYPE_WCHAR_T])
+  if test $gt_cv_c_wchar_t = no; then
+    HAVE_WCHAR_T=0
+    STDDEF_H=stddef.h
+  fi
+  AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions],
+    [gl_cv_decl_null_works],
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
+      int test[2 * (sizeof NULL == sizeof (void *)) -1];
+]])],
+      [gl_cv_decl_null_works=yes],
+      [gl_cv_decl_null_works=no])])
+  if test $gl_cv_decl_null_works = no; then
+    REPLACE_NULL=1
+    STDDEF_H=stddef.h
+  fi
+  if test -n "$STDDEF_H"; then
+    gl_CHECK_NEXT_HEADERS([stddef.h])
+  fi
+])
+
+AC_DEFUN([gl_STDDEF_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
+ 
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_STDDEF_H_DEFAULTS],
+[
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  REPLACE_NULL=0;                AC_SUBST([REPLACE_NULL])
+  HAVE_WCHAR_T=1;                AC_SUBST([HAVE_WCHAR_T])
+  STDDEF_H='';                   AC_SUBST([STDDEF_H])
+])
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1b2f82a..44e472b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -12,6 +12,7 @@ daemon/dir.c
 daemon/dmesg.c
 daemon/dropcaches.c
 daemon/du.c
+daemon/echo_daemon.c
 daemon/ext2.c
 daemon/fallocate.c
 daemon/file.c
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 205a12b..6bb2f98 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-194
+195
diff --git a/src/generator.ml b/src/generator.ml
index 439c9c4..f820e1f 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -3595,6 +3595,13 @@ This loads a kernel module in the appliance.
 The kernel module must have been whitelisted when libguestfs
 was built (see C<appliance/kmod.whitelist.in> in the source).");
 
+  ("echo_daemon", (RString "output", [StringList
"words"]), 195, [],
+   [InitNone, Always, TestRun [["echo_daemon"; "\"This is a
test\""]]],
+   "echo arguments back to the client",
+   "\
+This commands works much like the unix echo command. It returns its arguments
as
+a string.");
+
 ]
 
 let all_functions = non_daemon_functions @ daemon_functions
-- 
1.6.2.5
Ignore this. It contains accidentally included crap. On 11/09/09 14:33, Matthew Booth wrote:> echo_daemon is a simple echo which can be used to test connectivity between the > client and daemon. > --- > daemon/Makefile.am | 1 + > daemon/echo_daemon.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ > daemon/m4/stddef_h.m4 | 45 +++++++++++++++++++++++++++++++++ > po/POTFILES.in | 1 + > src/MAX_PROC_NR | 2 +- > src/generator.ml | 7 +++++ > 6 files changed, 121 insertions(+), 1 deletions(-) > create mode 100644 daemon/echo_daemon.c > create mode 100644 daemon/m4/stddef_h.m4 > > diff --git a/daemon/Makefile.am b/daemon/Makefile.am > index 83ee408..ae74699 100644 > --- a/daemon/Makefile.am > +++ b/daemon/Makefile.am > @@ -36,6 +36,7 @@ guestfsd_SOURCES = \ > dmesg.c \ > dropcaches.c \ > du.c \ > + echo_daemon.c \ > ext2.c \ > fallocate.c \ > file.c \ > diff --git a/daemon/echo_daemon.c b/daemon/echo_daemon.c > new file mode 100644 > index 0000000..dbede2f > --- /dev/null > +++ b/daemon/echo_daemon.c > @@ -0,0 +1,66 @@ > +/* libguestfs - the guestfsd daemon > + * 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 > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program; if not, write to the Free Software > + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. > + */ > + > +#include<config.h> > + > +#include<string.h> > + > +#include "actions.h" > + > +char * > +do_echo_daemon (char *const *argv) > +{ > + char *out = NULL; > + size_t out_len = 0; > + > + /* Iterate over argv entries until reaching the NULL terminator */ > + while (*argv) { > + char add_space = 0; > + > + /* Store the end of current output */ > + size_t out_end = out_len; > + > + /* Calculate the new output size */ > + size_t arg_len = strlen(*argv); > + out_len += arg_len; > + > + /* We will prepend a space if this isn't the first argument added */ > + if (NULL != out) { > + out_len++; > + add_space = 1; > + } > + > + /* Make the output buffer big enough for the string and its terminator */ > + out = realloc (out, out_len + 1); > + > + /* Prepend a space if required */ > + if (add_space) { > + out[out_end++] = ' '; > + } > + > + /* Copy the argument to the output */ > + memcpy(&out[out_end], *argv, arg_len); > + > + argv++; > + } > + > + /* NULL terminate the output */ > + out[out_len] = '\0'; > + > + return out; > +} > diff --git a/daemon/m4/stddef_h.m4 b/daemon/m4/stddef_h.m4 > new file mode 100644 > index 0000000..682e9c6 > --- /dev/null > +++ b/daemon/m4/stddef_h.m4 > @@ -0,0 +1,45 @@ > +dnl A placeholder for POSIX 2008<stddef.h>, for platforms that have issues. > +# stddef_h.m4 serial 1 > +dnl Copyright (C) 2009 Free Software Foundation, Inc. > +dnl This file is free software; the Free Software Foundation > +dnl gives unlimited permission to copy and/or distribute it, > +dnl with or without modifications, as long as this notice is preserved. > + > +AC_DEFUN([gl_STDDEF_H], > +[ > + AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) > + AC_REQUIRE([gt_TYPE_WCHAR_T]) > + if test $gt_cv_c_wchar_t = no; then > + HAVE_WCHAR_T=0 > + STDDEF_H=stddef.h > + fi > + AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions], > + [gl_cv_decl_null_works], > + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include<stddef.h> > + int test[2 * (sizeof NULL == sizeof (void *)) -1]; > +]])], > + [gl_cv_decl_null_works=yes], > + [gl_cv_decl_null_works=no])]) > + if test $gl_cv_decl_null_works = no; then > + REPLACE_NULL=1 > + STDDEF_H=stddef.h > + fi > + if test -n "$STDDEF_H"; then > + gl_CHECK_NEXT_HEADERS([stddef.h]) > + fi > +]) > + > +AC_DEFUN([gl_STDDEF_MODULE_INDICATOR], > +[ > + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. > + AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) > + GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 > +]) > + > +AC_DEFUN([gl_STDDEF_H_DEFAULTS], > +[ > + dnl Assume proper GNU behavior unless another module says otherwise. > + REPLACE_NULL=0; AC_SUBST([REPLACE_NULL]) > + HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T]) > + STDDEF_H=''; AC_SUBST([STDDEF_H]) > +]) > diff --git a/po/POTFILES.in b/po/POTFILES.in > index 1b2f82a..44e472b 100644 > --- a/po/POTFILES.in > +++ b/po/POTFILES.in > @@ -12,6 +12,7 @@ daemon/dir.c > daemon/dmesg.c > daemon/dropcaches.c > daemon/du.c > +daemon/echo_daemon.c > daemon/ext2.c > daemon/fallocate.c > daemon/file.c > diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR > index 205a12b..6bb2f98 100644 > --- a/src/MAX_PROC_NR > +++ b/src/MAX_PROC_NR > @@ -1 +1 @@ > -194 > +195 > diff --git a/src/generator.ml b/src/generator.ml > index 439c9c4..f820e1f 100755 > --- a/src/generator.ml > +++ b/src/generator.ml > @@ -3595,6 +3595,13 @@ This loads a kernel module in the appliance. > The kernel module must have been whitelisted when libguestfs > was built (see C<appliance/kmod.whitelist.in> in the source)."); > > + ("echo_daemon", (RString "output", [StringList "words"]), 195, [], > + [InitNone, Always, TestRun [["echo_daemon"; "\"This is a test\""]]], > + "echo arguments back to the client", > + "\ > +This commands works much like the unix echo command. It returns its arguments as > +a string."); > + > ] > > let all_functions = non_daemon_functions @ daemon_functions-- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team M: +44 (0)7977 267231 GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
echo_daemon is a simple echo which can be used to test connectivity between the
client and daemon.
---
 daemon/Makefile.am   |    1 +
 daemon/echo_daemon.c |   66 ++++++++++++++++++++++++++++++++++++++++++++++++++
 po/POTFILES.in       |    1 +
 src/MAX_PROC_NR      |    2 +-
 src/generator.ml     |    7 +++++
 5 files changed, 76 insertions(+), 1 deletions(-)
 create mode 100644 daemon/echo_daemon.c
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 83ee408..ae74699 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -36,6 +36,7 @@ guestfsd_SOURCES = \
 	dmesg.c \
 	dropcaches.c \
 	du.c \
+	echo_daemon.c \
 	ext2.c \
 	fallocate.c \
 	file.c \
diff --git a/daemon/echo_daemon.c b/daemon/echo_daemon.c
new file mode 100644
index 0000000..dbede2f
--- /dev/null
+++ b/daemon/echo_daemon.c
@@ -0,0 +1,66 @@
+/* libguestfs - the guestfsd daemon
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include "actions.h"
+
+char *
+do_echo_daemon (char *const *argv)
+{
+  char *out = NULL;
+  size_t out_len = 0;
+
+  /* Iterate over argv entries until reaching the NULL terminator */
+  while (*argv) {
+    char add_space = 0;
+
+    /* Store the end of current output */
+    size_t out_end = out_len;
+
+    /* Calculate the new output size */
+    size_t arg_len = strlen(*argv);
+    out_len += arg_len;
+
+    /* We will prepend a space if this isn't the first argument added */
+    if (NULL != out) {
+      out_len++;
+      add_space = 1;
+    }
+
+    /* Make the output buffer big enough for the string and its terminator */
+    out = realloc (out, out_len + 1);
+
+    /* Prepend a space if required */
+    if (add_space) {
+      out[out_end++] = ' ';
+    }
+
+    /* Copy the argument to the output */
+    memcpy(&out[out_end], *argv, arg_len);
+
+    argv++;
+  }
+
+  /* NULL terminate the output */
+  out[out_len] = '\0';
+
+  return out;
+}
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1b2f82a..44e472b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -12,6 +12,7 @@ daemon/dir.c
 daemon/dmesg.c
 daemon/dropcaches.c
 daemon/du.c
+daemon/echo_daemon.c
 daemon/ext2.c
 daemon/fallocate.c
 daemon/file.c
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 205a12b..6bb2f98 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-194
+195
diff --git a/src/generator.ml b/src/generator.ml
index 439c9c4..f820e1f 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -3595,6 +3595,13 @@ This loads a kernel module in the appliance.
 The kernel module must have been whitelisted when libguestfs
 was built (see C<appliance/kmod.whitelist.in> in the source).");
 
+  ("echo_daemon", (RString "output", [StringList
"words"]), 195, [],
+   [InitNone, Always, TestRun [["echo_daemon"; "\"This is a
test\""]]],
+   "echo arguments back to the client",
+   "\
+This commands works much like the unix echo command. It returns its arguments
as
+a string.");
+
 ]
 
 let all_functions = non_daemon_functions @ daemon_functions
-- 
1.6.2.5
Maybe Matching Threads
- [PATCH 0/2] add LZ4 kernel decompression support
- [RFB] add LZ4 compression method to btrfs
- [PATCH 0/5] btrfs: lz4/lz4hc compression
- [PATCH RFC 07/13] vhost: format-independent API for used buffers
- [PATCH RFC 07/13] vhost: format-independent API for used buffers