Hi, I have tried to extract *.vhd* file using guestfs library. I am able to list all files inside my archive using *guestfs_ls* also * guestfs_list_filesystems()* retruns right File system information. I am trying to extract files from inside archive using *guestfs_copy_device_to_file() * but it returns following error (error: copy_device_to_file: unknown option 689330304 (this can happen if a program is compiled against a newer version of libguestfs, then dynamically linked to an older version)). Please see attached main.c for my sample code. Regards MUHAMMAD MOSHIN
On Thu, Feb 09, 2017 at 03:24:53PM +0500, MUHAMMAD MOHSIN wrote:> * but it returns following error (error: copy_device_to_file: unknown > option 689330304 (this can happen if a program is compiled against a newer > version of libguestfs, then dynamically linked to an older version)). > Please see attached main.c for my sample code.I don't know about the above error, but the way you've used copy-device-to-file is clearly wrong:> guestfs_mount (g, "/dev/sda1", "/"); > > //guestfs_mount_local (g, "/home/mohsin/VHD/"); > guestfs_ls(g, "/"); > guestfs_copy_device_to_file(g, "/dev/sda1/file-to extract.exe", "/abc.exe");It's actually not clear to me what you're trying to achieve here. Download the file to the local host? If so use guestfs_download: guestfs_download (g, "/file-to-extract.exe", "local-file.exe"); BTW you should check for errors from C API calls. http://libguestfs.org/guestfs.3.html#downloading http://libguestfs.org/guestfs.3.html#error-handling 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
On Thu, Feb 09, 2017 at 09:13:24PM +0000, Richard W.M. Jones wrote:> On Thu, Feb 09, 2017 at 03:24:53PM +0500, MUHAMMAD MOHSIN wrote: > > * but it returns following error (error: copy_device_to_file: unknown > > option 689330304 (this can happen if a program is compiled against a newer > > version of libguestfs, then dynamically linked to an older version)). > > Please see attached main.c for my sample code. > > I don't know about the above error,Actually I've realized what's wrong that's giving the above error too.> > guestfs_copy_device_to_file(g, "/dev/sda1/file-to extract.exe", "/abc.exe");This API takes a variable list of parameters terminated with -1, and since you've omitted that, it's reading off the end of the args. http://libguestfs.org/guestfs.3.html#guestfs_copy_device_to_file You probably shouldn't be using that API so this doesn't matter, but it's best to clear it up. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Thanks a lot. I was trying to copy on local disk and guestfs_download () solved my problem. Now I am trying to modify source code of guestfs_download () to extract file in memory. Can you guide me what should i do to achieve that. Mohsin On Fri, Feb 10, 2017 at 2:13 AM, Richard W.M. Jones <rjones@redhat.com> wrote:> On Thu, Feb 09, 2017 at 03:24:53PM +0500, MUHAMMAD MOHSIN wrote: > > * but it returns following error (error: copy_device_to_file: unknown > > option 689330304 (this can happen if a program is compiled against a > newer > > version of libguestfs, then dynamically linked to an older version)). > > Please see attached main.c for my sample code. > > I don't know about the above error, but the way you've used > copy-device-to-file is clearly wrong: > > > guestfs_mount (g, "/dev/sda1", "/"); > > > > //guestfs_mount_local (g, "/home/mohsin/VHD/"); > > guestfs_ls(g, "/"); > > guestfs_copy_device_to_file(g, "/dev/sda1/file-to extract.exe", > "/abc.exe"); > > It's actually not clear to me what you're trying to achieve here. > Download the file to the local host? If so use guestfs_download: > > guestfs_download (g, "/file-to-extract.exe", "local-file.exe"); > > BTW you should check for errors from C API calls. > > http://libguestfs.org/guestfs.3.html#downloading > http://libguestfs.org/guestfs.3.html#error-handling > > 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 >-- MUHAMMAD MOSHIN CIIT, ABBOTTABAD