diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-06-29 11:47:07 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2009-06-29 11:47:07 +0100 |
commit | 826020fe18bf2eee43f8afea392874bb88c0650a (patch) | |
tree | 7c6c40758611605be29b3528da647a78a071ea1b /perl | |
parent | 3854bbdecd1c089959fb812a739b84a96c05fbbf (diff) | |
download | libguestfs-826020fe18bf2eee43f8afea392874bb88c0650a.tar.gz libguestfs-826020fe18bf2eee43f8afea392874bb88c0650a.tar.xz libguestfs-826020fe18bf2eee43f8afea392874bb88c0650a.zip |
Generated code for head/tail commands.
Diffstat (limited to 'perl')
-rw-r--r-- | perl/Guestfs.xs | 84 | ||||
-rw-r--r-- | perl/lib/Sys/Guestfs.pm | 48 |
2 files changed, 128 insertions, 4 deletions
diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs index 1dc634f5..bcd7304f 100644 --- a/perl/Guestfs.xs +++ b/perl/Guestfs.xs @@ -2386,10 +2386,10 @@ PREINIT: croak ("pvresize: %s", guestfs_last_error (g)); void -sfdisk_N (g, device, n, cyls, heads, sectors, line) +sfdisk_N (g, device, partnum, cyls, heads, sectors, line) guestfs_h *g; char *device; - int n; + int partnum; int cyls; int heads; int sectors; @@ -2397,7 +2397,7 @@ sfdisk_N (g, device, n, cyls, heads, sectors, line) PREINIT: int r; PPCODE: - r = guestfs_sfdisk_N (g, device, n, cyls, heads, sectors, line); + r = guestfs_sfdisk_N (g, device, partnum, cyls, heads, sectors, line); if (r == -1) croak ("sfdisk_N: %s", guestfs_last_error (g)); @@ -2692,3 +2692,81 @@ PREINIT: OUTPUT: RETVAL +void +head (g, path) + guestfs_h *g; + char *path; +PREINIT: + char **lines; + int i, n; + PPCODE: + lines = guestfs_head (g, path); + if (lines == NULL) + croak ("head: %s", guestfs_last_error (g)); + for (n = 0; lines[n] != NULL; ++n) /**/; + EXTEND (SP, n); + for (i = 0; i < n; ++i) { + PUSHs (sv_2mortal (newSVpv (lines[i], 0))); + free (lines[i]); + } + free (lines); + +void +head_n (g, nrlines, path) + guestfs_h *g; + int nrlines; + char *path; +PREINIT: + char **lines; + int i, n; + PPCODE: + lines = guestfs_head_n (g, nrlines, path); + if (lines == NULL) + croak ("head_n: %s", guestfs_last_error (g)); + for (n = 0; lines[n] != NULL; ++n) /**/; + EXTEND (SP, n); + for (i = 0; i < n; ++i) { + PUSHs (sv_2mortal (newSVpv (lines[i], 0))); + free (lines[i]); + } + free (lines); + +void +tail (g, path) + guestfs_h *g; + char *path; +PREINIT: + char **lines; + int i, n; + PPCODE: + lines = guestfs_tail (g, path); + if (lines == NULL) + croak ("tail: %s", guestfs_last_error (g)); + for (n = 0; lines[n] != NULL; ++n) /**/; + EXTEND (SP, n); + for (i = 0; i < n; ++i) { + PUSHs (sv_2mortal (newSVpv (lines[i], 0))); + free (lines[i]); + } + free (lines); + +void +tail_n (g, nrlines, path) + guestfs_h *g; + int nrlines; + char *path; +PREINIT: + char **lines; + int i, n; + PPCODE: + lines = guestfs_tail_n (g, nrlines, path); + if (lines == NULL) + croak ("tail_n: %s", guestfs_last_error (g)); + for (n = 0; lines[n] != NULL; ++n) /**/; + EXTEND (SP, n); + for (i = 0; i < n; ++i) { + PUSHs (sv_2mortal (newSVpv (lines[i], 0))); + free (lines[i]); + } + free (lines); + diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm index 8871b68e..3d15738a 100644 --- a/perl/lib/Sys/Guestfs.pm +++ b/perl/lib/Sys/Guestfs.pm @@ -694,6 +694,29 @@ See that manual page for more details. This command installs GRUB (the Grand Unified Bootloader) on C<device>, with the root directory being C<root>. +=item @lines = $h->head ($path); + +This command returns up to the first 10 lines of a file as +a list of strings. + +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 @lines = $h->head_n ($nrlines, $path); + +If the parameter C<nrlines> is a positive number, this returns the first +C<nrlines> lines of the file C<path>. + +If the parameter C<nrlines> is a negative number, this returns lines +from the file C<path>, excluding the last C<nrlines> lines. + +If the parameter C<nrlines> is zero, this returns an empty list. + +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 $dump = $h->hexdump ($path); This runs C<hexdump -C> on the given C<path>. The result is @@ -1161,7 +1184,7 @@ See also: C<$h-E<gt>sfdisk_l>, C<$h-E<gt>sfdisk_N> B<This command is dangerous. Without careful use you can easily destroy all your data>. -=item $h->sfdisk_N ($device, $n, $cyls, $heads, $sectors, $line); +=item $h->sfdisk_N ($device, $partnum, $cyls, $heads, $sectors, $line); This runs L<sfdisk(8)> option to modify just the single partition C<n> (note: C<n> counts from 1). @@ -1268,6 +1291,29 @@ underlying disk image. You should always call this if you have modified a disk image, before closing the handle. +=item @lines = $h->tail ($path); + +This command returns up to the last 10 lines of a file as +a list of strings. + +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 @lines = $h->tail_n ($nrlines, $path); + +If the parameter C<nrlines> is a positive number, this returns the last +C<nrlines> lines of the file C<path>. + +If the parameter C<nrlines> is a negative number, this returns lines +from the file C<path>, starting with the C<-nrlines>th line. + +If the parameter C<nrlines> is zero, this returns an empty list. + +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->tar_in ($tarfile, $directory); This command uploads and unpacks local file C<tarfile> (an |