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 #-}
86 import Control.Exception
89 data GuestfsS = GuestfsS -- represents the opaque C struct
90 type GuestfsP = Ptr GuestfsS -- guestfs_h *
91 type GuestfsH = ForeignPtr GuestfsS -- guestfs_h * with attached finalizer
93 -- XXX define properly later XXX
97 data IntBool = IntBool
99 data StatVFS = StatVFS
100 data Hashtable = Hashtable
102 foreign import ccall unsafe "guestfs_create" c_create
104 foreign import ccall unsafe "&guestfs_close" c_close
105 :: FunPtr (GuestfsP -> IO ())
106 foreign import ccall unsafe "guestfs_set_error_handler" c_set_error_handler
107 :: GuestfsP -> Ptr CInt -> Ptr CInt -> IO ()
109 create :: IO GuestfsH
112 c_set_error_handler p nullPtr nullPtr
113 h <- newForeignPtr c_close p
116 foreign import ccall unsafe "guestfs_last_error" c_last_error
117 :: GuestfsP -> IO CString
119 -- last_error :: GuestfsH -> IO (Maybe String)
121 -- str <- withForeignPtr h (\p -> c_last_error p)
122 -- maybePeek peekCString str
124 last_error :: GuestfsH -> IO (String)
126 str <- withForeignPtr h (\p -> c_last_error p)
128 then return "no error"
131 foreign import ccall unsafe "guestfs_launch" c_launch
132 :: GuestfsP -> IO (CInt)
134 launch :: GuestfsH -> IO ()
136 r <- withForeignPtr h (\p -> c_launch p)
143 foreign import ccall unsafe "guestfs_wait_ready" c_wait_ready
144 :: GuestfsP -> IO (CInt)
146 wait_ready :: GuestfsH -> IO ()
148 r <- withForeignPtr h (\p -> c_wait_ready p)
155 foreign import ccall unsafe "guestfs_kill_subprocess" c_kill_subprocess
156 :: GuestfsP -> IO (CInt)
158 kill_subprocess :: GuestfsH -> IO ()
159 kill_subprocess h = do
160 r <- withForeignPtr h (\p -> c_kill_subprocess p)
167 foreign import ccall unsafe "guestfs_add_drive" c_add_drive
168 :: GuestfsP -> CString -> IO (CInt)
170 add_drive :: GuestfsH -> String -> IO ()
171 add_drive h filename = do
172 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_drive p filename)
179 foreign import ccall unsafe "guestfs_add_cdrom" c_add_cdrom
180 :: GuestfsP -> CString -> IO (CInt)
182 add_cdrom :: GuestfsH -> String -> IO ()
183 add_cdrom h filename = do
184 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_cdrom p filename)
191 foreign import ccall unsafe "guestfs_config" c_config
192 :: GuestfsP -> CString -> CString -> IO (CInt)
194 config :: GuestfsH -> String -> Maybe String -> IO ()
195 config h qemuparam qemuvalue = do
196 r <- withCString qemuparam $ \qemuparam -> maybeWith withCString qemuvalue $ \qemuvalue -> withForeignPtr h (\p -> c_config p qemuparam qemuvalue)
203 foreign import ccall unsafe "guestfs_set_qemu" c_set_qemu
204 :: GuestfsP -> CString -> IO (CInt)
206 set_qemu :: GuestfsH -> String -> IO ()
208 r <- withCString qemu $ \qemu -> withForeignPtr h (\p -> c_set_qemu p qemu)
215 foreign import ccall unsafe "guestfs_set_path" c_set_path
216 :: GuestfsP -> CString -> IO (CInt)
218 set_path :: GuestfsH -> String -> IO ()
220 r <- withCString path $ \path -> withForeignPtr h (\p -> c_set_path p path)
227 foreign import ccall unsafe "guestfs_set_append" c_set_append
228 :: GuestfsP -> CString -> IO (CInt)
230 set_append :: GuestfsH -> String -> IO ()
231 set_append h append = do
232 r <- withCString append $ \append -> withForeignPtr h (\p -> c_set_append p append)
239 foreign import ccall unsafe "guestfs_set_busy" c_set_busy
240 :: GuestfsP -> IO (CInt)
242 set_busy :: GuestfsH -> IO ()
244 r <- withForeignPtr h (\p -> c_set_busy p)
251 foreign import ccall unsafe "guestfs_set_ready" c_set_ready
252 :: GuestfsP -> IO (CInt)
254 set_ready :: GuestfsH -> IO ()
256 r <- withForeignPtr h (\p -> c_set_ready p)
263 foreign import ccall unsafe "guestfs_end_busy" c_end_busy
264 :: GuestfsP -> IO (CInt)
266 end_busy :: GuestfsH -> IO ()
268 r <- withForeignPtr h (\p -> c_end_busy p)
275 foreign import ccall unsafe "guestfs_mount" c_mount
276 :: GuestfsP -> CString -> CString -> IO (CInt)
278 mount :: GuestfsH -> String -> String -> IO ()
279 mount h device mountpoint = do
280 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount p device mountpoint)
287 foreign import ccall unsafe "guestfs_sync" c_sync
288 :: GuestfsP -> IO (CInt)
290 sync :: GuestfsH -> IO ()
292 r <- withForeignPtr h (\p -> c_sync p)
299 foreign import ccall unsafe "guestfs_touch" c_touch
300 :: GuestfsP -> CString -> IO (CInt)
302 touch :: GuestfsH -> String -> IO ()
304 r <- withCString path $ \path -> withForeignPtr h (\p -> c_touch p path)
311 foreign import ccall unsafe "guestfs_aug_close" c_aug_close
312 :: GuestfsP -> IO (CInt)
314 aug_close :: GuestfsH -> IO ()
316 r <- withForeignPtr h (\p -> c_aug_close p)
323 foreign import ccall unsafe "guestfs_aug_set" c_aug_set
324 :: GuestfsP -> CString -> CString -> IO (CInt)
326 aug_set :: GuestfsH -> String -> String -> IO ()
327 aug_set h path val = do
328 r <- withCString path $ \path -> withCString val $ \val -> withForeignPtr h (\p -> c_aug_set p path val)
335 foreign import ccall unsafe "guestfs_aug_mv" c_aug_mv
336 :: GuestfsP -> CString -> CString -> IO (CInt)
338 aug_mv :: GuestfsH -> String -> String -> IO ()
339 aug_mv h src dest = do
340 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_aug_mv p src dest)
347 foreign import ccall unsafe "guestfs_aug_save" c_aug_save
348 :: GuestfsP -> IO (CInt)
350 aug_save :: GuestfsH -> IO ()
352 r <- withForeignPtr h (\p -> c_aug_save p)
359 foreign import ccall unsafe "guestfs_aug_load" c_aug_load
360 :: GuestfsP -> IO (CInt)
362 aug_load :: GuestfsH -> IO ()
364 r <- withForeignPtr h (\p -> c_aug_load p)
371 foreign import ccall unsafe "guestfs_rm" c_rm
372 :: GuestfsP -> CString -> IO (CInt)
374 rm :: GuestfsH -> String -> IO ()
376 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm p path)
383 foreign import ccall unsafe "guestfs_rmdir" c_rmdir
384 :: GuestfsP -> CString -> IO (CInt)
386 rmdir :: GuestfsH -> String -> IO ()
388 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rmdir p path)
395 foreign import ccall unsafe "guestfs_rm_rf" c_rm_rf
396 :: GuestfsP -> CString -> IO (CInt)
398 rm_rf :: GuestfsH -> String -> IO ()
400 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm_rf p path)
407 foreign import ccall unsafe "guestfs_mkdir" c_mkdir
408 :: GuestfsP -> CString -> IO (CInt)
410 mkdir :: GuestfsH -> String -> IO ()
412 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir p path)
419 foreign import ccall unsafe "guestfs_mkdir_p" c_mkdir_p
420 :: GuestfsP -> CString -> IO (CInt)
422 mkdir_p :: GuestfsH -> String -> IO ()
424 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir_p p path)
431 foreign import ccall unsafe "guestfs_pvcreate" c_pvcreate
432 :: GuestfsP -> CString -> IO (CInt)
434 pvcreate :: GuestfsH -> String -> IO ()
435 pvcreate h device = do
436 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvcreate p device)
443 foreign import ccall unsafe "guestfs_vgcreate" c_vgcreate
444 :: GuestfsP -> CString -> Ptr CString -> IO (CInt)
446 vgcreate :: GuestfsH -> String -> [String] -> IO ()
447 vgcreate h volgroup physvols = do
448 r <- withCString volgroup $ \volgroup -> withMany withCString physvols $ \physvols -> withArray0 nullPtr physvols $ \physvols -> withForeignPtr h (\p -> c_vgcreate p volgroup physvols)
455 foreign import ccall unsafe "guestfs_mkfs" c_mkfs
456 :: GuestfsP -> CString -> CString -> IO (CInt)
458 mkfs :: GuestfsH -> String -> String -> IO ()
459 mkfs h fstype device = do
460 r <- withCString fstype $ \fstype -> withCString device $ \device -> withForeignPtr h (\p -> c_mkfs p fstype device)
467 foreign import ccall unsafe "guestfs_umount" c_umount
468 :: GuestfsP -> CString -> IO (CInt)
470 umount :: GuestfsH -> String -> IO ()
471 umount h pathordevice = do
472 r <- withCString pathordevice $ \pathordevice -> withForeignPtr h (\p -> c_umount p pathordevice)
479 foreign import ccall unsafe "guestfs_umount_all" c_umount_all
480 :: GuestfsP -> IO (CInt)
482 umount_all :: GuestfsH -> IO ()
484 r <- withForeignPtr h (\p -> c_umount_all p)
491 foreign import ccall unsafe "guestfs_lvm_remove_all" c_lvm_remove_all
492 :: GuestfsP -> IO (CInt)
494 lvm_remove_all :: GuestfsH -> IO ()
495 lvm_remove_all h = do
496 r <- withForeignPtr h (\p -> c_lvm_remove_all p)
503 foreign import ccall unsafe "guestfs_blockdev_setro" c_blockdev_setro
504 :: GuestfsP -> CString -> IO (CInt)
506 blockdev_setro :: GuestfsH -> String -> IO ()
507 blockdev_setro h device = do
508 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setro p device)
515 foreign import ccall unsafe "guestfs_blockdev_setrw" c_blockdev_setrw
516 :: GuestfsP -> CString -> IO (CInt)
518 blockdev_setrw :: GuestfsH -> String -> IO ()
519 blockdev_setrw h device = do
520 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setrw p device)
527 foreign import ccall unsafe "guestfs_blockdev_flushbufs" c_blockdev_flushbufs
528 :: GuestfsP -> CString -> IO (CInt)
530 blockdev_flushbufs :: GuestfsH -> String -> IO ()
531 blockdev_flushbufs h device = do
532 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_flushbufs p device)
539 foreign import ccall unsafe "guestfs_blockdev_rereadpt" c_blockdev_rereadpt
540 :: GuestfsP -> CString -> IO (CInt)
542 blockdev_rereadpt :: GuestfsH -> String -> IO ()
543 blockdev_rereadpt h device = do
544 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_rereadpt p device)
551 foreign import ccall unsafe "guestfs_upload" c_upload
552 :: GuestfsP -> CString -> CString -> IO (CInt)
554 upload :: GuestfsH -> String -> String -> IO ()
555 upload h filename remotefilename = do
556 r <- withCString filename $ \filename -> withCString remotefilename $ \remotefilename -> withForeignPtr h (\p -> c_upload p filename remotefilename)
563 foreign import ccall unsafe "guestfs_download" c_download
564 :: GuestfsP -> CString -> CString -> IO (CInt)
566 download :: GuestfsH -> String -> String -> IO ()
567 download h remotefilename filename = do
568 r <- withCString remotefilename $ \remotefilename -> withCString filename $ \filename -> withForeignPtr h (\p -> c_download p remotefilename filename)
575 foreign import ccall unsafe "guestfs_tar_in" c_tar_in
576 :: GuestfsP -> CString -> CString -> IO (CInt)
578 tar_in :: GuestfsH -> String -> String -> IO ()
579 tar_in h tarfile directory = do
580 r <- withCString tarfile $ \tarfile -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tar_in p tarfile directory)
587 foreign import ccall unsafe "guestfs_tar_out" c_tar_out
588 :: GuestfsP -> CString -> CString -> IO (CInt)
590 tar_out :: GuestfsH -> String -> String -> IO ()
591 tar_out h directory tarfile = do
592 r <- withCString directory $ \directory -> withCString tarfile $ \tarfile -> withForeignPtr h (\p -> c_tar_out p directory tarfile)
599 foreign import ccall unsafe "guestfs_tgz_in" c_tgz_in
600 :: GuestfsP -> CString -> CString -> IO (CInt)
602 tgz_in :: GuestfsH -> String -> String -> IO ()
603 tgz_in h tarball directory = do
604 r <- withCString tarball $ \tarball -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tgz_in p tarball directory)
611 foreign import ccall unsafe "guestfs_tgz_out" c_tgz_out
612 :: GuestfsP -> CString -> CString -> IO (CInt)
614 tgz_out :: GuestfsH -> String -> String -> IO ()
615 tgz_out h directory tarball = do
616 r <- withCString directory $ \directory -> withCString tarball $ \tarball -> withForeignPtr h (\p -> c_tgz_out p directory tarball)
623 foreign import ccall unsafe "guestfs_mount_ro" c_mount_ro
624 :: GuestfsP -> CString -> CString -> IO (CInt)
626 mount_ro :: GuestfsH -> String -> String -> IO ()
627 mount_ro h device mountpoint = do
628 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_ro p device mountpoint)
635 foreign import ccall unsafe "guestfs_mount_options" c_mount_options
636 :: GuestfsP -> CString -> CString -> CString -> IO (CInt)
638 mount_options :: GuestfsH -> String -> String -> String -> IO ()
639 mount_options h options device mountpoint = do
640 r <- withCString options $ \options -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_options p options device mountpoint)
647 foreign import ccall unsafe "guestfs_mount_vfs" c_mount_vfs
648 :: GuestfsP -> CString -> CString -> CString -> CString -> IO (CInt)
650 mount_vfs :: GuestfsH -> String -> String -> String -> String -> IO ()
651 mount_vfs h options vfstype device mountpoint = do
652 r <- withCString options $ \options -> withCString vfstype $ \vfstype -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_vfs p options vfstype device mountpoint)
659 foreign import ccall unsafe "guestfs_lvremove" c_lvremove
660 :: GuestfsP -> CString -> IO (CInt)
662 lvremove :: GuestfsH -> String -> IO ()
663 lvremove h device = do
664 r <- withCString device $ \device -> withForeignPtr h (\p -> c_lvremove p device)
671 foreign import ccall unsafe "guestfs_vgremove" c_vgremove
672 :: GuestfsP -> CString -> IO (CInt)
674 vgremove :: GuestfsH -> String -> IO ()
675 vgremove h vgname = do
676 r <- withCString vgname $ \vgname -> withForeignPtr h (\p -> c_vgremove p vgname)
683 foreign import ccall unsafe "guestfs_pvremove" c_pvremove
684 :: GuestfsP -> CString -> IO (CInt)
686 pvremove :: GuestfsH -> String -> IO ()
687 pvremove h device = do
688 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvremove p device)
695 foreign import ccall unsafe "guestfs_set_e2label" c_set_e2label
696 :: GuestfsP -> CString -> CString -> IO (CInt)
698 set_e2label :: GuestfsH -> String -> String -> IO ()
699 set_e2label h device label = do
700 r <- withCString device $ \device -> withCString label $ \label -> withForeignPtr h (\p -> c_set_e2label p device label)
707 foreign import ccall unsafe "guestfs_set_e2uuid" c_set_e2uuid
708 :: GuestfsP -> CString -> CString -> IO (CInt)
710 set_e2uuid :: GuestfsH -> String -> String -> IO ()
711 set_e2uuid h device uuid = do
712 r <- withCString device $ \device -> withCString uuid $ \uuid -> withForeignPtr h (\p -> c_set_e2uuid p device uuid)
719 foreign import ccall unsafe "guestfs_zero" c_zero
720 :: GuestfsP -> CString -> IO (CInt)
722 zero :: GuestfsH -> String -> IO ()
724 r <- withCString device $ \device -> withForeignPtr h (\p -> c_zero p device)
731 foreign import ccall unsafe "guestfs_grub_install" c_grub_install
732 :: GuestfsP -> CString -> CString -> IO (CInt)
734 grub_install :: GuestfsH -> String -> String -> IO ()
735 grub_install h root device = do
736 r <- withCString root $ \root -> withCString device $ \device -> withForeignPtr h (\p -> c_grub_install p root device)
743 foreign import ccall unsafe "guestfs_cp" c_cp
744 :: GuestfsP -> CString -> CString -> IO (CInt)
746 cp :: GuestfsH -> String -> String -> IO ()
748 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp p src dest)
755 foreign import ccall unsafe "guestfs_cp_a" c_cp_a
756 :: GuestfsP -> CString -> CString -> IO (CInt)
758 cp_a :: GuestfsH -> String -> String -> IO ()
760 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp_a p src dest)
767 foreign import ccall unsafe "guestfs_mv" c_mv
768 :: GuestfsP -> CString -> CString -> IO (CInt)
770 mv :: GuestfsH -> String -> String -> IO ()
772 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_mv p src dest)
779 foreign import ccall unsafe "guestfs_ping_daemon" c_ping_daemon
780 :: GuestfsP -> IO (CInt)
782 ping_daemon :: GuestfsH -> IO ()
784 r <- withForeignPtr h (\p -> c_ping_daemon p)