diff options
author | Wanlong Gao <gaowanlong@cn.fujitsu.com> | 2012-08-20 16:17:00 +0800 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-08-21 10:18:23 +0100 |
commit | 11b78a710729c34c1ef921feb119569b7d580877 (patch) | |
tree | 5ceccefad2eab3879c67bb43a0b93891c74f4625 | |
parent | 5e6727746367ba3f935dccb80109abf8e34fe74d (diff) | |
download | libguestfs-11b78a710729c34c1ef921feb119569b7d580877.tar.gz libguestfs-11b78a710729c34c1ef921feb119569b7d580877.tar.xz libguestfs-11b78a710729c34c1ef921feb119569b7d580877.zip |
New API: xfs: xfs_admin
Add new api xfs_admin to change parameters of an XFS filesystem.
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
RWMJ:
- Remove printuuid, printlabel, since they don't change any settings.
- Adjusted the documentation.
- Fix the tests.
-rw-r--r-- | daemon/xfs.c | 69 | ||||
-rw-r--r-- | generator/generator_actions.ml | 27 | ||||
-rw-r--r-- | gobject/Makefile.inc | 6 | ||||
-rw-r--r-- | guestfs-release-notes.txt | 1 | ||||
-rw-r--r-- | po/POTFILES | 1 | ||||
-rw-r--r-- | src/MAX_PROC_NR | 2 |
6 files changed, 103 insertions, 3 deletions
diff --git a/daemon/xfs.c b/daemon/xfs.c index b331b9ba..5f3eaaa5 100644 --- a/daemon/xfs.c +++ b/daemon/xfs.c @@ -460,3 +460,72 @@ error: if (out) free (out); return NULL; } + +int +do_xfs_admin (const char *device, + int extunwritten, int imgfile, int v2log, + int projid32bit, + 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_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 (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 d45558dd..d29ec30c 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -9432,6 +9432,33 @@ 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 "projid32bit"; 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"; "NOARG"; "NOARG"]; + ["mount"; "/dev/sda1"; "/"]; + ["xfs_info"; "/"]], + [CompareWithInt ("xfs_lazycount", 0); + ]) + ]; + shortdesc = "change parameters of an XFS filesystem"; + longdesc = "\ +Change the parameters of the XFS filesystem on C<device>. + +Devices that are mounted cannot be modified. +Administrators must unmount filesystems before this call +can modify parameters. + +Some of the parameters of a mounted filesystem can be examined +and modified using the C<guestfs_xfs_info> and +C<guestfs_xfs_growfs> calls." }; + ] (* Non-API meta-commands available only in guestfish. diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc index 49f95387..9f81cd2c 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 8fe0103d..3c7d02b1 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 60887dc2..d961ac12 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 71627d71..aef2e272 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -348 +349 |