[Pkg-libvirt-commits] [libguestfs] 04/384: btrfs: add optional parameter `ro' to btrfs_subvolume_snapshot

Hilko Bengen bengen at moszumanska.debian.org
Sun Mar 29 16:54:51 UTC 2015


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit b349076aeee7c83e5270f3e36cafb22258bd076c
Author: Hu Tao <hutao at cn.fujitsu.com>
Date:   Wed Nov 26 17:04:04 2014 +0800

    btrfs: add optional parameter `ro' to btrfs_subvolume_snapshot
    
    Parameter `ro' is for creating readonly btrfs snapshot.
    
    Signed-off-by: Hu Tao <hutao at cn.fujitsu.com>
---
 daemon/btrfs.c       |  8 +++++++-
 generator/actions.ml | 13 ++++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 7a4d43d..9b48a5d 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -208,7 +208,7 @@ do_mkfs_btrfs (char *const *devices,
 }
 
 int
-do_btrfs_subvolume_snapshot (const char *source, const char *dest)
+do_btrfs_subvolume_snapshot (const char *source, const char *dest, int ro)
 {
   const size_t MAX_ARGS = 64;
   const char *argv[MAX_ARGS];
@@ -231,6 +231,12 @@ do_btrfs_subvolume_snapshot (const char *source, const char *dest)
   ADD_ARG (argv, i, str_btrfs);
   ADD_ARG (argv, i, "subvolume");
   ADD_ARG (argv, i, "snapshot");
+
+  /* Optional arguments. */
+  if ((optargs_bitmask & GUESTFS_BTRFS_SUBVOLUME_SNAPSHOT_RO_BITMASK) &&
+      ro)
+    ADD_ARG (argv, i, "-r");
+
   ADD_ARG (argv, i, source_buf);
   ADD_ARG (argv, i, dest_buf);
   ADD_ARG (argv, i, NULL);
diff --git a/generator/actions.ml b/generator/actions.ml
index baa7679..47a98e3 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -10217,8 +10217,9 @@ See C<guestfs_get_e2generation>." };
 
   { defaults with
     name = "btrfs_subvolume_snapshot";
-    style = RErr, [Pathname "source"; Pathname "dest"], [];
+    style = RErr, [Pathname "source"; Pathname "dest"], [OBool "ro"];
     proc_nr = Some 322;
+    once_had_no_optargs = true;
     optional = Some "btrfs"; camel_name = "BTRFSSubvolumeSnapshot";
     tests = [
       InitPartition, Always, TestRun (
@@ -10228,13 +10229,15 @@ See C<guestfs_get_e2generation>." };
          ["btrfs_subvolume_create"; "/test1"];
          ["btrfs_subvolume_create"; "/test2"];
          ["btrfs_subvolume_create"; "/dir/test3"];
-         ["btrfs_subvolume_snapshot"; "/dir/test3"; "/dir/test4"]]), []
+         ["btrfs_subvolume_snapshot"; "/dir/test3"; "/dir/test5"; "true"]]), []
     ];
-    shortdesc = "create a writable btrfs snapshot";
+    shortdesc = "create a btrfs snapshot";
     longdesc = "\
-Create a writable snapshot of the btrfs subvolume C<source>.
+Create a snapshot of the btrfs subvolume C<source>.
 The C<dest> argument is the destination directory and the name
-of the snapshot, in the form C</path/to/dest/name>." };
+of the snapshot, in the form C</path/to/dest/name>. By default
+the newly created snapshot is writable, if the value of optional
+parameter C<ro> is true, then a readonly snapshot is created." };
 
   { defaults with
     name = "btrfs_subvolume_delete";

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list