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 #-}
87 import Control.Exception
90 data GuestfsS = GuestfsS -- represents the opaque C struct
91 type GuestfsP = Ptr GuestfsS -- guestfs_h *
92 type GuestfsH = ForeignPtr GuestfsS -- guestfs_h * with attached finalizer
94 -- XXX define properly later XXX
98 data IntBool = IntBool
100 data StatVFS = StatVFS
101 data Hashtable = Hashtable
103 foreign import ccall unsafe "guestfs_create" c_create
105 foreign import ccall unsafe "&guestfs_close" c_close
106 :: FunPtr (GuestfsP -> IO ())
107 foreign import ccall unsafe "guestfs_set_error_handler" c_set_error_handler
108 :: GuestfsP -> Ptr CInt -> Ptr CInt -> IO ()
110 create :: IO GuestfsH
113 c_set_error_handler p nullPtr nullPtr
114 h <- newForeignPtr c_close p
117 foreign import ccall unsafe "guestfs_last_error" c_last_error
118 :: GuestfsP -> IO CString
120 -- last_error :: GuestfsH -> IO (Maybe String)
122 -- str <- withForeignPtr h (\p -> c_last_error p)
123 -- maybePeek peekCString str
125 last_error :: GuestfsH -> IO (String)
127 str <- withForeignPtr h (\p -> c_last_error p)
129 then return "no error"
132 foreign import ccall unsafe "guestfs_launch" c_launch
133 :: GuestfsP -> IO (CInt)
135 launch :: GuestfsH -> IO ()
137 r <- withForeignPtr h (\p -> c_launch p)
144 foreign import ccall unsafe "guestfs_wait_ready" c_wait_ready
145 :: GuestfsP -> IO (CInt)
147 wait_ready :: GuestfsH -> IO ()
149 r <- withForeignPtr h (\p -> c_wait_ready p)
156 foreign import ccall unsafe "guestfs_kill_subprocess" c_kill_subprocess
157 :: GuestfsP -> IO (CInt)
159 kill_subprocess :: GuestfsH -> IO ()
160 kill_subprocess h = do
161 r <- withForeignPtr h (\p -> c_kill_subprocess p)
168 foreign import ccall unsafe "guestfs_add_drive" c_add_drive
169 :: GuestfsP -> CString -> IO (CInt)
171 add_drive :: GuestfsH -> String -> IO ()
172 add_drive h filename = do
173 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_drive p filename)
180 foreign import ccall unsafe "guestfs_add_cdrom" c_add_cdrom
181 :: GuestfsP -> CString -> IO (CInt)
183 add_cdrom :: GuestfsH -> String -> IO ()
184 add_cdrom h filename = do
185 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_cdrom p filename)
192 foreign import ccall unsafe "guestfs_config" c_config
193 :: GuestfsP -> CString -> CString -> IO (CInt)
195 config :: GuestfsH -> String -> Maybe String -> IO ()
196 config h qemuparam qemuvalue = do
197 r <- withCString qemuparam $ \qemuparam -> maybeWith withCString qemuvalue $ \qemuvalue -> withForeignPtr h (\p -> c_config p qemuparam qemuvalue)
204 foreign import ccall unsafe "guestfs_set_qemu" c_set_qemu
205 :: GuestfsP -> CString -> IO (CInt)
207 set_qemu :: GuestfsH -> String -> IO ()
209 r <- withCString qemu $ \qemu -> withForeignPtr h (\p -> c_set_qemu p qemu)
216 foreign import ccall unsafe "guestfs_set_path" c_set_path
217 :: GuestfsP -> CString -> IO (CInt)
219 set_path :: GuestfsH -> String -> IO ()
221 r <- withCString path $ \path -> withForeignPtr h (\p -> c_set_path p path)
228 foreign import ccall unsafe "guestfs_set_append" c_set_append
229 :: GuestfsP -> CString -> IO (CInt)
231 set_append :: GuestfsH -> String -> IO ()
232 set_append h append = do
233 r <- withCString append $ \append -> withForeignPtr h (\p -> c_set_append p append)
240 foreign import ccall unsafe "guestfs_set_busy" c_set_busy
241 :: GuestfsP -> IO (CInt)
243 set_busy :: GuestfsH -> IO ()
245 r <- withForeignPtr h (\p -> c_set_busy p)
252 foreign import ccall unsafe "guestfs_set_ready" c_set_ready
253 :: GuestfsP -> IO (CInt)
255 set_ready :: GuestfsH -> IO ()
257 r <- withForeignPtr h (\p -> c_set_ready p)
264 foreign import ccall unsafe "guestfs_end_busy" c_end_busy
265 :: GuestfsP -> IO (CInt)
267 end_busy :: GuestfsH -> IO ()
269 r <- withForeignPtr h (\p -> c_end_busy p)
276 foreign import ccall unsafe "guestfs_mount" c_mount
277 :: GuestfsP -> CString -> CString -> IO (CInt)
279 mount :: GuestfsH -> String -> String -> IO ()
280 mount h device mountpoint = do
281 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount p device mountpoint)
288 foreign import ccall unsafe "guestfs_sync" c_sync
289 :: GuestfsP -> IO (CInt)
291 sync :: GuestfsH -> IO ()
293 r <- withForeignPtr h (\p -> c_sync p)
300 foreign import ccall unsafe "guestfs_touch" c_touch
301 :: GuestfsP -> CString -> IO (CInt)
303 touch :: GuestfsH -> String -> IO ()
305 r <- withCString path $ \path -> withForeignPtr h (\p -> c_touch p path)
312 foreign import ccall unsafe "guestfs_aug_close" c_aug_close
313 :: GuestfsP -> IO (CInt)
315 aug_close :: GuestfsH -> IO ()
317 r <- withForeignPtr h (\p -> c_aug_close p)
324 foreign import ccall unsafe "guestfs_aug_set" c_aug_set
325 :: GuestfsP -> CString -> CString -> IO (CInt)
327 aug_set :: GuestfsH -> String -> String -> IO ()
328 aug_set h path val = do
329 r <- withCString path $ \path -> withCString val $ \val -> withForeignPtr h (\p -> c_aug_set p path val)
336 foreign import ccall unsafe "guestfs_aug_mv" c_aug_mv
337 :: GuestfsP -> CString -> CString -> IO (CInt)
339 aug_mv :: GuestfsH -> String -> String -> IO ()
340 aug_mv h src dest = do
341 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_aug_mv p src dest)
348 foreign import ccall unsafe "guestfs_aug_save" c_aug_save
349 :: GuestfsP -> IO (CInt)
351 aug_save :: GuestfsH -> IO ()
353 r <- withForeignPtr h (\p -> c_aug_save p)
360 foreign import ccall unsafe "guestfs_aug_load" c_aug_load
361 :: GuestfsP -> IO (CInt)
363 aug_load :: GuestfsH -> IO ()
365 r <- withForeignPtr h (\p -> c_aug_load p)
372 foreign import ccall unsafe "guestfs_rm" c_rm
373 :: GuestfsP -> CString -> IO (CInt)
375 rm :: GuestfsH -> String -> IO ()
377 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm p path)
384 foreign import ccall unsafe "guestfs_rmdir" c_rmdir
385 :: GuestfsP -> CString -> IO (CInt)
387 rmdir :: GuestfsH -> String -> IO ()
389 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rmdir p path)
396 foreign import ccall unsafe "guestfs_rm_rf" c_rm_rf
397 :: GuestfsP -> CString -> IO (CInt)
399 rm_rf :: GuestfsH -> String -> IO ()
401 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm_rf p path)
408 foreign import ccall unsafe "guestfs_mkdir" c_mkdir
409 :: GuestfsP -> CString -> IO (CInt)
411 mkdir :: GuestfsH -> String -> IO ()
413 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir p path)
420 foreign import ccall unsafe "guestfs_mkdir_p" c_mkdir_p
421 :: GuestfsP -> CString -> IO (CInt)
423 mkdir_p :: GuestfsH -> String -> IO ()
425 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir_p p path)
432 foreign import ccall unsafe "guestfs_pvcreate" c_pvcreate
433 :: GuestfsP -> CString -> IO (CInt)
435 pvcreate :: GuestfsH -> String -> IO ()
436 pvcreate h device = do
437 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvcreate p device)
444 foreign import ccall unsafe "guestfs_vgcreate" c_vgcreate
445 :: GuestfsP -> CString -> Ptr CString -> IO (CInt)
447 vgcreate :: GuestfsH -> String -> [String] -> IO ()
448 vgcreate h volgroup physvols = do
449 r <- withCString volgroup $ \volgroup -> withMany withCString physvols $ \physvols -> withArray0 nullPtr physvols $ \physvols -> withForeignPtr h (\p -> c_vgcreate p volgroup physvols)
456 foreign import ccall unsafe "guestfs_mkfs" c_mkfs
457 :: GuestfsP -> CString -> CString -> IO (CInt)
459 mkfs :: GuestfsH -> String -> String -> IO ()
460 mkfs h fstype device = do
461 r <- withCString fstype $ \fstype -> withCString device $ \device -> withForeignPtr h (\p -> c_mkfs p fstype device)
468 foreign import ccall unsafe "guestfs_umount" c_umount
469 :: GuestfsP -> CString -> IO (CInt)
471 umount :: GuestfsH -> String -> IO ()
472 umount h pathordevice = do
473 r <- withCString pathordevice $ \pathordevice -> withForeignPtr h (\p -> c_umount p pathordevice)
480 foreign import ccall unsafe "guestfs_umount_all" c_umount_all
481 :: GuestfsP -> IO (CInt)
483 umount_all :: GuestfsH -> IO ()
485 r <- withForeignPtr h (\p -> c_umount_all p)
492 foreign import ccall unsafe "guestfs_lvm_remove_all" c_lvm_remove_all
493 :: GuestfsP -> IO (CInt)
495 lvm_remove_all :: GuestfsH -> IO ()
496 lvm_remove_all h = do
497 r <- withForeignPtr h (\p -> c_lvm_remove_all p)
504 foreign import ccall unsafe "guestfs_blockdev_setro" c_blockdev_setro
505 :: GuestfsP -> CString -> IO (CInt)
507 blockdev_setro :: GuestfsH -> String -> IO ()
508 blockdev_setro h device = do
509 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setro p device)
516 foreign import ccall unsafe "guestfs_blockdev_setrw" c_blockdev_setrw
517 :: GuestfsP -> CString -> IO (CInt)
519 blockdev_setrw :: GuestfsH -> String -> IO ()
520 blockdev_setrw h device = do
521 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setrw p device)
528 foreign import ccall unsafe "guestfs_blockdev_flushbufs" c_blockdev_flushbufs
529 :: GuestfsP -> CString -> IO (CInt)
531 blockdev_flushbufs :: GuestfsH -> String -> IO ()
532 blockdev_flushbufs h device = do
533 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_flushbufs p device)
540 foreign import ccall unsafe "guestfs_blockdev_rereadpt" c_blockdev_rereadpt
541 :: GuestfsP -> CString -> IO (CInt)
543 blockdev_rereadpt :: GuestfsH -> String -> IO ()
544 blockdev_rereadpt h device = do
545 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_rereadpt p device)
552 foreign import ccall unsafe "guestfs_upload" c_upload
553 :: GuestfsP -> CString -> CString -> IO (CInt)
555 upload :: GuestfsH -> String -> String -> IO ()
556 upload h filename remotefilename = do
557 r <- withCString filename $ \filename -> withCString remotefilename $ \remotefilename -> withForeignPtr h (\p -> c_upload p filename remotefilename)
564 foreign import ccall unsafe "guestfs_download" c_download
565 :: GuestfsP -> CString -> CString -> IO (CInt)
567 download :: GuestfsH -> String -> String -> IO ()
568 download h remotefilename filename = do
569 r <- withCString remotefilename $ \remotefilename -> withCString filename $ \filename -> withForeignPtr h (\p -> c_download p remotefilename filename)
576 foreign import ccall unsafe "guestfs_tar_in" c_tar_in
577 :: GuestfsP -> CString -> CString -> IO (CInt)
579 tar_in :: GuestfsH -> String -> String -> IO ()
580 tar_in h tarfile directory = do
581 r <- withCString tarfile $ \tarfile -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tar_in p tarfile directory)
588 foreign import ccall unsafe "guestfs_tar_out" c_tar_out
589 :: GuestfsP -> CString -> CString -> IO (CInt)
591 tar_out :: GuestfsH -> String -> String -> IO ()
592 tar_out h directory tarfile = do
593 r <- withCString directory $ \directory -> withCString tarfile $ \tarfile -> withForeignPtr h (\p -> c_tar_out p directory tarfile)
600 foreign import ccall unsafe "guestfs_tgz_in" c_tgz_in
601 :: GuestfsP -> CString -> CString -> IO (CInt)
603 tgz_in :: GuestfsH -> String -> String -> IO ()
604 tgz_in h tarball directory = do
605 r <- withCString tarball $ \tarball -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tgz_in p tarball directory)
612 foreign import ccall unsafe "guestfs_tgz_out" c_tgz_out
613 :: GuestfsP -> CString -> CString -> IO (CInt)
615 tgz_out :: GuestfsH -> String -> String -> IO ()
616 tgz_out h directory tarball = do
617 r <- withCString directory $ \directory -> withCString tarball $ \tarball -> withForeignPtr h (\p -> c_tgz_out p directory tarball)
624 foreign import ccall unsafe "guestfs_mount_ro" c_mount_ro
625 :: GuestfsP -> CString -> CString -> IO (CInt)
627 mount_ro :: GuestfsH -> String -> String -> IO ()
628 mount_ro h device mountpoint = do
629 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_ro p device mountpoint)
636 foreign import ccall unsafe "guestfs_mount_options" c_mount_options
637 :: GuestfsP -> CString -> CString -> CString -> IO (CInt)
639 mount_options :: GuestfsH -> String -> String -> String -> IO ()
640 mount_options h options device mountpoint = do
641 r <- withCString options $ \options -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_options p options device mountpoint)
648 foreign import ccall unsafe "guestfs_mount_vfs" c_mount_vfs
649 :: GuestfsP -> CString -> CString -> CString -> CString -> IO (CInt)
651 mount_vfs :: GuestfsH -> String -> String -> String -> String -> IO ()
652 mount_vfs h options vfstype device mountpoint = do
653 r <- withCString options $ \options -> withCString vfstype $ \vfstype -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_vfs p options vfstype device mountpoint)
660 foreign import ccall unsafe "guestfs_lvremove" c_lvremove
661 :: GuestfsP -> CString -> IO (CInt)
663 lvremove :: GuestfsH -> String -> IO ()
664 lvremove h device = do
665 r <- withCString device $ \device -> withForeignPtr h (\p -> c_lvremove p device)
672 foreign import ccall unsafe "guestfs_vgremove" c_vgremove
673 :: GuestfsP -> CString -> IO (CInt)
675 vgremove :: GuestfsH -> String -> IO ()
676 vgremove h vgname = do
677 r <- withCString vgname $ \vgname -> withForeignPtr h (\p -> c_vgremove p vgname)
684 foreign import ccall unsafe "guestfs_pvremove" c_pvremove
685 :: GuestfsP -> CString -> IO (CInt)
687 pvremove :: GuestfsH -> String -> IO ()
688 pvremove h device = do
689 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvremove p device)
696 foreign import ccall unsafe "guestfs_set_e2label" c_set_e2label
697 :: GuestfsP -> CString -> CString -> IO (CInt)
699 set_e2label :: GuestfsH -> String -> String -> IO ()
700 set_e2label h device label = do
701 r <- withCString device $ \device -> withCString label $ \label -> withForeignPtr h (\p -> c_set_e2label p device label)
708 foreign import ccall unsafe "guestfs_set_e2uuid" c_set_e2uuid
709 :: GuestfsP -> CString -> CString -> IO (CInt)
711 set_e2uuid :: GuestfsH -> String -> String -> IO ()
712 set_e2uuid h device uuid = do
713 r <- withCString device $ \device -> withCString uuid $ \uuid -> withForeignPtr h (\p -> c_set_e2uuid p device uuid)
720 foreign import ccall unsafe "guestfs_zero" c_zero
721 :: GuestfsP -> CString -> IO (CInt)
723 zero :: GuestfsH -> String -> IO ()
725 r <- withCString device $ \device -> withForeignPtr h (\p -> c_zero p device)
732 foreign import ccall unsafe "guestfs_grub_install" c_grub_install
733 :: GuestfsP -> CString -> CString -> IO (CInt)
735 grub_install :: GuestfsH -> String -> String -> IO ()
736 grub_install h root device = do
737 r <- withCString root $ \root -> withCString device $ \device -> withForeignPtr h (\p -> c_grub_install p root device)
744 foreign import ccall unsafe "guestfs_cp" c_cp
745 :: GuestfsP -> CString -> CString -> IO (CInt)
747 cp :: GuestfsH -> String -> String -> IO ()
749 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp p src dest)
756 foreign import ccall unsafe "guestfs_cp_a" c_cp_a
757 :: GuestfsP -> CString -> CString -> IO (CInt)
759 cp_a :: GuestfsH -> String -> String -> IO ()
761 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp_a p src dest)
768 foreign import ccall unsafe "guestfs_mv" c_mv
769 :: GuestfsP -> CString -> CString -> IO (CInt)
771 mv :: GuestfsH -> String -> String -> IO ()
773 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_mv p src dest)
780 foreign import ccall unsafe "guestfs_ping_daemon" c_ping_daemon
781 :: GuestfsP -> IO (CInt)
783 ping_daemon :: GuestfsH -> IO ()
785 r <- withForeignPtr h (\p -> c_ping_daemon p)
792 foreign import ccall unsafe "guestfs_zerofree" c_zerofree
793 :: GuestfsP -> CString -> IO (CInt)
795 zerofree :: GuestfsH -> String -> IO ()
796 zerofree h device = do
797 r <- withCString device $ \device -> withForeignPtr h (\p -> c_zerofree p device)