summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--capitests/tests.c180
-rw-r--r--daemon/actions.h1
-rw-r--r--daemon/stubs.c31
-rw-r--r--fish/cmds.c25
-rw-r--r--fish/completion.c1
-rw-r--r--guestfish-actions.pod16
-rw-r--r--guestfs-actions.pod20
-rw-r--r--java/com/redhat/et/libguestfs/GuestFS.java29
-rw-r--r--java/com_redhat_et_libguestfs_GuestFS.c20
-rw-r--r--ocaml/guestfs.ml1
-rw-r--r--ocaml/guestfs.mli3
-rw-r--r--ocaml/guestfs_c_actions.c24
-rw-r--r--perl/Guestfs.xs15
-rw-r--r--perl/lib/Sys/Guestfs.pm14
-rw-r--r--python/guestfs-py.c26
-rw-r--r--python/guestfs.py17
-rw-r--r--ruby/ext/guestfs/_guestfs.c24
-rw-r--r--src/guestfs-actions.c94
-rw-r--r--src/guestfs-actions.h1
-rw-r--r--src/guestfs_protocol.c22
-rw-r--r--src/guestfs_protocol.h18
-rw-r--r--src/guestfs_protocol.x10
22 files changed, 590 insertions, 2 deletions
diff --git a/capitests/tests.c b/capitests/tests.c
index d2638629..6713a2d6 100644
--- a/capitests/tests.c
+++ b/capitests/tests.c
@@ -155,6 +155,172 @@ static void no_test_warnings (void)
fprintf (stderr, "warning: \"guestfs_e2fsck_f\" has no tests\n");
}
+static int test_ntfs_3g_probe_0_skip (void)
+{
+ const char *str;
+
+ str = getenv ("SKIP_TEST_NTFS_3G_PROBE_0");
+ if (str && strcmp (str, "1") == 0) return 1;
+ str = getenv ("SKIP_TEST_NTFS_3G_PROBE");
+ if (str && strcmp (str, "1") == 0) return 1;
+ return 0;
+}
+
+static int test_ntfs_3g_probe_0 (void)
+{
+ if (test_ntfs_3g_probe_0_skip ()) {
+ printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_ntfs_3g_probe_0");
+ return 0;
+ }
+
+ /* InitNone|InitEmpty for test_ntfs_3g_probe_0 */
+ {
+ char device[] = "/dev/sda";
+ device[5] = devchar;
+ int r;
+ suppress_error = 0;
+ r = guestfs_blockdev_setrw (g, device);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_umount_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_lvm_remove_all (g);
+ if (r == -1)
+ return -1;
+ }
+ /* TestOutputInt for ntfs_3g_probe (0) */
+ {
+ char device[] = "/dev/sda";
+ device[5] = devchar;
+ char lines_0[] = ",";
+ char *lines[] = {
+ lines_0,
+ NULL
+ };
+ int r;
+ suppress_error = 0;
+ r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char fstype[] = "ntfs";
+ char device[] = "/dev/sda1";
+ device[5] = devchar;
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkfs (g, fstype, device);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char device[] = "/dev/sda1";
+ device[5] = devchar;
+ int r;
+ suppress_error = 0;
+ r = guestfs_ntfs_3g_probe (g, 1, device);
+ if (r == -1)
+ return -1;
+ if (r != 0) {
+ fprintf (stderr, "test_ntfs_3g_probe_0: expected 0 but got %d\n", (int) r);
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static int test_ntfs_3g_probe_1_skip (void)
+{
+ const char *str;
+
+ str = getenv ("SKIP_TEST_NTFS_3G_PROBE_1");
+ if (str && strcmp (str, "1") == 0) return 1;
+ str = getenv ("SKIP_TEST_NTFS_3G_PROBE");
+ if (str && strcmp (str, "1") == 0) return 1;
+ return 0;
+}
+
+static int test_ntfs_3g_probe_1 (void)
+{
+ if (test_ntfs_3g_probe_1_skip ()) {
+ printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_ntfs_3g_probe_1");
+ return 0;
+ }
+
+ /* InitNone|InitEmpty for test_ntfs_3g_probe_1 */
+ {
+ char device[] = "/dev/sda";
+ device[5] = devchar;
+ int r;
+ suppress_error = 0;
+ r = guestfs_blockdev_setrw (g, device);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_umount_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_lvm_remove_all (g);
+ if (r == -1)
+ return -1;
+ }
+ /* TestOutputInt for ntfs_3g_probe (1) */
+ {
+ char device[] = "/dev/sda";
+ device[5] = devchar;
+ char lines_0[] = ",";
+ char *lines[] = {
+ lines_0,
+ NULL
+ };
+ int r;
+ suppress_error = 0;
+ r = guestfs_sfdisk (g, device, 0, 0, 0, lines);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char fstype[] = "ext2";
+ char device[] = "/dev/sda1";
+ device[5] = devchar;
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkfs (g, fstype, device);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char device[] = "/dev/sda1";
+ device[5] = devchar;
+ int r;
+ suppress_error = 0;
+ r = guestfs_ntfs_3g_probe (g, 1, device);
+ if (r == -1)
+ return -1;
+ if (r != 12) {
+ fprintf (stderr, "test_ntfs_3g_probe_1: expected 12 but got %d\n", (int) r);
+ return -1;
+ }
+ }
+ return 0;
+}
+
static int test_sleep_0_skip (void)
{
const char *str;
@@ -16211,9 +16377,21 @@ int main (int argc, char *argv[])
free (devs[i]);
free (devs);
- nr_tests = 144;
+ nr_tests = 146;
test_num++;
+ printf ("%3d/%3d test_ntfs_3g_probe_0\n", test_num, nr_tests);
+ if (test_ntfs_3g_probe_0 () == -1) {
+ printf ("test_ntfs_3g_probe_0 FAILED\n");
+ failed++;
+ }
+ test_num++;
+ printf ("%3d/%3d test_ntfs_3g_probe_1\n", test_num, nr_tests);
+ if (test_ntfs_3g_probe_1 () == -1) {
+ printf ("test_ntfs_3g_probe_1 FAILED\n");
+ failed++;
+ }
+ test_num++;
printf ("%3d/%3d test_sleep_0\n", test_num, nr_tests);
if (test_sleep_0 () == -1) {
printf ("test_sleep_0 FAILED\n");
diff --git a/daemon/actions.h b/daemon/actions.h
index 2c869474..e8291d56 100644
--- a/daemon/actions.h
+++ b/daemon/actions.h
@@ -130,3 +130,4 @@ extern int do_resize2fs (const char *device);
extern char **do_find (const char *directory);
extern int do_e2fsck_f (const char *device);
extern int do_sleep (int secs);
+extern int do_ntfs_3g_probe (int rw, const char *device);
diff --git a/daemon/stubs.c b/daemon/stubs.c
index 0e6af849..2a296446 100644
--- a/daemon/stubs.c
+++ b/daemon/stubs.c
@@ -2743,6 +2743,34 @@ done:
xdr_free ((xdrproc_t) xdr_guestfs_sleep_args, (char *) &args);
}
+static void ntfs_3g_probe_stub (XDR *xdr_in)
+{
+ int r;
+ struct guestfs_ntfs_3g_probe_args args;
+ int rw;
+ const char *device;
+
+ memset (&args, 0, sizeof args);
+
+ if (!xdr_guestfs_ntfs_3g_probe_args (xdr_in, &args)) {
+ reply_with_error ("%s: daemon failed to decode procedure arguments", "ntfs_3g_probe");
+ return;
+ }
+ rw = args.rw;
+ device = args.device;
+
+ r = do_ntfs_3g_probe (rw, device);
+ if (r == -1)
+ /* do_ntfs_3g_probe has already called reply_with_error */
+ goto done;
+
+ struct guestfs_ntfs_3g_probe_ret ret;
+ ret.status = r;
+ reply ((xdrproc_t) &xdr_guestfs_ntfs_3g_probe_ret, (char *) &ret);
+done:
+ xdr_free ((xdrproc_t) xdr_guestfs_ntfs_3g_probe_args, (char *) &args);
+}
+
void dispatch_incoming_message (XDR *xdr_in)
{
switch (proc_nr) {
@@ -3073,6 +3101,9 @@ void dispatch_incoming_message (XDR *xdr_in)
case GUESTFS_PROC_SLEEP:
sleep_stub (xdr_in);
break;
+ case GUESTFS_PROC_NTFS_3G_PROBE:
+ ntfs_3g_probe_stub (xdr_in);
+ break;
default:
reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr);
}
diff --git a/fish/cmds.c b/fish/cmds.c
index 8e8e08ac..334d7154 100644
--- a/fish/cmds.c
+++ b/fish/cmds.c
@@ -114,6 +114,7 @@ void list_commands (void)
printf ("%-20s %s\n", "mount-vfs", "mount a guest disk with mount options and vfstype");
printf ("%-20s %s\n", "mounts", "show mounted filesystems");
printf ("%-20s %s\n", "mv", "move a file");
+ printf ("%-20s %s\n", "ntfs-3g-probe", "probe NTFS volume");
printf ("%-20s %s\n", "ping-daemon", "ping the guest daemon");
printf ("%-20s %s\n", "pvcreate", "create an LVM physical volume");
printf ("%-20s %s\n", "pvremove", "remove an LVM physical volume");
@@ -556,6 +557,9 @@ void display_command (const char *cmd)
if (strcasecmp (cmd, "sleep") == 0)
pod2text ("sleep - sleep for some seconds", " sleep <secs>\n\nSleep for C<secs> seconds.");
else
+ if (strcasecmp (cmd, "ntfs_3g_probe") == 0 || strcasecmp (cmd, "ntfs-3g-probe") == 0)
+ pod2text ("ntfs-3g-probe - probe NTFS volume", " ntfs-3g-probe <rw> <device>\n\nThis command runs the L<ntfs-3g.probe(8)> command which probes\nan NTFS C<device> for mountability. (Not all NTFS volumes can\nbe mounted read-write, and some cannot be mounted at all).\n\nC<rw> is a boolean flag. Set it to true if you want to test\nif the volume can be mounted read-write. Set it to false if\nyou want to test if the volume can be mounted read-only.\n\nThe return value is an integer which C<0> if the operation\nwould succeed, or some non-zero value documented in the\nL<ntfs-3g.probe(8)> manual page.");
+ else
display_builtin_command (cmd);
}
@@ -2716,6 +2720,24 @@ static int run_sleep (const char *cmd, int argc, char *argv[])
return r;
}
+static int run_ntfs_3g_probe (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ int rw;
+ const char *device;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ rw = is_true (argv[0]) ? 1 : 0;
+ device = argv[1];
+ r = guestfs_ntfs_3g_probe (g, rw, device);
+ if (r == -1) return -1;
+ printf ("%d\n", r);
+ return 0;
+}
+
int run_action (const char *cmd, int argc, char *argv[])
{
if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0)
@@ -3108,6 +3130,9 @@ int run_action (const char *cmd, int argc, char *argv[])
if (strcasecmp (cmd, "sleep") == 0)
return run_sleep (cmd, argc, argv);
else
+ if (strcasecmp (cmd, "ntfs_3g_probe") == 0 || strcasecmp (cmd, "ntfs-3g-probe") == 0)
+ return run_ntfs_3g_probe (cmd, argc, argv);
+ else
{
fprintf (stderr, "%s: unknown command\n", cmd);
return -1;
diff --git a/fish/completion.c b/fish/completion.c
index 95c3e5d5..264c5840 100644
--- a/fish/completion.c
+++ b/fish/completion.c
@@ -176,6 +176,7 @@ static const char *const commands[] = {
"find",
"e2fsck-f",
"sleep",
+ "ntfs-3g-probe",
NULL
};
diff --git a/guestfish-actions.pod b/guestfish-actions.pod
index 5d0b5d27..ee3f6411 100644
--- a/guestfish-actions.pod
+++ b/guestfish-actions.pod
@@ -956,6 +956,22 @@ Some internal mounts are not shown.
This moves a file from C<src> to C<dest> where C<dest> is
either a destination filename or destination directory.
+=head2 ntfs-3g-probe
+
+ ntfs-3g-probe true|false device
+
+This command runs the L<ntfs-3g.probe(8)> command which probes
+an NTFS C<device> for mountability. (Not all NTFS volumes can
+be mounted read-write, and some cannot be mounted at all).
+
+C<rw> is a boolean flag. Set it to true if you want to test
+if the volume can be mounted read-write. Set it to false if
+you want to test if the volume can be mounted read-only.
+
+The return value is an integer which C<0> if the operation
+would succeed, or some non-zero value documented in the
+L<ntfs-3g.probe(8)> manual page.
+
=head2 ping-daemon
ping-daemon
diff --git a/guestfs-actions.pod b/guestfs-actions.pod
index 054b65ca..f37ec50b 100644
--- a/guestfs-actions.pod
+++ b/guestfs-actions.pod
@@ -1266,6 +1266,26 @@ either a destination filename or destination directory.
This function returns 0 on success or -1 on error.
+=head2 guestfs_ntfs_3g_probe
+
+ int guestfs_ntfs_3g_probe (guestfs_h *handle,
+ int rw,
+ const char *device);
+
+This command runs the L<ntfs-3g.probe(8)> command which probes
+an NTFS C<device> for mountability. (Not all NTFS volumes can
+be mounted read-write, and some cannot be mounted at all).
+
+C<rw> is a boolean flag. Set it to true if you want to test
+if the volume can be mounted read-write. Set it to false if
+you want to test if the volume can be mounted read-only.
+
+The return value is an integer which C<0> if the operation
+would succeed, or some non-zero value documented in the
+L<ntfs-3g.probe(8)> manual page.
+
+On error this function returns -1.
+
=head2 guestfs_ping_daemon
int guestfs_ping_daemon (guestfs_h *handle);
diff --git a/java/com/redhat/et/libguestfs/GuestFS.java b/java/com/redhat/et/libguestfs/GuestFS.java
index 3f03d754..d29ae54f 100644
--- a/java/com/redhat/et/libguestfs/GuestFS.java
+++ b/java/com/redhat/et/libguestfs/GuestFS.java
@@ -3354,4 +3354,33 @@ public HashMap<String,String> test0rhashtableerr ()
private native void _sleep (long g, int secs)
throws LibGuestFSException;
+ /**
+ * probe NTFS volume
+ * <p>
+ * This command runs the ntfs-3g.probe(8) command which
+ * probes an NTFS "device" for mountability. (Not all NTFS
+ * volumes can be mounted read-write, and some cannot be
+ * mounted at all).
+ * <p>
+ * "rw" is a boolean flag. Set it to true if you want to
+ * test if the volume can be mounted read-write. Set it to
+ * false if you want to test if the volume can be mounted
+ * read-only.
+ * <p>
+ * The return value is an integer which 0 if the operation
+ * would succeed, or some non-zero value documented in the
+ * ntfs-3g.probe(8) manual page.
+ * <p>
+ * @throws LibGuestFSException
+ */
+ public int ntfs_3g_probe (boolean rw, String device)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("ntfs_3g_probe: handle is closed");
+ return _ntfs_3g_probe (g, rw, device);
+ }
+ private native int _ntfs_3g_probe (long g, boolean rw, String device)
+ throws LibGuestFSException;
+
}
diff --git a/java/com_redhat_et_libguestfs_GuestFS.c b/java/com_redhat_et_libguestfs_GuestFS.c
index fc207c12..91e3cf19 100644
--- a/java/com_redhat_et_libguestfs_GuestFS.c
+++ b/java/com_redhat_et_libguestfs_GuestFS.c
@@ -3966,3 +3966,23 @@ Java_com_redhat_et_libguestfs_GuestFS__1sleep
}
}
+JNIEXPORT jint JNICALL
+Java_com_redhat_et_libguestfs_GuestFS__1ntfs_13g_1probe
+ (JNIEnv *env, jobject obj, jlong jg, jboolean jrw, jstring jdevice)
+{
+ guestfs_h *g = (guestfs_h *) (long) jg;
+ int r;
+ int rw;
+ const char *device;
+
+ rw = jrw;
+ device = (*env)->GetStringUTFChars (env, jdevice, NULL);
+ r = guestfs_ntfs_3g_probe (g, rw, device);
+ (*env)->ReleaseStringUTFChars (env, jdevice, device);
+ if (r == -1) {
+ throw_exception (env, guestfs_last_error (g));
+ return 0;
+ }
+ return (jint) r;
+}
+
diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml
index 7df33080..fb432142 100644
--- a/ocaml/guestfs.ml
+++ b/ocaml/guestfs.ml
@@ -276,3 +276,4 @@ external resize2fs : t -> string -> unit = "ocaml_guestfs_resize2fs"
external find : t -> string -> string array = "ocaml_guestfs_find"
external e2fsck_f : t -> string -> unit = "ocaml_guestfs_e2fsck_f"
external sleep : t -> int -> unit = "ocaml_guestfs_sleep"
+external ntfs_3g_probe : t -> bool -> string -> int = "ocaml_guestfs_ntfs_3g_probe"
diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli
index 6f77bb93..859774aa 100644
--- a/ocaml/guestfs.mli
+++ b/ocaml/guestfs.mli
@@ -607,3 +607,6 @@ val e2fsck_f : t -> string -> unit
val sleep : t -> int -> unit
(** sleep for some seconds *)
+val ntfs_3g_probe : t -> bool -> string -> int
+(** probe NTFS volume *)
+
diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c
index 615d209e..45c9883f 100644
--- a/ocaml/guestfs_c_actions.c
+++ b/ocaml/guestfs_c_actions.c
@@ -4174,3 +4174,27 @@ ocaml_guestfs_sleep (value gv, value secsv)
CAMLreturn (rv);
}
+CAMLprim value
+ocaml_guestfs_ntfs_3g_probe (value gv, value rwv, value devicev)
+{
+ CAMLparam3 (gv, rwv, devicev);
+ CAMLlocal1 (rv);
+
+ guestfs_h *g = Guestfs_val (gv);
+ if (g == NULL)
+ caml_failwith ("ntfs_3g_probe: used handle after closing it");
+
+ int rw = Bool_val (rwv);
+ const char *device = String_val (devicev);
+ int r;
+
+ caml_enter_blocking_section ();
+ r = guestfs_ntfs_3g_probe (g, rw, device);
+ caml_leave_blocking_section ();
+ if (r == -1)
+ ocaml_guestfs_raise_error (g, "ntfs_3g_probe");
+
+ rv = Val_int (r);
+ CAMLreturn (rv);
+}
+
diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs
index 7b923f6a..c26faa16 100644
--- a/perl/Guestfs.xs
+++ b/perl/Guestfs.xs
@@ -2534,3 +2534,18 @@ PREINIT:
if (r == -1)
croak ("sleep: %s", guestfs_last_error (g));
+SV *
+ntfs_3g_probe (g, rw, device)
+ guestfs_h *g;
+ int rw;
+ char *device;
+PREINIT:
+ int status;
+ CODE:
+ status = guestfs_ntfs_3g_probe (g, rw, device);
+ if (status == -1)
+ croak ("ntfs_3g_probe: %s", guestfs_last_error (g));
+ RETVAL = newSViv (status);
+ OUTPUT:
+ RETVAL
+
diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm
index 445d9b8b..05adfcb4 100644
--- a/perl/lib/Sys/Guestfs.pm
+++ b/perl/lib/Sys/Guestfs.pm
@@ -889,6 +889,20 @@ Some internal mounts are not shown.
This moves a file from C<src> to C<dest> where C<dest> is
either a destination filename or destination directory.
+=item $status = $h->ntfs_3g_probe ($rw, $device);
+
+This command runs the L<ntfs-3g.probe(8)> command which probes
+an NTFS C<device> for mountability. (Not all NTFS volumes can
+be mounted read-write, and some cannot be mounted at all).
+
+C<rw> is a boolean flag. Set it to true if you want to test
+if the volume can be mounted read-write. Set it to false if
+you want to test if the volume can be mounted read-only.
+
+The return value is an integer which C<0> if the operation
+would succeed, or some non-zero value documented in the
+L<ntfs-3g.probe(8)> manual page.
+
=item $h->ping_daemon ();
This is a test probe into the guestfs daemon running inside
diff --git a/python/guestfs-py.c b/python/guestfs-py.c
index dcfa5fb8..8e90d762 100644
--- a/python/guestfs-py.c
+++ b/python/guestfs-py.c
@@ -4431,6 +4431,31 @@ py_guestfs_sleep (PyObject *self, PyObject *args)
return py_r;
}
+static PyObject *
+py_guestfs_ntfs_3g_probe (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ int r;
+ int rw;
+ const char *device;
+
+ if (!PyArg_ParseTuple (args, (char *) "Ois:guestfs_ntfs_3g_probe",
+ &py_g, &rw, &device))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_ntfs_3g_probe (g, rw, device);
+ if (r == -1) {
+ PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+ return NULL;
+ }
+
+ py_r = PyInt_FromLong ((long) r);
+ return py_r;
+}
+
static PyMethodDef methods[] = {
{ (char *) "create", py_guestfs_create, METH_VARARGS, NULL },
{ (char *) "close", py_guestfs_close, METH_VARARGS, NULL },
@@ -4595,6 +4620,7 @@ static PyMethodDef methods[] = {
{ (char *) "find", py_guestfs_find, METH_VARARGS, NULL },
{ (char *) "e2fsck_f", py_guestfs_e2fsck_f, METH_VARARGS, NULL },
{ (char *) "sleep", py_guestfs_sleep, METH_VARARGS, NULL },
+ { (char *) "ntfs_3g_probe", py_guestfs_ntfs_3g_probe, METH_VARARGS, NULL },
{ NULL, NULL, 0, NULL }
};
diff --git a/python/guestfs.py b/python/guestfs.py
index dd9fa58c..2600ff2a 100644
--- a/python/guestfs.py
+++ b/python/guestfs.py
@@ -1604,3 +1604,20 @@ class GuestFS:
"""
return libguestfsmod.sleep (self._o, secs)
+ def ntfs_3g_probe (self, rw, device):
+ u"""This command runs the ntfs-3g.probe(8) command which
+ probes an NTFS "device" for mountability. (Not all NTFS
+ volumes can be mounted read-write, and some cannot be
+ mounted at all).
+
+ "rw" is a boolean flag. Set it to true if you want to
+ test if the volume can be mounted read-write. Set it to
+ false if you want to test if the volume can be mounted
+ read-only.
+
+ The return value is an integer which 0 if the operation
+ would succeed, or some non-zero value documented in the
+ ntfs-3g.probe(8) manual page.
+ """
+ return libguestfsmod.ntfs_3g_probe (self._o, rw, device)
+
diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c
index 661e3716..38256dc0 100644
--- a/ruby/ext/guestfs/_guestfs.c
+++ b/ruby/ext/guestfs/_guestfs.c
@@ -3981,6 +3981,28 @@ static VALUE ruby_guestfs_sleep (VALUE gv, VALUE secsv)
return Qnil;
}
+static VALUE ruby_guestfs_ntfs_3g_probe (VALUE gv, VALUE rwv, VALUE devicev)
+{
+ guestfs_h *g;
+ Data_Get_Struct (gv, guestfs_h, g);
+ if (!g)
+ rb_raise (rb_eArgError, "%s: used handle after closing it", "ntfs_3g_probe");
+
+ int rw = RTEST (rwv);
+ const char *device = StringValueCStr (devicev);
+ if (!device)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "device", "ntfs_3g_probe");
+
+ int r;
+
+ r = guestfs_ntfs_3g_probe (g, rw, device);
+ if (r == -1)
+ rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+ return INT2NUM (r);
+}
+
/* Initialize the module. */
void Init__guestfs ()
{
@@ -4313,4 +4335,6 @@ void Init__guestfs ()
ruby_guestfs_e2fsck_f, 1);
rb_define_method (c_guestfs, "sleep",
ruby_guestfs_sleep, 1);
+ rb_define_method (c_guestfs, "ntfs_3g_probe",
+ ruby_guestfs_ntfs_3g_probe, 2);
}
diff --git a/src/guestfs-actions.c b/src/guestfs-actions.c
index 955cfff8..ecaa5662 100644
--- a/src/guestfs-actions.c
+++ b/src/guestfs-actions.c
@@ -9980,3 +9980,97 @@ int guestfs_sleep (guestfs_h *g,
return 0;
}
+struct ntfs_3g_probe_ctx {
+ /* This flag is set by the callbacks, so we know we've done
+ * the callbacks as expected, and in the right sequence.
+ * 0 = not called, 1 = reply_cb called.
+ */
+ int cb_sequence;
+ struct guestfs_message_header hdr;
+ struct guestfs_message_error err;
+ struct guestfs_ntfs_3g_probe_ret ret;
+};
+
+static void ntfs_3g_probe_reply_cb (guestfs_h *g, void *data, XDR *xdr)
+{
+ guestfs_main_loop *ml = guestfs_get_main_loop (g);
+ struct ntfs_3g_probe_ctx *ctx = (struct ntfs_3g_probe_ctx *) data;
+
+ /* This should definitely not happen. */
+ if (ctx->cb_sequence != 0) {
+ ctx->cb_sequence = 9999;
+ error (g, "%s: internal error: reply callback called twice", "guestfs_ntfs_3g_probe");
+ return;
+ }
+
+ ml->main_loop_quit (ml, g);
+
+ if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
+ error (g, "%s: failed to parse reply header", "guestfs_ntfs_3g_probe");
+ return;
+ }
+ if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
+ if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
+ error (g, "%s: failed to parse reply error", "guestfs_ntfs_3g_probe");
+ return;
+ }
+ goto done;
+ }
+ if (!xdr_guestfs_ntfs_3g_probe_ret (xdr, &ctx->ret)) {
+ error (g, "%s: failed to parse reply", "guestfs_ntfs_3g_probe");
+ return;
+ }
+ done:
+ ctx->cb_sequence = 1;
+}
+
+int guestfs_ntfs_3g_probe (guestfs_h *g,
+ int rw,
+ const char *device)
+{
+ struct guestfs_ntfs_3g_probe_args args;
+ struct ntfs_3g_probe_ctx ctx;
+ guestfs_main_loop *ml = guestfs_get_main_loop (g);
+ int serial;
+
+ if (check_state (g, "guestfs_ntfs_3g_probe") == -1) return -1;
+ guestfs_set_busy (g);
+
+ memset (&ctx, 0, sizeof ctx);
+
+ args.rw = rw;
+ args.device = (char *) device;
+ serial = guestfs__send_sync (g, GUESTFS_PROC_NTFS_3G_PROBE,
+ (xdrproc_t) xdr_guestfs_ntfs_3g_probe_args, (char *) &args);
+ if (serial == -1) {
+ guestfs_end_busy (g);
+ return -1;
+ }
+
+ guestfs__switch_to_receiving (g);
+ ctx.cb_sequence = 0;
+ guestfs_set_reply_callback (g, ntfs_3g_probe_reply_cb, &ctx);
+ (void) ml->main_loop_run (ml, g);
+ guestfs_set_reply_callback (g, NULL, NULL);
+ if (ctx.cb_sequence != 1) {
+ error (g, "%s reply failed, see earlier error messages", "guestfs_ntfs_3g_probe");
+ guestfs_end_busy (g);
+ return -1;
+ }
+
+ if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_NTFS_3G_PROBE, serial) == -1) {
+ guestfs_end_busy (g);
+ return -1;
+ }
+
+ if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
+ error (g, "%s", ctx.err.error_message);
+ free (ctx.err.error_message);
+ guestfs_end_busy (g);
+ return -1;
+ }
+
+ guestfs_end_busy (g);
+ return ctx.ret.status;
+}
+
diff --git a/src/guestfs-actions.h b/src/guestfs-actions.h
index 1afb4f0b..7f8f0deb 100644
--- a/src/guestfs-actions.h
+++ b/src/guestfs-actions.h
@@ -180,3 +180,4 @@ extern int guestfs_resize2fs (guestfs_h *handle, const char *device);
extern char **guestfs_find (guestfs_h *handle, const char *directory);
extern int guestfs_e2fsck_f (guestfs_h *handle, const char *device);
extern int guestfs_sleep (guestfs_h *handle, int secs);
+extern int guestfs_ntfs_3g_probe (guestfs_h *handle, int rw, const char *device);
diff --git a/src/guestfs_protocol.c b/src/guestfs_protocol.c
index df494203..fc88d05f 100644
--- a/src/guestfs_protocol.c
+++ b/src/guestfs_protocol.c
@@ -1849,6 +1849,28 @@ xdr_guestfs_sleep_args (XDR *xdrs, guestfs_sleep_args *objp)
}
bool_t
+xdr_guestfs_ntfs_3g_probe_args (XDR *xdrs, guestfs_ntfs_3g_probe_args *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_bool (xdrs, &objp->rw))
+ return FALSE;
+ if (!xdr_string (xdrs, &objp->device, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_guestfs_ntfs_3g_probe_ret (XDR *xdrs, guestfs_ntfs_3g_probe_ret *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_int (xdrs, &objp->status))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
xdr_guestfs_procedure (XDR *xdrs, guestfs_procedure *objp)
{
register int32_t *buf;
diff --git a/src/guestfs_protocol.h b/src/guestfs_protocol.h
index 68f4ec62..9f3bd8d0 100644
--- a/src/guestfs_protocol.h
+++ b/src/guestfs_protocol.h
@@ -935,6 +935,17 @@ struct guestfs_sleep_args {
};
typedef struct guestfs_sleep_args guestfs_sleep_args;
+struct guestfs_ntfs_3g_probe_args {
+ bool_t rw;
+ char *device;
+};
+typedef struct guestfs_ntfs_3g_probe_args guestfs_ntfs_3g_probe_args;
+
+struct guestfs_ntfs_3g_probe_ret {
+ int status;
+};
+typedef struct guestfs_ntfs_3g_probe_ret guestfs_ntfs_3g_probe_ret;
+
enum guestfs_procedure {
GUESTFS_PROC_MOUNT = 1,
GUESTFS_PROC_SYNC = 2,
@@ -1045,7 +1056,8 @@ enum guestfs_procedure {
GUESTFS_PROC_FIND = 107,
GUESTFS_PROC_E2FSCK_F = 108,
GUESTFS_PROC_SLEEP = 109,
- GUESTFS_PROC_NR_PROCS = 109 + 1,
+ GUESTFS_PROC_NTFS_3G_PROBE = 110,
+ GUESTFS_PROC_NR_PROCS = 110 + 1,
};
typedef enum guestfs_procedure guestfs_procedure;
#define GUESTFS_MESSAGE_MAX 4194304
@@ -1244,6 +1256,8 @@ extern bool_t xdr_guestfs_find_args (XDR *, guestfs_find_args*);
extern bool_t xdr_guestfs_find_ret (XDR *, guestfs_find_ret*);
extern bool_t xdr_guestfs_e2fsck_f_args (XDR *, guestfs_e2fsck_f_args*);
extern bool_t xdr_guestfs_sleep_args (XDR *, guestfs_sleep_args*);
+extern bool_t xdr_guestfs_ntfs_3g_probe_args (XDR *, guestfs_ntfs_3g_probe_args*);
+extern bool_t xdr_guestfs_ntfs_3g_probe_ret (XDR *, guestfs_ntfs_3g_probe_ret*);
extern bool_t xdr_guestfs_procedure (XDR *, guestfs_procedure*);
extern bool_t xdr_guestfs_message_direction (XDR *, guestfs_message_direction*);
extern bool_t xdr_guestfs_message_status (XDR *, guestfs_message_status*);
@@ -1401,6 +1415,8 @@ extern bool_t xdr_guestfs_find_args ();
extern bool_t xdr_guestfs_find_ret ();
extern bool_t xdr_guestfs_e2fsck_f_args ();
extern bool_t xdr_guestfs_sleep_args ();
+extern bool_t xdr_guestfs_ntfs_3g_probe_args ();
+extern bool_t xdr_guestfs_ntfs_3g_probe_ret ();
extern bool_t xdr_guestfs_procedure ();
extern bool_t xdr_guestfs_message_direction ();
extern bool_t xdr_guestfs_message_status ();
diff --git a/src/guestfs_protocol.x b/src/guestfs_protocol.x
index 556ed60e..cc514e74 100644
--- a/src/guestfs_protocol.x
+++ b/src/guestfs_protocol.x
@@ -723,6 +723,15 @@ struct guestfs_sleep_args {
int secs;
};
+struct guestfs_ntfs_3g_probe_args {
+ bool rw;
+ string device<>;
+};
+
+struct guestfs_ntfs_3g_probe_ret {
+ int status;
+};
+
enum guestfs_procedure {
GUESTFS_PROC_MOUNT = 1,
GUESTFS_PROC_SYNC = 2,
@@ -833,6 +842,7 @@ enum guestfs_procedure {
GUESTFS_PROC_FIND = 107,
GUESTFS_PROC_E2FSCK_F = 108,
GUESTFS_PROC_SLEEP = 109,
+ GUESTFS_PROC_NTFS_3G_PROBE = 110,
GUESTFS_PROC_NR_PROCS
};