[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 2/2] New APIs: mount-local, umount-local (FUSE support in the API).

From: "Richard W.M. Jones" <rjones redhat com>

Add FUSE support directly to the API.  Instead of needing to
use the external 'guestmount' command, you can mount the
libguestfs filesystem space on a local mountpoint using an
API call from any language.

Cc: Pádraig Brady <P draigBrady com>
 generator/generator_actions.ml |   45 ++++++++++++++++++++++++++++++++++++++++
 generator/generator_events.ml  |    3 ++
 2 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index 7d7c7af..3d4e5ec 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -1644,6 +1644,51 @@ This function must be called before C<guestfs_launch>.");
 This returns the number of virtual CPUs assigned to the appliance.");
+  ("mount_local", (RErr, [String "localmountpoint"], [String "options"]), -1, [],
+   [], (* tests in fuse subdirectory *)
+   "mount on the local filesystem",
+   "\
+This call exports the libguestfs-accessible filesystem to
+a local mountpoint (directory) called C<localmountpoint>.
+Ordinary reads and writes to files and directories under
+C<localmountpoint> are redirected through libguestfs.
+Internally this is currently implemented using FUSE, and
+so this requires that FUSE is available and usable.  This
+may require installing a kernel module and/or adding the
+current user to a special C<fuse> group.  See the documentation
+for your distro and L<http://fuse.sf.net> for further
+The C<guestfs_mount_local> call does not return until the
+filesystem is I<unmounted> by calling C<guestfs_umount_local>.
+The current thread is involved with the processing of
+filesystem requests.  To access the filesystem you need
+to use another thread or process.  B<Note> you must I<not>
+make concurrent libguestfs calls on the same handle from
+another thread, except for C<guestfs_umount_local>.
+The mountpoint is not immediately available, since there
+is certain setup required.  When the mountpoint becomes
+ready to use, the C<MOUNTED> callback is called in the
+current thread.  You can register a callback function
+using C<guestfs_set_event_callback>.
+To unmount the filesystem, call C<guestfs_umount_local>.
+This may be called from another thread, which is a special
+exception to ordinary libguestfs rules.  Two things happen
+when this is called: firstly the C<UNMOUNTED> callback is
+called, and secondly the current call returns.");
+  ("umount_local", (RErr, [], []), -1, [],
+   [], (* tests in fuse subdirectory *)
+   "unmount a locally mounted filesystem",
+   "\
+If libguestfs is exporting the filesystem on a local
+mountpoint, then this unmounts it.
+See C<guestfs_mount_local> for full documentation.");
 (* daemon_functions are any functions which cause some action
diff --git a/generator/generator_events.ml b/generator/generator_events.ml
index df74af3..ea26cd0 100644
--- a/generator/generator_events.ml
+++ b/generator/generator_events.ml
@@ -37,6 +37,9 @@ let events = [
   "trace";                              (* call trace messages *)
   "enter";                              (* enter a function *)
+  "mounted";                            (* local filesystem mounted and ready *)
+  "unmounted";                          (* local filesystem unmounted *)
 let events = mapi (fun i name -> name, 1 lsl i) events

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]