[PATCH 0/3] btrfs subvolumes display fix
by Cédric Bosdonnat
Hey there!
Here are a few patches to fix unrelated things: one fixes the configure for older
ncurses releases having no pkg-config files. The other two are fixing what Richard
mentioned about guestfs subvolumes display
Cédric Bosdonnat (3):
configure: handle older version of ncurses
api: add mountable_device and mountable_subvolume
fish: fix btrfs subvolumes display in error case
fish/options.c | 15 ++++++++++++++-
generator/actions.ml | 25 +++++++++++++++++++++++++
m4/guestfs_libraries.m4 | 6 +++++-
po/POTFILES | 1 +
src/Makefile.am | 1 +
src/mountable.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 94 insertions(+), 2 deletions(-)
create mode 100644 src/mountable.c
--
2.6.2
8 years, 8 months
[PATCH] tests: move ntfs tests in a single directory
by Pino Toscano
Move test-ntfscat.sh and test-ntfsclone.sh in a single ntfs directory,
much like the tests for other filesystems.
---
Makefile.am | 3 +-
configure.ac | 3 +-
tests/ntfs/Makefile.am | 27 +++++++++++++++++
tests/ntfs/test-ntfscat.sh | 53 +++++++++++++++++++++++++++++++++
tests/ntfs/test-ntfsclone.sh | 62 +++++++++++++++++++++++++++++++++++++++
tests/ntfscat/Makefile.am | 26 ----------------
tests/ntfscat/test-ntfscat.sh | 53 ---------------------------------
tests/ntfsclone/Makefile.am | 26 ----------------
tests/ntfsclone/test-ntfsclone.sh | 62 ---------------------------------------
9 files changed, 144 insertions(+), 171 deletions(-)
create mode 100644 tests/ntfs/Makefile.am
create mode 100755 tests/ntfs/test-ntfscat.sh
create mode 100755 tests/ntfs/test-ntfsclone.sh
delete mode 100644 tests/ntfscat/Makefile.am
delete mode 100755 tests/ntfscat/test-ntfscat.sh
delete mode 100644 tests/ntfsclone/Makefile.am
delete mode 100755 tests/ntfsclone/test-ntfsclone.sh
diff --git a/Makefile.am b/Makefile.am
index 1ab85e8..fe92630 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -65,8 +65,7 @@ SUBDIRS += tests/lvm
SUBDIRS += tests/luks
SUBDIRS += tests/md
SUBDIRS += tests/selinux
-SUBDIRS += tests/ntfsclone
-SUBDIRS += tests/ntfscat
+SUBDIRS += tests/ntfs
SUBDIRS += tests/btrfs
SUBDIRS += tests/xfs
SUBDIRS += tests/charsets
diff --git a/configure.ac b/configure.ac
index 0a759fe..fd8e534 100644
--- a/configure.ac
+++ b/configure.ac
@@ -271,8 +271,7 @@ AC_CONFIG_FILES([Makefile
tests/mountable/Makefile
tests/nbd/Makefile
tests/network/Makefile
- tests/ntfsclone/Makefile
- tests/ntfscat/Makefile
+ tests/ntfs/Makefile
tests/parallel/Makefile
tests/protocol/Makefile
tests/qemu/Makefile
diff --git a/tests/ntfs/Makefile.am b/tests/ntfs/Makefile.am
new file mode 100644
index 0000000..8b8fd95
--- /dev/null
+++ b/tests/ntfs/Makefile.am
@@ -0,0 +1,27 @@
+# libguestfs
+# Copyright (C) 2012-2016 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include $(top_srcdir)/subdir-rules.mk
+
+TESTS = \
+ test-ntfscat.sh \
+ test-ntfsclone.sh
+
+TESTS_ENVIRONMENT = $(top_builddir)/run --test
+
+EXTRA_DIST = \
+ $(TESTS)
diff --git a/tests/ntfs/test-ntfscat.sh b/tests/ntfs/test-ntfscat.sh
new file mode 100755
index 0000000..5cfdd95
--- /dev/null
+++ b/tests/ntfs/test-ntfscat.sh
@@ -0,0 +1,53 @@
+#!/bin/bash -
+# libguestfs
+# Copyright (C) 2016 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Test the ntfscat-i command.
+
+set -e
+
+if [ -n "$SKIP_TEST_NTFSCAT_SH" ]; then
+ echo "$0: test skipped because environment variable is set."
+ exit 77
+fi
+
+rm -f test-mft.bin
+
+# Skip if ntfs-3g is not supported by the appliance.
+if ! guestfish add /dev/null : run : available "ntfs3g"; then
+ echo "$0: skipped because ntfs-3g is not supported by the appliance"
+ exit 77
+fi
+
+if [ ! -s ../../test-data/phony-guests/windows.img ]; then
+ echo "$0: skipped because windows.img is zero-sized"
+ exit 77
+fi
+
+# download Master File Table ($MFT).
+guestfish --ro -a ../../test-data/phony-guests/windows.img <<EOF
+run
+ntfscat-i /dev/sda2 0 test-mft.bin
+EOF
+
+# test extracted file is the Master File Table
+if [ `head -c 5 test-mft.bin` != "FILE0" ]; then
+ echo "$0: wrong file extracted."
+ exit 1
+fi
+
+rm -f test-mft.bin
diff --git a/tests/ntfs/test-ntfsclone.sh b/tests/ntfs/test-ntfsclone.sh
new file mode 100755
index 0000000..668ed8a
--- /dev/null
+++ b/tests/ntfs/test-ntfsclone.sh
@@ -0,0 +1,62 @@
+#!/bin/bash -
+# libguestfs
+# Copyright (C) 2012 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+# Test the ntfsclone-in/-out commands.
+
+set -e
+
+if [ -n "$SKIP_TEST_NTFSCLONE_SH" ]; then
+ echo "$0: test skipped because environment variable is set."
+ exit 77
+fi
+
+rm -f test-ntfsclone.img ntfsclone-backup1 ntfsclone-backup2
+
+# Skip if ntfs-3g is not supported by the appliance.
+if ! guestfish add /dev/null : run : available "ntfs3g"; then
+ echo "$0: skipped because ntfs-3g is not supported by the appliance"
+ exit 77
+fi
+
+if [ ! -s ../../test-data/phony-guests/windows.img ]; then
+ echo "$0: skipped because windows.img is zero-sized"
+ exit 77
+fi
+
+# Export the filesystems to the backup file.
+guestfish --ro -a ../../test-data/phony-guests/windows.img <<EOF
+run
+ntfsclone-out /dev/sda1 ntfsclone-backup1 preservetimestamps:true force:true
+ntfsclone-out /dev/sda2 ntfsclone-backup2 metadataonly:true ignorefscheck:true
+EOF
+
+# Restore to another disk image.
+output=$(guestfish -N test-ntfsclone.img=part:300M <<EOF
+ntfsclone-in ntfsclone-backup1 /dev/sda1
+vfs-type /dev/sda1
+EOF
+)
+
+if [ "$output" != "ntfs" ]; then
+ echo "$0: unexpected filesystem type after restore: $output"
+ exit 1
+fi
+
+#ls -lh ntfsclone-backup[12]
+
+rm test-ntfsclone.img ntfsclone-backup1 ntfsclone-backup2
diff --git a/tests/ntfscat/Makefile.am b/tests/ntfscat/Makefile.am
deleted file mode 100644
index dc64c3d..0000000
--- a/tests/ntfscat/Makefile.am
+++ /dev/null
@@ -1,26 +0,0 @@
-# libguestfs
-# Copyright (C) 2016 Red Hat Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-include $(top_srcdir)/subdir-rules.mk
-
-TESTS = \
- test-ntfscat.sh
-
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
-
-EXTRA_DIST = \
- $(TESTS)
diff --git a/tests/ntfscat/test-ntfscat.sh b/tests/ntfscat/test-ntfscat.sh
deleted file mode 100755
index 5cfdd95..0000000
--- a/tests/ntfscat/test-ntfscat.sh
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/bash -
-# libguestfs
-# Copyright (C) 2016 Red Hat Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-# Test the ntfscat-i command.
-
-set -e
-
-if [ -n "$SKIP_TEST_NTFSCAT_SH" ]; then
- echo "$0: test skipped because environment variable is set."
- exit 77
-fi
-
-rm -f test-mft.bin
-
-# Skip if ntfs-3g is not supported by the appliance.
-if ! guestfish add /dev/null : run : available "ntfs3g"; then
- echo "$0: skipped because ntfs-3g is not supported by the appliance"
- exit 77
-fi
-
-if [ ! -s ../../test-data/phony-guests/windows.img ]; then
- echo "$0: skipped because windows.img is zero-sized"
- exit 77
-fi
-
-# download Master File Table ($MFT).
-guestfish --ro -a ../../test-data/phony-guests/windows.img <<EOF
-run
-ntfscat-i /dev/sda2 0 test-mft.bin
-EOF
-
-# test extracted file is the Master File Table
-if [ `head -c 5 test-mft.bin` != "FILE0" ]; then
- echo "$0: wrong file extracted."
- exit 1
-fi
-
-rm -f test-mft.bin
diff --git a/tests/ntfsclone/Makefile.am b/tests/ntfsclone/Makefile.am
deleted file mode 100644
index 80795c5..0000000
--- a/tests/ntfsclone/Makefile.am
+++ /dev/null
@@ -1,26 +0,0 @@
-# libguestfs
-# Copyright (C) 2012 Red Hat Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-include $(top_srcdir)/subdir-rules.mk
-
-TESTS = \
- test-ntfsclone.sh
-
-TESTS_ENVIRONMENT = $(top_builddir)/run --test
-
-EXTRA_DIST = \
- $(TESTS)
diff --git a/tests/ntfsclone/test-ntfsclone.sh b/tests/ntfsclone/test-ntfsclone.sh
deleted file mode 100755
index 668ed8a..0000000
--- a/tests/ntfsclone/test-ntfsclone.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash -
-# libguestfs
-# Copyright (C) 2012 Red Hat Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-# Test the ntfsclone-in/-out commands.
-
-set -e
-
-if [ -n "$SKIP_TEST_NTFSCLONE_SH" ]; then
- echo "$0: test skipped because environment variable is set."
- exit 77
-fi
-
-rm -f test-ntfsclone.img ntfsclone-backup1 ntfsclone-backup2
-
-# Skip if ntfs-3g is not supported by the appliance.
-if ! guestfish add /dev/null : run : available "ntfs3g"; then
- echo "$0: skipped because ntfs-3g is not supported by the appliance"
- exit 77
-fi
-
-if [ ! -s ../../test-data/phony-guests/windows.img ]; then
- echo "$0: skipped because windows.img is zero-sized"
- exit 77
-fi
-
-# Export the filesystems to the backup file.
-guestfish --ro -a ../../test-data/phony-guests/windows.img <<EOF
-run
-ntfsclone-out /dev/sda1 ntfsclone-backup1 preservetimestamps:true force:true
-ntfsclone-out /dev/sda2 ntfsclone-backup2 metadataonly:true ignorefscheck:true
-EOF
-
-# Restore to another disk image.
-output=$(guestfish -N test-ntfsclone.img=part:300M <<EOF
-ntfsclone-in ntfsclone-backup1 /dev/sda1
-vfs-type /dev/sda1
-EOF
-)
-
-if [ "$output" != "ntfs" ]; then
- echo "$0: unexpected filesystem type after restore: $output"
- exit 1
-fi
-
-#ls -lh ntfsclone-backup[12]
-
-rm test-ntfsclone.img ntfsclone-backup1 ntfsclone-backup2
--
2.5.0
8 years, 8 months
[PATCH 1/2] added ntfscat_i api
by Matteo Cafasso
Adding ntfscat_i command for downloading files based on their inode number.
This allows the dowload of files unaccessible otherwise from a NTFS guest disk image.
Signed-off-by: Matteo Cafasso <noxdafox(a)gmail.com>
---
daemon/ntfs.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
generator/actions.ml | 15 +++++++++++++
2 files changed, 77 insertions(+)
diff --git a/daemon/ntfs.c b/daemon/ntfs.c
index 568899e..58f62fa 100644
--- a/daemon/ntfs.c
+++ b/daemon/ntfs.c
@@ -266,3 +266,65 @@ do_ntfsfix (const char *device, int clearbadsectors)
return 0;
}
+
+int
+do_ntfscat_i (const mountable_t *mountable, int64_t inode)
+{
+ int r;
+ FILE *fp;
+ CLEANUP_FREE char *cmd = NULL;
+ char buffer[GUESTFS_MAX_CHUNK_SIZE];
+
+ /* Inode must be greater than 0 */
+ if (inode < 0) {
+ reply_with_error("Inode must be greater than 0");
+ return -1;
+ }
+
+ /* Construct the command. */
+ if (asprintf_nowarn (&cmd, "ntfscat -i %ld %s",
+ inode, mountable->device) == -1) {
+ reply_with_perror ("asprintf");
+ return -1;
+ }
+
+ if (verbose)
+ fprintf (stderr, "%s\n", cmd);
+
+ fp = popen (cmd, "r");
+ if (fp == NULL) {
+ reply_with_perror ("%s", cmd);
+ return -1;
+ }
+
+ /* Now we must send the reply message, before the file contents. After
+ * this there is no opportunity in the protocol to send any error
+ * message back. Instead we can only cancel the transfer.
+ */
+ reply (NULL, NULL);
+
+ while ((r = fread (buffer, 1, sizeof buffer, fp)) > 0) {
+ if (send_file_write (buffer, r) < 0) {
+ pclose (fp);
+ return -1;
+ }
+ }
+
+ if (ferror (fp)) {
+ fprintf (stderr, "fread: %ld: %m\n", inode);
+ send_file_end (1); /* Cancel. */
+ pclose (fp);
+ return -1;
+ }
+
+ if (pclose (fp) != 0) {
+ fprintf (stderr, "pclose: %ld: %m\n", inode);
+ send_file_end (1); /* Cancel. */
+ return -1;
+ }
+
+ if (send_file_end (0)) /* Normal end of file. */
+ return -1;
+
+ return 0;
+}
diff --git a/generator/actions.ml b/generator/actions.ml
index eb45392..18418aa 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -12891,6 +12891,21 @@ This is equivalent to C<sgdisk -e>.
See also L<sgdisk(8)>." };
+ { defaults with
+ name = "ntfscat_i"; added = (1, 33, 2);
+ style = RErr, [Mountable "device"; Int64 "inode"; FileOut "filename"], [];
+ proc_nr = Some 463;
+ progress = true; cancellable = true;
+ shortdesc = "download a file to the local machine given its inode";
+ longdesc = "\
+Download a file given its inode from a NTFS filesystem and save it as F<filename>
+on the local machine.
+
+This allows to download some otherwise unaccessible files such as the ones
+within the $Extend folder.
+
+F<filename> can also be a named pipe." };
+
]
(* Non-API meta-commands available only in guestfish.
--
2.7.0
8 years, 8 months