1 {- libguestfs generated file
2 WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3 ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
5 Copyright (C) 2009 Red Hat Inc.
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 {-# INCLUDE <guestfs.h> #-}
23 {-# LANGUAGE ForeignFunctionInterface #-}
88 import Control.Exception
91 data GuestfsS = GuestfsS -- represents the opaque C struct
92 type GuestfsP = Ptr GuestfsS -- guestfs_h *
93 type GuestfsH = ForeignPtr GuestfsS -- guestfs_h * with attached finalizer
95 -- XXX define properly later XXX
99 data IntBool = IntBool
101 data StatVFS = StatVFS
102 data Hashtable = Hashtable
104 foreign import ccall unsafe "guestfs_create" c_create
106 foreign import ccall unsafe "&guestfs_close" c_close
107 :: FunPtr (GuestfsP -> IO ())
108 foreign import ccall unsafe "guestfs_set_error_handler" c_set_error_handler
109 :: GuestfsP -> Ptr CInt -> Ptr CInt -> IO ()
111 create :: IO GuestfsH
114 c_set_error_handler p nullPtr nullPtr
115 h <- newForeignPtr c_close p
118 foreign import ccall unsafe "guestfs_last_error" c_last_error
119 :: GuestfsP -> IO CString
121 -- last_error :: GuestfsH -> IO (Maybe String)
123 -- str <- withForeignPtr h (\p -> c_last_error p)
124 -- maybePeek peekCString str
126 last_error :: GuestfsH -> IO (String)
128 str <- withForeignPtr h (\p -> c_last_error p)
130 then return "no error"
133 foreign import ccall unsafe "guestfs_launch" c_launch
134 :: GuestfsP -> IO (CInt)
136 launch :: GuestfsH -> IO ()
138 r <- withForeignPtr h (\p -> c_launch p)
145 foreign import ccall unsafe "guestfs_wait_ready" c_wait_ready
146 :: GuestfsP -> IO (CInt)
148 wait_ready :: GuestfsH -> IO ()
150 r <- withForeignPtr h (\p -> c_wait_ready p)
157 foreign import ccall unsafe "guestfs_kill_subprocess" c_kill_subprocess
158 :: GuestfsP -> IO (CInt)
160 kill_subprocess :: GuestfsH -> IO ()
161 kill_subprocess h = do
162 r <- withForeignPtr h (\p -> c_kill_subprocess p)
169 foreign import ccall unsafe "guestfs_add_drive" c_add_drive
170 :: GuestfsP -> CString -> IO (CInt)
172 add_drive :: GuestfsH -> String -> IO ()
173 add_drive h filename = do
174 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_drive p filename)
181 foreign import ccall unsafe "guestfs_add_cdrom" c_add_cdrom
182 :: GuestfsP -> CString -> IO (CInt)
184 add_cdrom :: GuestfsH -> String -> IO ()
185 add_cdrom h filename = do
186 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_cdrom p filename)
193 foreign import ccall unsafe "guestfs_config" c_config
194 :: GuestfsP -> CString -> CString -> IO (CInt)
196 config :: GuestfsH -> String -> Maybe String -> IO ()
197 config h qemuparam qemuvalue = do
198 r <- withCString qemuparam $ \qemuparam -> maybeWith withCString qemuvalue $ \qemuvalue -> withForeignPtr h (\p -> c_config p qemuparam qemuvalue)
205 foreign import ccall unsafe "guestfs_set_qemu" c_set_qemu
206 :: GuestfsP -> CString -> IO (CInt)
208 set_qemu :: GuestfsH -> String -> IO ()
210 r <- withCString qemu $ \qemu -> withForeignPtr h (\p -> c_set_qemu p qemu)
217 foreign import ccall unsafe "guestfs_set_path" c_set_path
218 :: GuestfsP -> CString -> IO (CInt)
220 set_path :: GuestfsH -> String -> IO ()
222 r <- withCString path $ \path -> withForeignPtr h (\p -> c_set_path p path)
229 foreign import ccall unsafe "guestfs_set_append" c_set_append
230 :: GuestfsP -> CString -> IO (CInt)
232 set_append :: GuestfsH -> String -> IO ()
233 set_append h append = do
234 r <- withCString append $ \append -> withForeignPtr h (\p -> c_set_append p append)
241 foreign import ccall unsafe "guestfs_set_busy" c_set_busy
242 :: GuestfsP -> IO (CInt)
244 set_busy :: GuestfsH -> IO ()
246 r <- withForeignPtr h (\p -> c_set_busy p)
253 foreign import ccall unsafe "guestfs_set_ready" c_set_ready
254 :: GuestfsP -> IO (CInt)
256 set_ready :: GuestfsH -> IO ()
258 r <- withForeignPtr h (\p -> c_set_ready p)
265 foreign import ccall unsafe "guestfs_end_busy" c_end_busy
266 :: GuestfsP -> IO (CInt)
268 end_busy :: GuestfsH -> IO ()
270 r <- withForeignPtr h (\p -> c_end_busy p)
277 foreign import ccall unsafe "guestfs_mount" c_mount
278 :: GuestfsP -> CString -> CString -> IO (CInt)
280 mount :: GuestfsH -> String -> String -> IO ()
281 mount h device mountpoint = do
282 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount p device mountpoint)
289 foreign import ccall unsafe "guestfs_sync" c_sync
290 :: GuestfsP -> IO (CInt)
292 sync :: GuestfsH -> IO ()
294 r <- withForeignPtr h (\p -> c_sync p)
301 foreign import ccall unsafe "guestfs_touch" c_touch
302 :: GuestfsP -> CString -> IO (CInt)
304 touch :: GuestfsH -> String -> IO ()
306 r <- withCString path $ \path -> withForeignPtr h (\p -> c_touch p path)
313 foreign import ccall unsafe "guestfs_aug_close" c_aug_close
314 :: GuestfsP -> IO (CInt)
316 aug_close :: GuestfsH -> IO ()
318 r <- withForeignPtr h (\p -> c_aug_close p)
325 foreign import ccall unsafe "guestfs_aug_set" c_aug_set
326 :: GuestfsP -> CString -> CString -> IO (CInt)
328 aug_set :: GuestfsH -> String -> String -> IO ()
329 aug_set h path val = do
330 r <- withCString path $ \path -> withCString val $ \val -> withForeignPtr h (\p -> c_aug_set p path val)
337 foreign import ccall unsafe "guestfs_aug_mv" c_aug_mv
338 :: GuestfsP -> CString -> CString -> IO (CInt)
340 aug_mv :: GuestfsH -> String -> String -> IO ()
341 aug_mv h src dest = do
342 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_aug_mv p src dest)
349 foreign import ccall unsafe "guestfs_aug_save" c_aug_save
350 :: GuestfsP -> IO (CInt)
352 aug_save :: GuestfsH -> IO ()
354 r <- withForeignPtr h (\p -> c_aug_save p)
361 foreign import ccall unsafe "guestfs_aug_load" c_aug_load
362 :: GuestfsP -> IO (CInt)
364 aug_load :: GuestfsH -> IO ()
366 r <- withForeignPtr h (\p -> c_aug_load p)
373 foreign import ccall unsafe "guestfs_rm" c_rm
374 :: GuestfsP -> CString -> IO (CInt)
376 rm :: GuestfsH -> String -> IO ()
378 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm p path)
385 foreign import ccall unsafe "guestfs_rmdir" c_rmdir
386 :: GuestfsP -> CString -> IO (CInt)
388 rmdir :: GuestfsH -> String -> IO ()
390 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rmdir p path)
397 foreign import ccall unsafe "guestfs_rm_rf" c_rm_rf
398 :: GuestfsP -> CString -> IO (CInt)
400 rm_rf :: GuestfsH -> String -> IO ()
402 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm_rf p path)
409 foreign import ccall unsafe "guestfs_mkdir" c_mkdir
410 :: GuestfsP -> CString -> IO (CInt)
412 mkdir :: GuestfsH -> String -> IO ()
414 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir p path)
421 foreign import ccall unsafe "guestfs_mkdir_p" c_mkdir_p
422 :: GuestfsP -> CString -> IO (CInt)
424 mkdir_p :: GuestfsH -> String -> IO ()
426 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir_p p path)
433 foreign import ccall unsafe "guestfs_pvcreate" c_pvcreate
434 :: GuestfsP -> CString -> IO (CInt)
436 pvcreate :: GuestfsH -> String -> IO ()
437 pvcreate h device = do
438 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvcreate p device)
445 foreign import ccall unsafe "guestfs_vgcreate" c_vgcreate
446 :: GuestfsP -> CString -> Ptr CString -> IO (CInt)
448 vgcreate :: GuestfsH -> String -> [String] -> IO ()
449 vgcreate h volgroup physvols = do
450 r <- withCString volgroup $ \volgroup -> withMany withCString physvols $ \physvols -> withArray0 nullPtr physvols $ \physvols -> withForeignPtr h (\p -> c_vgcreate p volgroup physvols)
457 foreign import ccall unsafe "guestfs_mkfs" c_mkfs
458 :: GuestfsP -> CString -> CString -> IO (CInt)
460 mkfs :: GuestfsH -> String -> String -> IO ()
461 mkfs h fstype device = do
462 r <- withCString fstype $ \fstype -> withCString device $ \device -> withForeignPtr h (\p -> c_mkfs p fstype device)
469 foreign import ccall unsafe "guestfs_umount" c_umount
470 :: GuestfsP -> CString -> IO (CInt)
472 umount :: GuestfsH -> String -> IO ()
473 umount h pathordevice = do
474 r <- withCString pathordevice $ \pathordevice -> withForeignPtr h (\p -> c_umount p pathordevice)
481 foreign import ccall unsafe "guestfs_umount_all" c_umount_all
482 :: GuestfsP -> IO (CInt)
484 umount_all :: GuestfsH -> IO ()
486 r <- withForeignPtr h (\p -> c_umount_all p)
493 foreign import ccall unsafe "guestfs_lvm_remove_all" c_lvm_remove_all
494 :: GuestfsP -> IO (CInt)
496 lvm_remove_all :: GuestfsH -> IO ()
497 lvm_remove_all h = do
498 r <- withForeignPtr h (\p -> c_lvm_remove_all p)
505 foreign import ccall unsafe "guestfs_blockdev_setro" c_blockdev_setro
506 :: GuestfsP -> CString -> IO (CInt)
508 blockdev_setro :: GuestfsH -> String -> IO ()
509 blockdev_setro h device = do
510 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setro p device)
517 foreign import ccall unsafe "guestfs_blockdev_setrw" c_blockdev_setrw
518 :: GuestfsP -> CString -> IO (CInt)
520 blockdev_setrw :: GuestfsH -> String -> IO ()
521 blockdev_setrw h device = do
522 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setrw p device)
529 foreign import ccall unsafe "guestfs_blockdev_flushbufs" c_blockdev_flushbufs
530 :: GuestfsP -> CString -> IO (CInt)
532 blockdev_flushbufs :: GuestfsH -> String -> IO ()
533 blockdev_flushbufs h device = do
534 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_flushbufs p device)
541 foreign import ccall unsafe "guestfs_blockdev_rereadpt" c_blockdev_rereadpt
542 :: GuestfsP -> CString -> IO (CInt)
544 blockdev_rereadpt :: GuestfsH -> String -> IO ()
545 blockdev_rereadpt h device = do
546 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_rereadpt p device)
553 foreign import ccall unsafe "guestfs_upload" c_upload
554 :: GuestfsP -> CString -> CString -> IO (CInt)
556 upload :: GuestfsH -> String -> String -> IO ()
557 upload h filename remotefilename = do
558 r <- withCString filename $ \filename -> withCString remotefilename $ \remotefilename -> withForeignPtr h (\p -> c_upload p filename remotefilename)
565 foreign import ccall unsafe "guestfs_download" c_download
566 :: GuestfsP -> CString -> CString -> IO (CInt)
568 download :: GuestfsH -> String -> String -> IO ()
569 download h remotefilename filename = do
570 r <- withCString remotefilename $ \remotefilename -> withCString filename $ \filename -> withForeignPtr h (\p -> c_download p remotefilename filename)
577 foreign import ccall unsafe "guestfs_tar_in" c_tar_in
578 :: GuestfsP -> CString -> CString -> IO (CInt)
580 tar_in :: GuestfsH -> String -> String -> IO ()
581 tar_in h tarfile directory = do
582 r <- withCString tarfile $ \tarfile -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tar_in p tarfile directory)
589 foreign import ccall unsafe "guestfs_tar_out" c_tar_out
590 :: GuestfsP -> CString -> CString -> IO (CInt)
592 tar_out :: GuestfsH -> String -> String -> IO ()
593 tar_out h directory tarfile = do
594 r <- withCString directory $ \directory -> withCString tarfile $ \tarfile -> withForeignPtr h (\p -> c_tar_out p directory tarfile)
601 foreign import ccall unsafe "guestfs_tgz_in" c_tgz_in
602 :: GuestfsP -> CString -> CString -> IO (CInt)
604 tgz_in :: GuestfsH -> String -> String -> IO ()
605 tgz_in h tarball directory = do
606 r <- withCString tarball $ \tarball -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tgz_in p tarball directory)
613 foreign import ccall unsafe "guestfs_tgz_out" c_tgz_out
614 :: GuestfsP -> CString -> CString -> IO (CInt)
616 tgz_out :: GuestfsH -> String -> String -> IO ()
617 tgz_out h directory tarball = do
618 r <- withCString directory $ \directory -> withCString tarball $ \tarball -> withForeignPtr h (\p -> c_tgz_out p directory tarball)
625 foreign import ccall unsafe "guestfs_mount_ro" c_mount_ro
626 :: GuestfsP -> CString -> CString -> IO (CInt)
628 mount_ro :: GuestfsH -> String -> String -> IO ()
629 mount_ro h device mountpoint = do
630 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_ro p device mountpoint)
637 foreign import ccall unsafe "guestfs_mount_options" c_mount_options
638 :: GuestfsP -> CString -> CString -> CString -> IO (CInt)
640 mount_options :: GuestfsH -> String -> String -> String -> IO ()
641 mount_options h options device mountpoint = do
642 r <- withCString options $ \options -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_options p options device mountpoint)
649 foreign import ccall unsafe "guestfs_mount_vfs" c_mount_vfs
650 :: GuestfsP -> CString -> CString -> CString -> CString -> IO (CInt)
652 mount_vfs :: GuestfsH -> String -> String -> String -> String -> IO ()
653 mount_vfs h options vfstype device mountpoint = do
654 r <- withCString options $ \options -> withCString vfstype $ \vfstype -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_vfs p options vfstype device mountpoint)
661 foreign import ccall unsafe "guestfs_lvremove" c_lvremove
662 :: GuestfsP -> CString -> IO (CInt)
664 lvremove :: GuestfsH -> String -> IO ()
665 lvremove h device = do
666 r <- withCString device $ \device -> withForeignPtr h (\p -> c_lvremove p device)
673 foreign import ccall unsafe "guestfs_vgremove" c_vgremove
674 :: GuestfsP -> CString -> IO (CInt)
676 vgremove :: GuestfsH -> String -> IO ()
677 vgremove h vgname = do
678 r <- withCString vgname $ \vgname -> withForeignPtr h (\p -> c_vgremove p vgname)
685 foreign import ccall unsafe "guestfs_pvremove" c_pvremove
686 :: GuestfsP -> CString -> IO (CInt)
688 pvremove :: GuestfsH -> String -> IO ()
689 pvremove h device = do
690 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvremove p device)
697 foreign import ccall unsafe "guestfs_set_e2label" c_set_e2label
698 :: GuestfsP -> CString -> CString -> IO (CInt)
700 set_e2label :: GuestfsH -> String -> String -> IO ()
701 set_e2label h device label = do
702 r <- withCString device $ \device -> withCString label $ \label -> withForeignPtr h (\p -> c_set_e2label p device label)
709 foreign import ccall unsafe "guestfs_set_e2uuid" c_set_e2uuid
710 :: GuestfsP -> CString -> CString -> IO (CInt)
712 set_e2uuid :: GuestfsH -> String -> String -> IO ()
713 set_e2uuid h device uuid = do
714 r <- withCString device $ \device -> withCString uuid $ \uuid -> withForeignPtr h (\p -> c_set_e2uuid p device uuid)
721 foreign import ccall unsafe "guestfs_zero" c_zero
722 :: GuestfsP -> CString -> IO (CInt)
724 zero :: GuestfsH -> String -> IO ()
726 r <- withCString device $ \device -> withForeignPtr h (\p -> c_zero p device)
733 foreign import ccall unsafe "guestfs_grub_install" c_grub_install
734 :: GuestfsP -> CString -> CString -> IO (CInt)
736 grub_install :: GuestfsH -> String -> String -> IO ()
737 grub_install h root device = do
738 r <- withCString root $ \root -> withCString device $ \device -> withForeignPtr h (\p -> c_grub_install p root device)
745 foreign import ccall unsafe "guestfs_cp" c_cp
746 :: GuestfsP -> CString -> CString -> IO (CInt)
748 cp :: GuestfsH -> String -> String -> IO ()
750 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp p src dest)
757 foreign import ccall unsafe "guestfs_cp_a" c_cp_a
758 :: GuestfsP -> CString -> CString -> IO (CInt)
760 cp_a :: GuestfsH -> String -> String -> IO ()
762 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp_a p src dest)
769 foreign import ccall unsafe "guestfs_mv" c_mv
770 :: GuestfsP -> CString -> CString -> IO (CInt)
772 mv :: GuestfsH -> String -> String -> IO ()
774 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_mv p src dest)
781 foreign import ccall unsafe "guestfs_ping_daemon" c_ping_daemon
782 :: GuestfsP -> IO (CInt)
784 ping_daemon :: GuestfsH -> IO ()
786 r <- withForeignPtr h (\p -> c_ping_daemon p)
793 foreign import ccall unsafe "guestfs_zerofree" c_zerofree
794 :: GuestfsP -> CString -> IO (CInt)
796 zerofree :: GuestfsH -> String -> IO ()
797 zerofree h device = do
798 r <- withCString device $ \device -> withForeignPtr h (\p -> c_zerofree p device)
805 foreign import ccall unsafe "guestfs_pvresize" c_pvresize
806 :: GuestfsP -> CString -> IO (CInt)
808 pvresize :: GuestfsH -> String -> IO ()
809 pvresize h device = do
810 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvresize p device)