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 #-}
89 import Control.Exception
92 data GuestfsS = GuestfsS -- represents the opaque C struct
93 type GuestfsP = Ptr GuestfsS -- guestfs_h *
94 type GuestfsH = ForeignPtr GuestfsS -- guestfs_h * with attached finalizer
96 -- XXX define properly later XXX
100 data IntBool = IntBool
102 data StatVFS = StatVFS
103 data Hashtable = Hashtable
105 foreign import ccall unsafe "guestfs_create" c_create
107 foreign import ccall unsafe "&guestfs_close" c_close
108 :: FunPtr (GuestfsP -> IO ())
109 foreign import ccall unsafe "guestfs_set_error_handler" c_set_error_handler
110 :: GuestfsP -> Ptr CInt -> Ptr CInt -> IO ()
112 create :: IO GuestfsH
115 c_set_error_handler p nullPtr nullPtr
116 h <- newForeignPtr c_close p
119 foreign import ccall unsafe "guestfs_last_error" c_last_error
120 :: GuestfsP -> IO CString
122 -- last_error :: GuestfsH -> IO (Maybe String)
124 -- str <- withForeignPtr h (\p -> c_last_error p)
125 -- maybePeek peekCString str
127 last_error :: GuestfsH -> IO (String)
129 str <- withForeignPtr h (\p -> c_last_error p)
131 then return "no error"
134 foreign import ccall unsafe "guestfs_launch" c_launch
135 :: GuestfsP -> IO (CInt)
137 launch :: GuestfsH -> IO ()
139 r <- withForeignPtr h (\p -> c_launch p)
146 foreign import ccall unsafe "guestfs_wait_ready" c_wait_ready
147 :: GuestfsP -> IO (CInt)
149 wait_ready :: GuestfsH -> IO ()
151 r <- withForeignPtr h (\p -> c_wait_ready p)
158 foreign import ccall unsafe "guestfs_kill_subprocess" c_kill_subprocess
159 :: GuestfsP -> IO (CInt)
161 kill_subprocess :: GuestfsH -> IO ()
162 kill_subprocess h = do
163 r <- withForeignPtr h (\p -> c_kill_subprocess p)
170 foreign import ccall unsafe "guestfs_add_drive" c_add_drive
171 :: GuestfsP -> CString -> IO (CInt)
173 add_drive :: GuestfsH -> String -> IO ()
174 add_drive h filename = do
175 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_drive p filename)
182 foreign import ccall unsafe "guestfs_add_cdrom" c_add_cdrom
183 :: GuestfsP -> CString -> IO (CInt)
185 add_cdrom :: GuestfsH -> String -> IO ()
186 add_cdrom h filename = do
187 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_cdrom p filename)
194 foreign import ccall unsafe "guestfs_config" c_config
195 :: GuestfsP -> CString -> CString -> IO (CInt)
197 config :: GuestfsH -> String -> Maybe String -> IO ()
198 config h qemuparam qemuvalue = do
199 r <- withCString qemuparam $ \qemuparam -> maybeWith withCString qemuvalue $ \qemuvalue -> withForeignPtr h (\p -> c_config p qemuparam qemuvalue)
206 foreign import ccall unsafe "guestfs_set_qemu" c_set_qemu
207 :: GuestfsP -> CString -> IO (CInt)
209 set_qemu :: GuestfsH -> String -> IO ()
211 r <- withCString qemu $ \qemu -> withForeignPtr h (\p -> c_set_qemu p qemu)
218 foreign import ccall unsafe "guestfs_set_path" c_set_path
219 :: GuestfsP -> CString -> IO (CInt)
221 set_path :: GuestfsH -> String -> IO ()
223 r <- withCString path $ \path -> withForeignPtr h (\p -> c_set_path p path)
230 foreign import ccall unsafe "guestfs_set_append" c_set_append
231 :: GuestfsP -> CString -> IO (CInt)
233 set_append :: GuestfsH -> String -> IO ()
234 set_append h append = do
235 r <- withCString append $ \append -> withForeignPtr h (\p -> c_set_append p append)
242 foreign import ccall unsafe "guestfs_set_busy" c_set_busy
243 :: GuestfsP -> IO (CInt)
245 set_busy :: GuestfsH -> IO ()
247 r <- withForeignPtr h (\p -> c_set_busy p)
254 foreign import ccall unsafe "guestfs_set_ready" c_set_ready
255 :: GuestfsP -> IO (CInt)
257 set_ready :: GuestfsH -> IO ()
259 r <- withForeignPtr h (\p -> c_set_ready p)
266 foreign import ccall unsafe "guestfs_end_busy" c_end_busy
267 :: GuestfsP -> IO (CInt)
269 end_busy :: GuestfsH -> IO ()
271 r <- withForeignPtr h (\p -> c_end_busy p)
278 foreign import ccall unsafe "guestfs_mount" c_mount
279 :: GuestfsP -> CString -> CString -> IO (CInt)
281 mount :: GuestfsH -> String -> String -> IO ()
282 mount h device mountpoint = do
283 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount p device mountpoint)
290 foreign import ccall unsafe "guestfs_sync" c_sync
291 :: GuestfsP -> IO (CInt)
293 sync :: GuestfsH -> IO ()
295 r <- withForeignPtr h (\p -> c_sync p)
302 foreign import ccall unsafe "guestfs_touch" c_touch
303 :: GuestfsP -> CString -> IO (CInt)
305 touch :: GuestfsH -> String -> IO ()
307 r <- withCString path $ \path -> withForeignPtr h (\p -> c_touch p path)
314 foreign import ccall unsafe "guestfs_aug_close" c_aug_close
315 :: GuestfsP -> IO (CInt)
317 aug_close :: GuestfsH -> IO ()
319 r <- withForeignPtr h (\p -> c_aug_close p)
326 foreign import ccall unsafe "guestfs_aug_set" c_aug_set
327 :: GuestfsP -> CString -> CString -> IO (CInt)
329 aug_set :: GuestfsH -> String -> String -> IO ()
330 aug_set h path val = do
331 r <- withCString path $ \path -> withCString val $ \val -> withForeignPtr h (\p -> c_aug_set p path val)
338 foreign import ccall unsafe "guestfs_aug_mv" c_aug_mv
339 :: GuestfsP -> CString -> CString -> IO (CInt)
341 aug_mv :: GuestfsH -> String -> String -> IO ()
342 aug_mv h src dest = do
343 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_aug_mv p src dest)
350 foreign import ccall unsafe "guestfs_aug_save" c_aug_save
351 :: GuestfsP -> IO (CInt)
353 aug_save :: GuestfsH -> IO ()
355 r <- withForeignPtr h (\p -> c_aug_save p)
362 foreign import ccall unsafe "guestfs_aug_load" c_aug_load
363 :: GuestfsP -> IO (CInt)
365 aug_load :: GuestfsH -> IO ()
367 r <- withForeignPtr h (\p -> c_aug_load p)
374 foreign import ccall unsafe "guestfs_rm" c_rm
375 :: GuestfsP -> CString -> IO (CInt)
377 rm :: GuestfsH -> String -> IO ()
379 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm p path)
386 foreign import ccall unsafe "guestfs_rmdir" c_rmdir
387 :: GuestfsP -> CString -> IO (CInt)
389 rmdir :: GuestfsH -> String -> IO ()
391 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rmdir p path)
398 foreign import ccall unsafe "guestfs_rm_rf" c_rm_rf
399 :: GuestfsP -> CString -> IO (CInt)
401 rm_rf :: GuestfsH -> String -> IO ()
403 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm_rf p path)
410 foreign import ccall unsafe "guestfs_mkdir" c_mkdir
411 :: GuestfsP -> CString -> IO (CInt)
413 mkdir :: GuestfsH -> String -> IO ()
415 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir p path)
422 foreign import ccall unsafe "guestfs_mkdir_p" c_mkdir_p
423 :: GuestfsP -> CString -> IO (CInt)
425 mkdir_p :: GuestfsH -> String -> IO ()
427 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir_p p path)
434 foreign import ccall unsafe "guestfs_pvcreate" c_pvcreate
435 :: GuestfsP -> CString -> IO (CInt)
437 pvcreate :: GuestfsH -> String -> IO ()
438 pvcreate h device = do
439 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvcreate p device)
446 foreign import ccall unsafe "guestfs_vgcreate" c_vgcreate
447 :: GuestfsP -> CString -> Ptr CString -> IO (CInt)
449 vgcreate :: GuestfsH -> String -> [String] -> IO ()
450 vgcreate h volgroup physvols = do
451 r <- withCString volgroup $ \volgroup -> withMany withCString physvols $ \physvols -> withArray0 nullPtr physvols $ \physvols -> withForeignPtr h (\p -> c_vgcreate p volgroup physvols)
458 foreign import ccall unsafe "guestfs_mkfs" c_mkfs
459 :: GuestfsP -> CString -> CString -> IO (CInt)
461 mkfs :: GuestfsH -> String -> String -> IO ()
462 mkfs h fstype device = do
463 r <- withCString fstype $ \fstype -> withCString device $ \device -> withForeignPtr h (\p -> c_mkfs p fstype device)
470 foreign import ccall unsafe "guestfs_umount" c_umount
471 :: GuestfsP -> CString -> IO (CInt)
473 umount :: GuestfsH -> String -> IO ()
474 umount h pathordevice = do
475 r <- withCString pathordevice $ \pathordevice -> withForeignPtr h (\p -> c_umount p pathordevice)
482 foreign import ccall unsafe "guestfs_umount_all" c_umount_all
483 :: GuestfsP -> IO (CInt)
485 umount_all :: GuestfsH -> IO ()
487 r <- withForeignPtr h (\p -> c_umount_all p)
494 foreign import ccall unsafe "guestfs_lvm_remove_all" c_lvm_remove_all
495 :: GuestfsP -> IO (CInt)
497 lvm_remove_all :: GuestfsH -> IO ()
498 lvm_remove_all h = do
499 r <- withForeignPtr h (\p -> c_lvm_remove_all p)
506 foreign import ccall unsafe "guestfs_blockdev_setro" c_blockdev_setro
507 :: GuestfsP -> CString -> IO (CInt)
509 blockdev_setro :: GuestfsH -> String -> IO ()
510 blockdev_setro h device = do
511 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setro p device)
518 foreign import ccall unsafe "guestfs_blockdev_setrw" c_blockdev_setrw
519 :: GuestfsP -> CString -> IO (CInt)
521 blockdev_setrw :: GuestfsH -> String -> IO ()
522 blockdev_setrw h device = do
523 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setrw p device)
530 foreign import ccall unsafe "guestfs_blockdev_flushbufs" c_blockdev_flushbufs
531 :: GuestfsP -> CString -> IO (CInt)
533 blockdev_flushbufs :: GuestfsH -> String -> IO ()
534 blockdev_flushbufs h device = do
535 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_flushbufs p device)
542 foreign import ccall unsafe "guestfs_blockdev_rereadpt" c_blockdev_rereadpt
543 :: GuestfsP -> CString -> IO (CInt)
545 blockdev_rereadpt :: GuestfsH -> String -> IO ()
546 blockdev_rereadpt h device = do
547 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_rereadpt p device)
554 foreign import ccall unsafe "guestfs_upload" c_upload
555 :: GuestfsP -> CString -> CString -> IO (CInt)
557 upload :: GuestfsH -> String -> String -> IO ()
558 upload h filename remotefilename = do
559 r <- withCString filename $ \filename -> withCString remotefilename $ \remotefilename -> withForeignPtr h (\p -> c_upload p filename remotefilename)
566 foreign import ccall unsafe "guestfs_download" c_download
567 :: GuestfsP -> CString -> CString -> IO (CInt)
569 download :: GuestfsH -> String -> String -> IO ()
570 download h remotefilename filename = do
571 r <- withCString remotefilename $ \remotefilename -> withCString filename $ \filename -> withForeignPtr h (\p -> c_download p remotefilename filename)
578 foreign import ccall unsafe "guestfs_tar_in" c_tar_in
579 :: GuestfsP -> CString -> CString -> IO (CInt)
581 tar_in :: GuestfsH -> String -> String -> IO ()
582 tar_in h tarfile directory = do
583 r <- withCString tarfile $ \tarfile -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tar_in p tarfile directory)
590 foreign import ccall unsafe "guestfs_tar_out" c_tar_out
591 :: GuestfsP -> CString -> CString -> IO (CInt)
593 tar_out :: GuestfsH -> String -> String -> IO ()
594 tar_out h directory tarfile = do
595 r <- withCString directory $ \directory -> withCString tarfile $ \tarfile -> withForeignPtr h (\p -> c_tar_out p directory tarfile)
602 foreign import ccall unsafe "guestfs_tgz_in" c_tgz_in
603 :: GuestfsP -> CString -> CString -> IO (CInt)
605 tgz_in :: GuestfsH -> String -> String -> IO ()
606 tgz_in h tarball directory = do
607 r <- withCString tarball $ \tarball -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tgz_in p tarball directory)
614 foreign import ccall unsafe "guestfs_tgz_out" c_tgz_out
615 :: GuestfsP -> CString -> CString -> IO (CInt)
617 tgz_out :: GuestfsH -> String -> String -> IO ()
618 tgz_out h directory tarball = do
619 r <- withCString directory $ \directory -> withCString tarball $ \tarball -> withForeignPtr h (\p -> c_tgz_out p directory tarball)
626 foreign import ccall unsafe "guestfs_mount_ro" c_mount_ro
627 :: GuestfsP -> CString -> CString -> IO (CInt)
629 mount_ro :: GuestfsH -> String -> String -> IO ()
630 mount_ro h device mountpoint = do
631 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_ro p device mountpoint)
638 foreign import ccall unsafe "guestfs_mount_options" c_mount_options
639 :: GuestfsP -> CString -> CString -> CString -> IO (CInt)
641 mount_options :: GuestfsH -> String -> String -> String -> IO ()
642 mount_options h options device mountpoint = do
643 r <- withCString options $ \options -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_options p options device mountpoint)
650 foreign import ccall unsafe "guestfs_mount_vfs" c_mount_vfs
651 :: GuestfsP -> CString -> CString -> CString -> CString -> IO (CInt)
653 mount_vfs :: GuestfsH -> String -> String -> String -> String -> IO ()
654 mount_vfs h options vfstype device mountpoint = do
655 r <- withCString options $ \options -> withCString vfstype $ \vfstype -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_vfs p options vfstype device mountpoint)
662 foreign import ccall unsafe "guestfs_lvremove" c_lvremove
663 :: GuestfsP -> CString -> IO (CInt)
665 lvremove :: GuestfsH -> String -> IO ()
666 lvremove h device = do
667 r <- withCString device $ \device -> withForeignPtr h (\p -> c_lvremove p device)
674 foreign import ccall unsafe "guestfs_vgremove" c_vgremove
675 :: GuestfsP -> CString -> IO (CInt)
677 vgremove :: GuestfsH -> String -> IO ()
678 vgremove h vgname = do
679 r <- withCString vgname $ \vgname -> withForeignPtr h (\p -> c_vgremove p vgname)
686 foreign import ccall unsafe "guestfs_pvremove" c_pvremove
687 :: GuestfsP -> CString -> IO (CInt)
689 pvremove :: GuestfsH -> String -> IO ()
690 pvremove h device = do
691 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvremove p device)
698 foreign import ccall unsafe "guestfs_set_e2label" c_set_e2label
699 :: GuestfsP -> CString -> CString -> IO (CInt)
701 set_e2label :: GuestfsH -> String -> String -> IO ()
702 set_e2label h device label = do
703 r <- withCString device $ \device -> withCString label $ \label -> withForeignPtr h (\p -> c_set_e2label p device label)
710 foreign import ccall unsafe "guestfs_set_e2uuid" c_set_e2uuid
711 :: GuestfsP -> CString -> CString -> IO (CInt)
713 set_e2uuid :: GuestfsH -> String -> String -> IO ()
714 set_e2uuid h device uuid = do
715 r <- withCString device $ \device -> withCString uuid $ \uuid -> withForeignPtr h (\p -> c_set_e2uuid p device uuid)
722 foreign import ccall unsafe "guestfs_zero" c_zero
723 :: GuestfsP -> CString -> IO (CInt)
725 zero :: GuestfsH -> String -> IO ()
727 r <- withCString device $ \device -> withForeignPtr h (\p -> c_zero p device)
734 foreign import ccall unsafe "guestfs_grub_install" c_grub_install
735 :: GuestfsP -> CString -> CString -> IO (CInt)
737 grub_install :: GuestfsH -> String -> String -> IO ()
738 grub_install h root device = do
739 r <- withCString root $ \root -> withCString device $ \device -> withForeignPtr h (\p -> c_grub_install p root device)
746 foreign import ccall unsafe "guestfs_cp" c_cp
747 :: GuestfsP -> CString -> CString -> IO (CInt)
749 cp :: GuestfsH -> String -> String -> IO ()
751 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp p src dest)
758 foreign import ccall unsafe "guestfs_cp_a" c_cp_a
759 :: GuestfsP -> CString -> CString -> IO (CInt)
761 cp_a :: GuestfsH -> String -> String -> IO ()
763 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp_a p src dest)
770 foreign import ccall unsafe "guestfs_mv" c_mv
771 :: GuestfsP -> CString -> CString -> IO (CInt)
773 mv :: GuestfsH -> String -> String -> IO ()
775 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_mv p src dest)
782 foreign import ccall unsafe "guestfs_ping_daemon" c_ping_daemon
783 :: GuestfsP -> IO (CInt)
785 ping_daemon :: GuestfsH -> IO ()
787 r <- withForeignPtr h (\p -> c_ping_daemon p)
794 foreign import ccall unsafe "guestfs_zerofree" c_zerofree
795 :: GuestfsP -> CString -> IO (CInt)
797 zerofree :: GuestfsH -> String -> IO ()
798 zerofree h device = do
799 r <- withCString device $ \device -> withForeignPtr h (\p -> c_zerofree p device)
806 foreign import ccall unsafe "guestfs_pvresize" c_pvresize
807 :: GuestfsP -> CString -> IO (CInt)
809 pvresize :: GuestfsH -> String -> IO ()
810 pvresize h device = do
811 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvresize p device)
818 foreign import ccall unsafe "guestfs_resize2fs" c_resize2fs
819 :: GuestfsP -> CString -> IO (CInt)
821 resize2fs :: GuestfsH -> String -> IO ()
822 resize2fs h device = do
823 r <- withCString device $ \device -> withForeignPtr h (\p -> c_resize2fs p device)