Add xfs_info to show the geometry of the xfs filesystem.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
Hi Rich,
This patch add xfs_info, and start the
xfs support work.
I'd like to add the xfs support, like
xfs_growfs, xfs_io, xfs_db, xfs_repair etc.
Any thoughts?
Thanks,
Wanlong Gao
daemon/Makefile.am | 1 +
daemon/xfs.c | 69 ++++++++++++++++++++++++++++++++++++++++++
generator/generator_actions.ml | 6 ++++
src/MAX_PROC_NR | 2 +-
5 files changed, 78 insertions(+), 2 deletions(-)
create mode 100644 daemon/xfs.c
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 9e2a633..afe8874 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -165,6 +165,7 @@ guestfsd_SOURCES = \
utimens.c \
wc.c \
xattr.c \
+ xfs.c \
zero.c \
zerofree.c
guestfsd_LDADD = \
diff --git a/daemon/xfs.c b/daemon/xfs.c
new file mode 100644
index 0000000..8b60b19
--- /dev/null
+++ b/daemon/xfs.c
@@ -0,0 +1,69 @@
+/* libguestfs - the guestfsd daemon
+ * Copyright (C) 2012 Fujitsu Limited.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "guestfs_protocol.h"
+#include "daemon.h"
+#include "c-ctype.h"
+#include "actions.h"
+
+int
+optgroup_xfs_available (void)
+{
+ return prog_exists ("mkfs.xfs");
+}
+
+char *
+do_xfs_info (const char *path)
+{
+ int r;
+ char *buf;
+ char *out, *err;
+
+ if (do_is_dir (path)) {
+ buf = sysroot_path (path);
+ if (!buf) {
+ reply_with_perror ("malloc");
+ return NULL;
+ }
+ } else {
+ buf = strdup(path);
+ if (!buf) {
+ reply_with_perror ("strdup");
+ return NULL;
+ }
+ }
+
+ r = command (&out, &err, "xfs_info", buf, NULL);
+ free (buf);
+ if (r == -1) {
+ reply_with_error ("%s", err);
+ free (err);
+ free (out);
+ return NULL;
+ }
+
+ return out;
+}
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index 5baa9b2..ba0b0de 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -7374,6 +7374,12 @@ be returned if you called C<guestfs_list_devices>.
To find out the maximum number of devices that could be added,
call C<guestfs_max_disks>.");
+ ("xfs_info", (RString "information", [String "path"],
[]), 337, [Optional "xfs"],
+ [],
+ "print out the geometry of the filesystem",
+ "\
+Thie function can print out the geometry of an mounted XFS filesystem.");
+
]
let all_functions = non_daemon_functions @ daemon_functions
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index e64f24d..f59a90f 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-336
+337
--
1.7.11.rc0