diff options
Diffstat (limited to 'perl')
-rw-r--r-- | perl/Guestfs.xs | 54 | ||||
-rw-r--r-- | perl/lib/Sys/Guestfs.pm | 39 |
2 files changed, 93 insertions, 0 deletions
diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs index e95b2746..ce697c54 100644 --- a/perl/Guestfs.xs +++ b/perl/Guestfs.xs @@ -1699,3 +1699,57 @@ PREINIT: OUTPUT: RETVAL +void +strings (g, path) + guestfs_h *g; + char *path; +PREINIT: + char **stringsout; + int i, n; + PPCODE: + stringsout = guestfs_strings (g, path); + if (stringsout == NULL) + croak ("strings: %s", guestfs_last_error (g)); + for (n = 0; stringsout[n] != NULL; ++n) /**/; + EXTEND (SP, n); + for (i = 0; i < n; ++i) { + PUSHs (sv_2mortal (newSVpv (stringsout[i], 0))); + free (stringsout[i]); + } + free (stringsout); + +void +strings_e (g, encoding, path) + guestfs_h *g; + char *encoding; + char *path; +PREINIT: + char **stringsout; + int i, n; + PPCODE: + stringsout = guestfs_strings_e (g, encoding, path); + if (stringsout == NULL) + croak ("strings_e: %s", guestfs_last_error (g)); + for (n = 0; stringsout[n] != NULL; ++n) /**/; + EXTEND (SP, n); + for (i = 0; i < n; ++i) { + PUSHs (sv_2mortal (newSVpv (stringsout[i], 0))); + free (stringsout[i]); + } + free (stringsout); + +SV * +hexdump (g, path) + guestfs_h *g; + char *path; +PREINIT: + char *dump; + CODE: + dump = guestfs_hexdump (g, path); + if (dump == NULL) + croak ("hexdump: %s", guestfs_last_error (g)); + RETVAL = newSVpv (dump, 0); + free (dump); + OUTPUT: + RETVAL + diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm index 116f7163..d059ae42 100644 --- a/perl/lib/Sys/Guestfs.pm +++ b/perl/lib/Sys/Guestfs.pm @@ -582,6 +582,15 @@ This returns the verbose messages flag. This command installs GRUB (the Grand Unified Bootloader) on C<device>, with the root directory being C<root>. +=item $dump = $h->hexdump ($path); + +This runs C<hexdump -C> on the given C<path>. The result is +the human-readable, canonical hex dump of the file. + +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. + =item $busy = $h->is_busy (); This returns true iff this handle is busy processing a command @@ -958,6 +967,31 @@ C<path> should be a file or directory in the mounted file system This is the same as the C<statvfs(2)> system call. +=item @stringsout = $h->strings ($path); + +This runs the L<strings(1)> command on a file and returns +the list of printable strings found. + +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. + +=item @stringsout = $h->strings_e ($encoding, $path); + +This is like the C<$h-E<gt>strings> command, but allows you to +specify the encoding. + +See the L<strings(1)> manpage for the full list of encodings. + +Commonly useful encodings are C<l> (lower case L) which will +show strings inside Windows/x86 files. + +The returned strings are transcoded to UTF-8. + +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. + =item $h->sync (); This syncs the disk, so that any writes are flushed through to the @@ -1076,6 +1110,11 @@ As a special case, if C<size> is C<0> then the length is calculated using C<strlen> (so in this case the content cannot contain embedded ASCII NULs). +I<NB.> Owing to a bug, writing content containing ASCII NUL +characters does I<not> work, even if the length is specified. +We hope to resolve this bug in a future version. In the meantime +use C<$h-E<gt>upload>. + Because of the message protocol, there is a transfer limit of somewhere between 2MB and 4MB. To transfer large files you should use FTP. |