Add new api xfs_admin to change parameters of an XFS filesystem.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
daemon/xfs.c | 77 ++++++++++++++++++++++++++++++++++++++++++
generator/generator_actions.ml | 21 ++++++++++++
gobject/Makefile.inc | 6 ++--
guestfs-release-notes.txt | 1 +
po/POTFILES | 1 +
src/MAX_PROC_NR | 2 +-
6 files changed, 105 insertions(+), 3 deletions(-)
diff --git a/daemon/xfs.c b/daemon/xfs.c
index b331b9b..df01917 100644
--- a/daemon/xfs.c
+++ b/daemon/xfs.c
@@ -460,3 +460,80 @@ error:
if (out) free (out);
return NULL;
}
+
+int
+do_xfs_admin (const char *device,
+ int extunwritten, int imgfile, int v2log,
+ int printlabel, int projid32bit, int printuuid,
+ int lazycounter, const char *label, const char *uuid)
+{
+ int r;
+ char *err = NULL;
+ const char *argv[MAX_ARGS];
+ size_t i = 0;
+
+ ADD_ARG (argv, i, "xfs_admin");
+
+ /* Optional arguments */
+ if (!(optargs_bitmask & GUESTFS_XFS_ADMIN_EXTUNWRITTEN_BITMASK))
+ extunwritten = 0;
+ if (!(optargs_bitmask & GUESTFS_XFS_ADMIN_IMGFILE_BITMASK))
+ imgfile = 0;
+ if (!(optargs_bitmask & GUESTFS_XFS_ADMIN_V2LOG_BITMASK))
+ v2log = 0;
+ if (!(optargs_bitmask & GUESTFS_XFS_ADMIN_PRINTLABEL_BITMASK))
+ printlabel = 0;
+ if (!(optargs_bitmask & GUESTFS_XFS_ADMIN_PRINTUUID_BITMASK))
+ printuuid = 0;
+ if (!(optargs_bitmask & GUESTFS_XFS_ADMIN_PROJID32BIT_BITMASK))
+ projid32bit = 0;
+
+ if (extunwritten)
+ ADD_ARG (argv, i, "-e");
+ if (imgfile)
+ ADD_ARG (argv, i, "-f");
+ if (v2log)
+ ADD_ARG (argv, i, "-j");
+ if (printlabel)
+ ADD_ARG (argv, i, "-l");
+ if (printuuid)
+ ADD_ARG (argv, i, "-u");
+ if (projid32bit)
+ ADD_ARG (argv, i, "-p");
+
+ if (optargs_bitmask & GUESTFS_XFS_ADMIN_LAZYCOUNTER_BITMASK) {
+ if (lazycounter) {
+ ADD_ARG (argv, i, "-c");
+ ADD_ARG (argv, i, "1");
+ } else {
+ ADD_ARG (argv, i, "-c");
+ ADD_ARG (argv, i, "0");
+ }
+ }
+
+ if (optargs_bitmask & GUESTFS_XFS_ADMIN_LABEL_BITMASK) {
+ ADD_ARG (argv, i, "-L");
+ ADD_ARG (argv, i, label);
+ }
+
+ if (optargs_bitmask & GUESTFS_XFS_ADMIN_UUID_BITMASK) {
+ ADD_ARG (argv, i, "-U");
+ ADD_ARG (argv, i, uuid);
+ }
+
+ ADD_ARG (argv, i, device);
+ ADD_ARG (argv, i, NULL);
+
+ r = commandv (NULL, &err, argv);
+ if (r == -1) {
+ reply_with_error ("%s: %s", device, err);
+ goto error;
+ }
+
+ free (err);
+ return 0;
+
+error:
+ free (err);
+ return -1;
+}
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index d45558d..ebda464 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -9432,6 +9432,27 @@ empty files in the directory C<dir> with names
C<00000000>
through C<nr-1> (ie. each file name is 8 digits long padded
with zeroes)." };
+ { defaults with
+ name = "xfs_admin";
+ style = RErr, [Device "device"], [OBool "extunwritten"; OBool
"imgfile"; OBool "v2log"; OBool "printlabel"; OBool
"projid32bit"; OBool "printuuid"; OBool "lazycounter";
OString "label"; OString "uuid"];
+ proc_nr = Some 349;
+ optional = Some "xfs";
+ tests = [
+ InitEmpty, IfAvailable "xfs", TestOutputStruct (
+ [["part_disk"; "/dev/sda"; "mbr"];
+ ["mkfs"; "xfs"; "/dev/sda1"; "";
"NOARG"; ""; ""];
+ ["xfs_admin"; "/dev/sda1"; ""; "";
""; ""; ""; ""; "false"; "";
""];
+ ["mount"; "/dev/sda1"; "/"];
+ ["xfs_info"; "/"]],
+ [CompareWithInt ("xfs_lazycount", 0);
+ ])
+ ];
+ shortdesc = "change parameters of an XFS filesystem";
+ longdesc = "\
+Devices that are mounted cannot be modified. Administrators must unmount
+filesystems before C<xfs_admin> can convert parameters. A number of parameters
+of a mounted filesystem can be examined and modified using the C<xfs_growfs>."
};
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
index 49f9538..9f81cd2 100644
--- a/gobject/Makefile.inc
+++ b/gobject/Makefile.inc
@@ -72,7 +72,8 @@ guestfs_gobject_headers= \
include/guestfs-gobject/optargs-xfs_growfs.h \
include/guestfs-gobject/optargs-rsync.h \
include/guestfs-gobject/optargs-rsync_in.h \
- include/guestfs-gobject/optargs-rsync_out.h
+ include/guestfs-gobject/optargs-rsync_out.h \
+ include/guestfs-gobject/optargs-xfs_admin.h
guestfs_gobject_sources= \
src/session.c \
@@ -126,4 +127,5 @@ guestfs_gobject_sources= \
src/optargs-xfs_growfs.c \
src/optargs-rsync.c \
src/optargs-rsync_in.c \
- src/optargs-rsync_out.c
+ src/optargs-rsync_out.c \
+ src/optargs-xfs_admin.c
diff --git a/guestfs-release-notes.txt b/guestfs-release-notes.txt
index 8fe0103..3c7d02b 100644
--- a/guestfs-release-notes.txt
+++ b/guestfs-release-notes.txt
@@ -89,6 +89,7 @@ RELEASE NOTES FOR LIBGUESTFS 1.20
For further information, see
https://bugzilla.redhat.com/show_bug.cgi?id=788642
+ <
https://bugzilla.redhat.com/show_bug.cgi?id=788642>
New APIs
diff --git a/po/POTFILES b/po/POTFILES
index 60887dc..d961ac1 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -167,6 +167,7 @@ gobject/src/optargs-tar_out.c
gobject/src/optargs-tune2fs.c
gobject/src/optargs-umount.c
gobject/src/optargs-umount_local.c
+gobject/src/optargs-xfs_admin.c
gobject/src/optargs-xfs_growfs.c
gobject/src/session.c
gobject/src/struct-application.c
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 71627d7..aef2e27 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-348
+349
--
1.7.12