Expose the aug_transform API through the library, so it's possible to
add/remove Augeas transformations to handle files in custom places using
existing lenses.
---
daemon/augeas.c | 21 +++++++++++++++++++++
generator/actions.ml | 12 ++++++++++++
gobject/Makefile.inc | 2 ++
src/MAX_PROC_NR | 2 +-
4 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/daemon/augeas.c b/daemon/augeas.c
index 14cc0cf..5adc959 100644
--- a/daemon/augeas.c
+++ b/daemon/augeas.c
@@ -491,3 +491,24 @@ do_aug_label (const char *augpath)
return ret; /* caller frees */
}
+
+/* Takes optional arguments, consult optargs_bitmask. */
+int
+do_aug_transform (const char *lens, const char *file, int remove)
+{
+ int r;
+ int excl = 0; /* add by default */
+
+ NEED_AUG (-1);
+
+ if (optargs_bitmask & GUESTFS_AUG_TRANSFORM_REMOVE_BITMASK)
+ excl = remove;
+
+ r = aug_transform (aug, lens, file, excl);
+ if (r == -1) {
+ AUGEAS_ERROR ("aug_transform: %s: %s: %s", lens, file, excl ?
"excl" : "incl");
+ return -1;
+ }
+
+ return r;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index eccef00..aa26649 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -13205,6 +13205,18 @@ only the unallocated blocks will be extracted.
This is useful to detect hidden data or to retrieve deleted files
which data units have not been overwritten yet." };
+ { defaults with
+ name = "aug_transform"; added = (1, 35, 2);
+ style = RErr, [String "lens"; String "file"], [ OBool
"remove"];
+ proc_nr = Some 469;
+ shortdesc = "add/remove an Augeas lens transformation";
+ longdesc = "\
+Add an Augeas transformation for the specified C<lens> so it can
+handle C<file>.
+
+If C<remove> is true (C<false> by default), then the transformation
+is removed." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
index 7698c2a..149e4c6 100644
--- a/gobject/Makefile.inc
+++ b/gobject/Makefile.inc
@@ -53,6 +53,7 @@ guestfs_gobject_headers= \
include/guestfs-gobject/optargs-add_drive.h \
include/guestfs-gobject/optargs-add_drive_scratch.h \
include/guestfs-gobject/optargs-add_libvirt_dom.h \
+ include/guestfs-gobject/optargs-aug_transform.h \
include/guestfs-gobject/optargs-btrfs_filesystem_defragment.h \
include/guestfs-gobject/optargs-btrfs_filesystem_resize.h \
include/guestfs-gobject/optargs-btrfs_fsck.h \
@@ -143,6 +144,7 @@ guestfs_gobject_sources= \
src/optargs-add_drive.c \
src/optargs-add_drive_scratch.c \
src/optargs-add_libvirt_dom.c \
+ src/optargs-aug_transform.c \
src/optargs-btrfs_filesystem_defragment.c \
src/optargs-btrfs_filesystem_resize.c \
src/optargs-btrfs_fsck.c \
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 1023289..5ef9d24 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-468
+469
--
2.7.4