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

2016-03-07 Thread noxdafox

On 07/03/16 13:32, Richard W.M. Jones wrote:

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

Will fix it.



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)
+and save it as F 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).
+The list of filenames is written to the local file F (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.

This is exactly the internal API that's why I appended the 0 to the name xD.

As I explained in the previous e-mail. What is missing is the higher 
level API returning the RStructList.


Rich.



___
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs


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

2016-03-07 Thread Richard W.M. Jones
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)
> +and save it as F 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).
> +The list of filenames is written to the local file F (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

___
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs