[Libguestfs] [PATCH 1/2] added icat and fls0 APIs

Richard W.M. Jones rjones at redhat.com
Mon Mar 7 11:32:04 UTC 2016


On Sun, Mar 06, 2016 at 05:42:25PM +0200, Matteo Cafasso wrote:
> +static int
> +file_out (const char *cmd)
> +{
> +  int r;
> +  FILE *fp;
> +  char buffer[GUESTFS_MAX_CHUNK_SIZE];

Soon libguestfs will prevent you from using large stack allocations.
This is easy to fix.  See:
https://www.redhat.com/archives/libguestfs/2016-March/msg00052.html

> diff --git a/generator/actions.ml b/generator/actions.ml
> index 287d7f5..ff6aa3f 100644
> --- a/generator/actions.ml
> +++ b/generator/actions.ml
> @@ -12919,6 +12919,39 @@ within the C<$Extend> folder.
>  The filesystem from which to extract the file must be unmounted,
>  otherwise the call will fail." };
> 
> +  { defaults with
> +    name = "icat"; added = (1, 33, 14);
> +    style = RErr, [Mountable "device"; Int64 "inode"; FileOut "filename"], [];
> +    proc_nr = Some 464;
> +    optional = Some "icat";
> +    progress = true; cancellable = true;
> +    shortdesc = "download a file to the local machine given its inode";
> +    longdesc = "\
> +Download a file given its inode from the disk partition (eg. F</dev/sda1>)
> +and save it as F<filename> on the local machine.
> +
> +This allows to download deleted or inaccessible files." };

This one looks OK.

> +  { defaults with
> +    name = "fls0"; added = (1, 33, 14);
> +    style = RErr, [Mountable "device"; FileOut "filename"], [];
> +    proc_nr = Some 465;
> +    optional = Some "icat";
> +    progress = true; cancellable = true;
> +    shortdesc = "list the content of the disk";
> +    longdesc = "\
> +This specialized command is used to get a listing of
> +the content of the disk partition (eg. F</dev/sda1>).
> +The list of filenames is written to the local file F<filenames> (on the host).
> +
> +The command can display hidden or deleted files.
> +
> +The output information contains the file type, the metadata address
> +and the full path of the file.
> +
> +If the file was deleted, an asterisk will be shown between the file type
> +and the metadata address." };

As discussed, this shouldn't be a FileOut API at all.  It should
return a list of structs (RStructList).

If the output could be very large then we may need to split it into an
internal API, but let's not worry about that right now.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html




More information about the Libguestfs mailing list