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 #-}
85 import Control.Exception
88 data GuestfsS = GuestfsS -- represents the opaque C struct
89 type GuestfsP = Ptr GuestfsS -- guestfs_h *
90 type GuestfsH = ForeignPtr GuestfsS -- guestfs_h * with attached finalizer
92 -- XXX define properly later XXX
96 data IntBool = IntBool
98 data StatVFS = StatVFS
99 data Hashtable = Hashtable
101 foreign import ccall unsafe "guestfs_create" c_create
103 foreign import ccall unsafe "&guestfs_close" c_close
104 :: FunPtr (GuestfsP -> IO ())
105 foreign import ccall unsafe "guestfs_set_error_handler" c_set_error_handler
106 :: GuestfsP -> Ptr CInt -> Ptr CInt -> IO ()
108 create :: IO GuestfsH
111 c_set_error_handler p nullPtr nullPtr
112 h <- newForeignPtr c_close p
115 foreign import ccall unsafe "guestfs_last_error" c_last_error
116 :: GuestfsP -> IO CString
118 -- last_error :: GuestfsH -> IO (Maybe String)
120 -- str <- withForeignPtr h (\p -> c_last_error p)
121 -- maybePeek peekCString str
123 last_error :: GuestfsH -> IO (String)
125 str <- withForeignPtr h (\p -> c_last_error p)
127 then return "no error"
130 foreign import ccall unsafe "guestfs_launch" c_launch
131 :: GuestfsP -> IO (CInt)
133 launch :: GuestfsH -> IO ()
135 r <- withForeignPtr h (\p -> c_launch p)
142 foreign import ccall unsafe "guestfs_wait_ready" c_wait_ready
143 :: GuestfsP -> IO (CInt)
145 wait_ready :: GuestfsH -> IO ()
147 r <- withForeignPtr h (\p -> c_wait_ready p)
154 foreign import ccall unsafe "guestfs_kill_subprocess" c_kill_subprocess
155 :: GuestfsP -> IO (CInt)
157 kill_subprocess :: GuestfsH -> IO ()
158 kill_subprocess h = do
159 r <- withForeignPtr h (\p -> c_kill_subprocess p)
166 foreign import ccall unsafe "guestfs_add_drive" c_add_drive
167 :: GuestfsP -> CString -> IO (CInt)
169 add_drive :: GuestfsH -> String -> IO ()
170 add_drive h filename = do
171 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_drive p filename)
178 foreign import ccall unsafe "guestfs_add_cdrom" c_add_cdrom
179 :: GuestfsP -> CString -> IO (CInt)
181 add_cdrom :: GuestfsH -> String -> IO ()
182 add_cdrom h filename = do
183 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_cdrom p filename)
190 foreign import ccall unsafe "guestfs_config" c_config
191 :: GuestfsP -> CString -> CString -> IO (CInt)
193 config :: GuestfsH -> String -> Maybe String -> IO ()
194 config h qemuparam qemuvalue = do
195 r <- withCString qemuparam $ \qemuparam -> maybeWith withCString qemuvalue $ \qemuvalue -> withForeignPtr h (\p -> c_config p qemuparam qemuvalue)
202 foreign import ccall unsafe "guestfs_set_qemu" c_set_qemu
203 :: GuestfsP -> CString -> IO (CInt)
205 set_qemu :: GuestfsH -> String -> IO ()
207 r <- withCString qemu $ \qemu -> withForeignPtr h (\p -> c_set_qemu p qemu)
214 foreign import ccall unsafe "guestfs_set_path" c_set_path
215 :: GuestfsP -> CString -> IO (CInt)
217 set_path :: GuestfsH -> String -> IO ()
219 r <- withCString path $ \path -> withForeignPtr h (\p -> c_set_path p path)
226 foreign import ccall unsafe "guestfs_set_busy" c_set_busy
227 :: GuestfsP -> IO (CInt)
229 set_busy :: GuestfsH -> IO ()
231 r <- withForeignPtr h (\p -> c_set_busy p)
238 foreign import ccall unsafe "guestfs_set_ready" c_set_ready
239 :: GuestfsP -> IO (CInt)
241 set_ready :: GuestfsH -> IO ()
243 r <- withForeignPtr h (\p -> c_set_ready p)
250 foreign import ccall unsafe "guestfs_end_busy" c_end_busy
251 :: GuestfsP -> IO (CInt)
253 end_busy :: GuestfsH -> IO ()
255 r <- withForeignPtr h (\p -> c_end_busy p)
262 foreign import ccall unsafe "guestfs_mount" c_mount
263 :: GuestfsP -> CString -> CString -> IO (CInt)
265 mount :: GuestfsH -> String -> String -> IO ()
266 mount h device mountpoint = do
267 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount p device mountpoint)
274 foreign import ccall unsafe "guestfs_sync" c_sync
275 :: GuestfsP -> IO (CInt)
277 sync :: GuestfsH -> IO ()
279 r <- withForeignPtr h (\p -> c_sync p)
286 foreign import ccall unsafe "guestfs_touch" c_touch
287 :: GuestfsP -> CString -> IO (CInt)
289 touch :: GuestfsH -> String -> IO ()
291 r <- withCString path $ \path -> withForeignPtr h (\p -> c_touch p path)
298 foreign import ccall unsafe "guestfs_aug_close" c_aug_close
299 :: GuestfsP -> IO (CInt)
301 aug_close :: GuestfsH -> IO ()
303 r <- withForeignPtr h (\p -> c_aug_close p)
310 foreign import ccall unsafe "guestfs_aug_set" c_aug_set
311 :: GuestfsP -> CString -> CString -> IO (CInt)
313 aug_set :: GuestfsH -> String -> String -> IO ()
314 aug_set h path val = do
315 r <- withCString path $ \path -> withCString val $ \val -> withForeignPtr h (\p -> c_aug_set p path val)
322 foreign import ccall unsafe "guestfs_aug_mv" c_aug_mv
323 :: GuestfsP -> CString -> CString -> IO (CInt)
325 aug_mv :: GuestfsH -> String -> String -> IO ()
326 aug_mv h src dest = do
327 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_aug_mv p src dest)
334 foreign import ccall unsafe "guestfs_aug_save" c_aug_save
335 :: GuestfsP -> IO (CInt)
337 aug_save :: GuestfsH -> IO ()
339 r <- withForeignPtr h (\p -> c_aug_save p)
346 foreign import ccall unsafe "guestfs_aug_load" c_aug_load
347 :: GuestfsP -> IO (CInt)
349 aug_load :: GuestfsH -> IO ()
351 r <- withForeignPtr h (\p -> c_aug_load p)
358 foreign import ccall unsafe "guestfs_rm" c_rm
359 :: GuestfsP -> CString -> IO (CInt)
361 rm :: GuestfsH -> String -> IO ()
363 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm p path)
370 foreign import ccall unsafe "guestfs_rmdir" c_rmdir
371 :: GuestfsP -> CString -> IO (CInt)
373 rmdir :: GuestfsH -> String -> IO ()
375 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rmdir p path)
382 foreign import ccall unsafe "guestfs_rm_rf" c_rm_rf
383 :: GuestfsP -> CString -> IO (CInt)
385 rm_rf :: GuestfsH -> String -> IO ()
387 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm_rf p path)
394 foreign import ccall unsafe "guestfs_mkdir" c_mkdir
395 :: GuestfsP -> CString -> IO (CInt)
397 mkdir :: GuestfsH -> String -> IO ()
399 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir p path)
406 foreign import ccall unsafe "guestfs_mkdir_p" c_mkdir_p
407 :: GuestfsP -> CString -> IO (CInt)
409 mkdir_p :: GuestfsH -> String -> IO ()
411 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir_p p path)
418 foreign import ccall unsafe "guestfs_pvcreate" c_pvcreate
419 :: GuestfsP -> CString -> IO (CInt)
421 pvcreate :: GuestfsH -> String -> IO ()
422 pvcreate h device = do
423 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvcreate p device)
430 foreign import ccall unsafe "guestfs_vgcreate" c_vgcreate
431 :: GuestfsP -> CString -> Ptr CString -> IO (CInt)
433 vgcreate :: GuestfsH -> String -> [String] -> IO ()
434 vgcreate h volgroup physvols = do
435 r <- withCString volgroup $ \volgroup -> withMany withCString physvols $ \physvols -> withArray0 nullPtr physvols $ \physvols -> withForeignPtr h (\p -> c_vgcreate p volgroup physvols)
442 foreign import ccall unsafe "guestfs_mkfs" c_mkfs
443 :: GuestfsP -> CString -> CString -> IO (CInt)
445 mkfs :: GuestfsH -> String -> String -> IO ()
446 mkfs h fstype device = do
447 r <- withCString fstype $ \fstype -> withCString device $ \device -> withForeignPtr h (\p -> c_mkfs p fstype device)
454 foreign import ccall unsafe "guestfs_umount" c_umount
455 :: GuestfsP -> CString -> IO (CInt)
457 umount :: GuestfsH -> String -> IO ()
458 umount h pathordevice = do
459 r <- withCString pathordevice $ \pathordevice -> withForeignPtr h (\p -> c_umount p pathordevice)
466 foreign import ccall unsafe "guestfs_umount_all" c_umount_all
467 :: GuestfsP -> IO (CInt)
469 umount_all :: GuestfsH -> IO ()
471 r <- withForeignPtr h (\p -> c_umount_all p)
478 foreign import ccall unsafe "guestfs_lvm_remove_all" c_lvm_remove_all
479 :: GuestfsP -> IO (CInt)
481 lvm_remove_all :: GuestfsH -> IO ()
482 lvm_remove_all h = do
483 r <- withForeignPtr h (\p -> c_lvm_remove_all p)
490 foreign import ccall unsafe "guestfs_blockdev_setro" c_blockdev_setro
491 :: GuestfsP -> CString -> IO (CInt)
493 blockdev_setro :: GuestfsH -> String -> IO ()
494 blockdev_setro h device = do
495 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setro p device)
502 foreign import ccall unsafe "guestfs_blockdev_setrw" c_blockdev_setrw
503 :: GuestfsP -> CString -> IO (CInt)
505 blockdev_setrw :: GuestfsH -> String -> IO ()
506 blockdev_setrw h device = do
507 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setrw p device)
514 foreign import ccall unsafe "guestfs_blockdev_flushbufs" c_blockdev_flushbufs
515 :: GuestfsP -> CString -> IO (CInt)
517 blockdev_flushbufs :: GuestfsH -> String -> IO ()
518 blockdev_flushbufs h device = do
519 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_flushbufs p device)
526 foreign import ccall unsafe "guestfs_blockdev_rereadpt" c_blockdev_rereadpt
527 :: GuestfsP -> CString -> IO (CInt)
529 blockdev_rereadpt :: GuestfsH -> String -> IO ()
530 blockdev_rereadpt h device = do
531 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_rereadpt p device)
538 foreign import ccall unsafe "guestfs_upload" c_upload
539 :: GuestfsP -> CString -> CString -> IO (CInt)
541 upload :: GuestfsH -> String -> String -> IO ()
542 upload h filename remotefilename = do
543 r <- withCString filename $ \filename -> withCString remotefilename $ \remotefilename -> withForeignPtr h (\p -> c_upload p filename remotefilename)
550 foreign import ccall unsafe "guestfs_download" c_download
551 :: GuestfsP -> CString -> CString -> IO (CInt)
553 download :: GuestfsH -> String -> String -> IO ()
554 download h remotefilename filename = do
555 r <- withCString remotefilename $ \remotefilename -> withCString filename $ \filename -> withForeignPtr h (\p -> c_download p remotefilename filename)
562 foreign import ccall unsafe "guestfs_tar_in" c_tar_in
563 :: GuestfsP -> CString -> CString -> IO (CInt)
565 tar_in :: GuestfsH -> String -> String -> IO ()
566 tar_in h tarfile directory = do
567 r <- withCString tarfile $ \tarfile -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tar_in p tarfile directory)
574 foreign import ccall unsafe "guestfs_tar_out" c_tar_out
575 :: GuestfsP -> CString -> CString -> IO (CInt)
577 tar_out :: GuestfsH -> String -> String -> IO ()
578 tar_out h directory tarfile = do
579 r <- withCString directory $ \directory -> withCString tarfile $ \tarfile -> withForeignPtr h (\p -> c_tar_out p directory tarfile)
586 foreign import ccall unsafe "guestfs_tgz_in" c_tgz_in
587 :: GuestfsP -> CString -> CString -> IO (CInt)
589 tgz_in :: GuestfsH -> String -> String -> IO ()
590 tgz_in h tarball directory = do
591 r <- withCString tarball $ \tarball -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tgz_in p tarball directory)
598 foreign import ccall unsafe "guestfs_tgz_out" c_tgz_out
599 :: GuestfsP -> CString -> CString -> IO (CInt)
601 tgz_out :: GuestfsH -> String -> String -> IO ()
602 tgz_out h directory tarball = do
603 r <- withCString directory $ \directory -> withCString tarball $ \tarball -> withForeignPtr h (\p -> c_tgz_out p directory tarball)
610 foreign import ccall unsafe "guestfs_mount_ro" c_mount_ro
611 :: GuestfsP -> CString -> CString -> IO (CInt)
613 mount_ro :: GuestfsH -> String -> String -> IO ()
614 mount_ro h device mountpoint = do
615 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_ro p device mountpoint)
622 foreign import ccall unsafe "guestfs_mount_options" c_mount_options
623 :: GuestfsP -> CString -> CString -> CString -> IO (CInt)
625 mount_options :: GuestfsH -> String -> String -> String -> IO ()
626 mount_options h options device mountpoint = do
627 r <- withCString options $ \options -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_options p options device mountpoint)
634 foreign import ccall unsafe "guestfs_mount_vfs" c_mount_vfs
635 :: GuestfsP -> CString -> CString -> CString -> CString -> IO (CInt)
637 mount_vfs :: GuestfsH -> String -> String -> String -> String -> IO ()
638 mount_vfs h options vfstype device mountpoint = do
639 r <- withCString options $ \options -> withCString vfstype $ \vfstype -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_vfs p options vfstype device mountpoint)
646 foreign import ccall unsafe "guestfs_lvremove" c_lvremove
647 :: GuestfsP -> CString -> IO (CInt)
649 lvremove :: GuestfsH -> String -> IO ()
650 lvremove h device = do
651 r <- withCString device $ \device -> withForeignPtr h (\p -> c_lvremove p device)
658 foreign import ccall unsafe "guestfs_vgremove" c_vgremove
659 :: GuestfsP -> CString -> IO (CInt)
661 vgremove :: GuestfsH -> String -> IO ()
662 vgremove h vgname = do
663 r <- withCString vgname $ \vgname -> withForeignPtr h (\p -> c_vgremove p vgname)
670 foreign import ccall unsafe "guestfs_pvremove" c_pvremove
671 :: GuestfsP -> CString -> IO (CInt)
673 pvremove :: GuestfsH -> String -> IO ()
674 pvremove h device = do
675 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvremove p device)
682 foreign import ccall unsafe "guestfs_set_e2label" c_set_e2label
683 :: GuestfsP -> CString -> CString -> IO (CInt)
685 set_e2label :: GuestfsH -> String -> String -> IO ()
686 set_e2label h device label = do
687 r <- withCString device $ \device -> withCString label $ \label -> withForeignPtr h (\p -> c_set_e2label p device label)
694 foreign import ccall unsafe "guestfs_set_e2uuid" c_set_e2uuid
695 :: GuestfsP -> CString -> CString -> IO (CInt)
697 set_e2uuid :: GuestfsH -> String -> String -> IO ()
698 set_e2uuid h device uuid = do
699 r <- withCString device $ \device -> withCString uuid $ \uuid -> withForeignPtr h (\p -> c_set_e2uuid p device uuid)
706 foreign import ccall unsafe "guestfs_zero" c_zero
707 :: GuestfsP -> CString -> IO (CInt)
709 zero :: GuestfsH -> String -> IO ()
711 r <- withCString device $ \device -> withForeignPtr h (\p -> c_zero p device)
718 foreign import ccall unsafe "guestfs_grub_install" c_grub_install
719 :: GuestfsP -> CString -> CString -> IO (CInt)
721 grub_install :: GuestfsH -> String -> String -> IO ()
722 grub_install h root device = do
723 r <- withCString root $ \root -> withCString device $ \device -> withForeignPtr h (\p -> c_grub_install p root device)
730 foreign import ccall unsafe "guestfs_cp" c_cp
731 :: GuestfsP -> CString -> CString -> IO (CInt)
733 cp :: GuestfsH -> String -> String -> IO ()
735 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp p src dest)
742 foreign import ccall unsafe "guestfs_cp_a" c_cp_a
743 :: GuestfsP -> CString -> CString -> IO (CInt)
745 cp_a :: GuestfsH -> String -> String -> IO ()
747 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp_a p src dest)
754 foreign import ccall unsafe "guestfs_mv" c_mv
755 :: GuestfsP -> CString -> CString -> IO (CInt)
757 mv :: GuestfsH -> String -> String -> IO ()
759 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_mv p src dest)
766 foreign import ccall unsafe "guestfs_ping_daemon" c_ping_daemon
767 :: GuestfsP -> IO (CInt)
769 ping_daemon :: GuestfsH -> IO ()
771 r <- withForeignPtr h (\p -> c_ping_daemon p)