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 #-}
90 import Control.Exception
93 data GuestfsS = GuestfsS -- represents the opaque C struct
94 type GuestfsP = Ptr GuestfsS -- guestfs_h *
95 type GuestfsH = ForeignPtr GuestfsS -- guestfs_h * with attached finalizer
97 -- XXX define properly later XXX
101 data IntBool = IntBool
103 data StatVFS = StatVFS
104 data Hashtable = Hashtable
106 foreign import ccall unsafe "guestfs_create" c_create
108 foreign import ccall unsafe "&guestfs_close" c_close
109 :: FunPtr (GuestfsP -> IO ())
110 foreign import ccall unsafe "guestfs_set_error_handler" c_set_error_handler
111 :: GuestfsP -> Ptr CInt -> Ptr CInt -> IO ()
113 create :: IO GuestfsH
116 c_set_error_handler p nullPtr nullPtr
117 h <- newForeignPtr c_close p
120 foreign import ccall unsafe "guestfs_last_error" c_last_error
121 :: GuestfsP -> IO CString
123 -- last_error :: GuestfsH -> IO (Maybe String)
125 -- str <- withForeignPtr h (\p -> c_last_error p)
126 -- maybePeek peekCString str
128 last_error :: GuestfsH -> IO (String)
130 str <- withForeignPtr h (\p -> c_last_error p)
132 then return "no error"
135 foreign import ccall unsafe "guestfs_launch" c_launch
136 :: GuestfsP -> IO (CInt)
138 launch :: GuestfsH -> IO ()
140 r <- withForeignPtr h (\p -> c_launch p)
147 foreign import ccall unsafe "guestfs_wait_ready" c_wait_ready
148 :: GuestfsP -> IO (CInt)
150 wait_ready :: GuestfsH -> IO ()
152 r <- withForeignPtr h (\p -> c_wait_ready p)
159 foreign import ccall unsafe "guestfs_kill_subprocess" c_kill_subprocess
160 :: GuestfsP -> IO (CInt)
162 kill_subprocess :: GuestfsH -> IO ()
163 kill_subprocess h = do
164 r <- withForeignPtr h (\p -> c_kill_subprocess p)
171 foreign import ccall unsafe "guestfs_add_drive" c_add_drive
172 :: GuestfsP -> CString -> IO (CInt)
174 add_drive :: GuestfsH -> String -> IO ()
175 add_drive h filename = do
176 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_drive p filename)
183 foreign import ccall unsafe "guestfs_add_cdrom" c_add_cdrom
184 :: GuestfsP -> CString -> IO (CInt)
186 add_cdrom :: GuestfsH -> String -> IO ()
187 add_cdrom h filename = do
188 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_cdrom p filename)
195 foreign import ccall unsafe "guestfs_config" c_config
196 :: GuestfsP -> CString -> CString -> IO (CInt)
198 config :: GuestfsH -> String -> Maybe String -> IO ()
199 config h qemuparam qemuvalue = do
200 r <- withCString qemuparam $ \qemuparam -> maybeWith withCString qemuvalue $ \qemuvalue -> withForeignPtr h (\p -> c_config p qemuparam qemuvalue)
207 foreign import ccall unsafe "guestfs_set_qemu" c_set_qemu
208 :: GuestfsP -> CString -> IO (CInt)
210 set_qemu :: GuestfsH -> String -> IO ()
212 r <- withCString qemu $ \qemu -> withForeignPtr h (\p -> c_set_qemu p qemu)
219 foreign import ccall unsafe "guestfs_set_path" c_set_path
220 :: GuestfsP -> CString -> IO (CInt)
222 set_path :: GuestfsH -> String -> IO ()
224 r <- withCString path $ \path -> withForeignPtr h (\p -> c_set_path p path)
231 foreign import ccall unsafe "guestfs_set_append" c_set_append
232 :: GuestfsP -> CString -> IO (CInt)
234 set_append :: GuestfsH -> String -> IO ()
235 set_append h append = do
236 r <- withCString append $ \append -> withForeignPtr h (\p -> c_set_append p append)
243 foreign import ccall unsafe "guestfs_set_busy" c_set_busy
244 :: GuestfsP -> IO (CInt)
246 set_busy :: GuestfsH -> IO ()
248 r <- withForeignPtr h (\p -> c_set_busy p)
255 foreign import ccall unsafe "guestfs_set_ready" c_set_ready
256 :: GuestfsP -> IO (CInt)
258 set_ready :: GuestfsH -> IO ()
260 r <- withForeignPtr h (\p -> c_set_ready p)
267 foreign import ccall unsafe "guestfs_end_busy" c_end_busy
268 :: GuestfsP -> IO (CInt)
270 end_busy :: GuestfsH -> IO ()
272 r <- withForeignPtr h (\p -> c_end_busy p)
279 foreign import ccall unsafe "guestfs_mount" c_mount
280 :: GuestfsP -> CString -> CString -> IO (CInt)
282 mount :: GuestfsH -> String -> String -> IO ()
283 mount h device mountpoint = do
284 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount p device mountpoint)
291 foreign import ccall unsafe "guestfs_sync" c_sync
292 :: GuestfsP -> IO (CInt)
294 sync :: GuestfsH -> IO ()
296 r <- withForeignPtr h (\p -> c_sync p)
303 foreign import ccall unsafe "guestfs_touch" c_touch
304 :: GuestfsP -> CString -> IO (CInt)
306 touch :: GuestfsH -> String -> IO ()
308 r <- withCString path $ \path -> withForeignPtr h (\p -> c_touch p path)
315 foreign import ccall unsafe "guestfs_aug_close" c_aug_close
316 :: GuestfsP -> IO (CInt)
318 aug_close :: GuestfsH -> IO ()
320 r <- withForeignPtr h (\p -> c_aug_close p)
327 foreign import ccall unsafe "guestfs_aug_set" c_aug_set
328 :: GuestfsP -> CString -> CString -> IO (CInt)
330 aug_set :: GuestfsH -> String -> String -> IO ()
331 aug_set h path val = do
332 r <- withCString path $ \path -> withCString val $ \val -> withForeignPtr h (\p -> c_aug_set p path val)
339 foreign import ccall unsafe "guestfs_aug_mv" c_aug_mv
340 :: GuestfsP -> CString -> CString -> IO (CInt)
342 aug_mv :: GuestfsH -> String -> String -> IO ()
343 aug_mv h src dest = do
344 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_aug_mv p src dest)
351 foreign import ccall unsafe "guestfs_aug_save" c_aug_save
352 :: GuestfsP -> IO (CInt)
354 aug_save :: GuestfsH -> IO ()
356 r <- withForeignPtr h (\p -> c_aug_save p)
363 foreign import ccall unsafe "guestfs_aug_load" c_aug_load
364 :: GuestfsP -> IO (CInt)
366 aug_load :: GuestfsH -> IO ()
368 r <- withForeignPtr h (\p -> c_aug_load p)
375 foreign import ccall unsafe "guestfs_rm" c_rm
376 :: GuestfsP -> CString -> IO (CInt)
378 rm :: GuestfsH -> String -> IO ()
380 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm p path)
387 foreign import ccall unsafe "guestfs_rmdir" c_rmdir
388 :: GuestfsP -> CString -> IO (CInt)
390 rmdir :: GuestfsH -> String -> IO ()
392 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rmdir p path)
399 foreign import ccall unsafe "guestfs_rm_rf" c_rm_rf
400 :: GuestfsP -> CString -> IO (CInt)
402 rm_rf :: GuestfsH -> String -> IO ()
404 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm_rf p path)
411 foreign import ccall unsafe "guestfs_mkdir" c_mkdir
412 :: GuestfsP -> CString -> IO (CInt)
414 mkdir :: GuestfsH -> String -> IO ()
416 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir p path)
423 foreign import ccall unsafe "guestfs_mkdir_p" c_mkdir_p
424 :: GuestfsP -> CString -> IO (CInt)
426 mkdir_p :: GuestfsH -> String -> IO ()
428 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir_p p path)
435 foreign import ccall unsafe "guestfs_pvcreate" c_pvcreate
436 :: GuestfsP -> CString -> IO (CInt)
438 pvcreate :: GuestfsH -> String -> IO ()
439 pvcreate h device = do
440 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvcreate p device)
447 foreign import ccall unsafe "guestfs_vgcreate" c_vgcreate
448 :: GuestfsP -> CString -> Ptr CString -> IO (CInt)
450 vgcreate :: GuestfsH -> String -> [String] -> IO ()
451 vgcreate h volgroup physvols = do
452 r <- withCString volgroup $ \volgroup -> withMany withCString physvols $ \physvols -> withArray0 nullPtr physvols $ \physvols -> withForeignPtr h (\p -> c_vgcreate p volgroup physvols)
459 foreign import ccall unsafe "guestfs_mkfs" c_mkfs
460 :: GuestfsP -> CString -> CString -> IO (CInt)
462 mkfs :: GuestfsH -> String -> String -> IO ()
463 mkfs h fstype device = do
464 r <- withCString fstype $ \fstype -> withCString device $ \device -> withForeignPtr h (\p -> c_mkfs p fstype device)
471 foreign import ccall unsafe "guestfs_umount" c_umount
472 :: GuestfsP -> CString -> IO (CInt)
474 umount :: GuestfsH -> String -> IO ()
475 umount h pathordevice = do
476 r <- withCString pathordevice $ \pathordevice -> withForeignPtr h (\p -> c_umount p pathordevice)
483 foreign import ccall unsafe "guestfs_umount_all" c_umount_all
484 :: GuestfsP -> IO (CInt)
486 umount_all :: GuestfsH -> IO ()
488 r <- withForeignPtr h (\p -> c_umount_all p)
495 foreign import ccall unsafe "guestfs_lvm_remove_all" c_lvm_remove_all
496 :: GuestfsP -> IO (CInt)
498 lvm_remove_all :: GuestfsH -> IO ()
499 lvm_remove_all h = do
500 r <- withForeignPtr h (\p -> c_lvm_remove_all p)
507 foreign import ccall unsafe "guestfs_blockdev_setro" c_blockdev_setro
508 :: GuestfsP -> CString -> IO (CInt)
510 blockdev_setro :: GuestfsH -> String -> IO ()
511 blockdev_setro h device = do
512 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setro p device)
519 foreign import ccall unsafe "guestfs_blockdev_setrw" c_blockdev_setrw
520 :: GuestfsP -> CString -> IO (CInt)
522 blockdev_setrw :: GuestfsH -> String -> IO ()
523 blockdev_setrw h device = do
524 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setrw p device)
531 foreign import ccall unsafe "guestfs_blockdev_flushbufs" c_blockdev_flushbufs
532 :: GuestfsP -> CString -> IO (CInt)
534 blockdev_flushbufs :: GuestfsH -> String -> IO ()
535 blockdev_flushbufs h device = do
536 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_flushbufs p device)
543 foreign import ccall unsafe "guestfs_blockdev_rereadpt" c_blockdev_rereadpt
544 :: GuestfsP -> CString -> IO (CInt)
546 blockdev_rereadpt :: GuestfsH -> String -> IO ()
547 blockdev_rereadpt h device = do
548 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_rereadpt p device)
555 foreign import ccall unsafe "guestfs_upload" c_upload
556 :: GuestfsP -> CString -> CString -> IO (CInt)
558 upload :: GuestfsH -> String -> String -> IO ()
559 upload h filename remotefilename = do
560 r <- withCString filename $ \filename -> withCString remotefilename $ \remotefilename -> withForeignPtr h (\p -> c_upload p filename remotefilename)
567 foreign import ccall unsafe "guestfs_download" c_download
568 :: GuestfsP -> CString -> CString -> IO (CInt)
570 download :: GuestfsH -> String -> String -> IO ()
571 download h remotefilename filename = do
572 r <- withCString remotefilename $ \remotefilename -> withCString filename $ \filename -> withForeignPtr h (\p -> c_download p remotefilename filename)
579 foreign import ccall unsafe "guestfs_tar_in" c_tar_in
580 :: GuestfsP -> CString -> CString -> IO (CInt)
582 tar_in :: GuestfsH -> String -> String -> IO ()
583 tar_in h tarfile directory = do
584 r <- withCString tarfile $ \tarfile -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tar_in p tarfile directory)
591 foreign import ccall unsafe "guestfs_tar_out" c_tar_out
592 :: GuestfsP -> CString -> CString -> IO (CInt)
594 tar_out :: GuestfsH -> String -> String -> IO ()
595 tar_out h directory tarfile = do
596 r <- withCString directory $ \directory -> withCString tarfile $ \tarfile -> withForeignPtr h (\p -> c_tar_out p directory tarfile)
603 foreign import ccall unsafe "guestfs_tgz_in" c_tgz_in
604 :: GuestfsP -> CString -> CString -> IO (CInt)
606 tgz_in :: GuestfsH -> String -> String -> IO ()
607 tgz_in h tarball directory = do
608 r <- withCString tarball $ \tarball -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tgz_in p tarball directory)
615 foreign import ccall unsafe "guestfs_tgz_out" c_tgz_out
616 :: GuestfsP -> CString -> CString -> IO (CInt)
618 tgz_out :: GuestfsH -> String -> String -> IO ()
619 tgz_out h directory tarball = do
620 r <- withCString directory $ \directory -> withCString tarball $ \tarball -> withForeignPtr h (\p -> c_tgz_out p directory tarball)
627 foreign import ccall unsafe "guestfs_mount_ro" c_mount_ro
628 :: GuestfsP -> CString -> CString -> IO (CInt)
630 mount_ro :: GuestfsH -> String -> String -> IO ()
631 mount_ro h device mountpoint = do
632 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_ro p device mountpoint)
639 foreign import ccall unsafe "guestfs_mount_options" c_mount_options
640 :: GuestfsP -> CString -> CString -> CString -> IO (CInt)
642 mount_options :: GuestfsH -> String -> String -> String -> IO ()
643 mount_options h options device mountpoint = do
644 r <- withCString options $ \options -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_options p options device mountpoint)
651 foreign import ccall unsafe "guestfs_mount_vfs" c_mount_vfs
652 :: GuestfsP -> CString -> CString -> CString -> CString -> IO (CInt)
654 mount_vfs :: GuestfsH -> String -> String -> String -> String -> IO ()
655 mount_vfs h options vfstype device mountpoint = do
656 r <- withCString options $ \options -> withCString vfstype $ \vfstype -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_vfs p options vfstype device mountpoint)
663 foreign import ccall unsafe "guestfs_lvremove" c_lvremove
664 :: GuestfsP -> CString -> IO (CInt)
666 lvremove :: GuestfsH -> String -> IO ()
667 lvremove h device = do
668 r <- withCString device $ \device -> withForeignPtr h (\p -> c_lvremove p device)
675 foreign import ccall unsafe "guestfs_vgremove" c_vgremove
676 :: GuestfsP -> CString -> IO (CInt)
678 vgremove :: GuestfsH -> String -> IO ()
679 vgremove h vgname = do
680 r <- withCString vgname $ \vgname -> withForeignPtr h (\p -> c_vgremove p vgname)
687 foreign import ccall unsafe "guestfs_pvremove" c_pvremove
688 :: GuestfsP -> CString -> IO (CInt)
690 pvremove :: GuestfsH -> String -> IO ()
691 pvremove h device = do
692 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvremove p device)
699 foreign import ccall unsafe "guestfs_set_e2label" c_set_e2label
700 :: GuestfsP -> CString -> CString -> IO (CInt)
702 set_e2label :: GuestfsH -> String -> String -> IO ()
703 set_e2label h device label = do
704 r <- withCString device $ \device -> withCString label $ \label -> withForeignPtr h (\p -> c_set_e2label p device label)
711 foreign import ccall unsafe "guestfs_set_e2uuid" c_set_e2uuid
712 :: GuestfsP -> CString -> CString -> IO (CInt)
714 set_e2uuid :: GuestfsH -> String -> String -> IO ()
715 set_e2uuid h device uuid = do
716 r <- withCString device $ \device -> withCString uuid $ \uuid -> withForeignPtr h (\p -> c_set_e2uuid p device uuid)
723 foreign import ccall unsafe "guestfs_zero" c_zero
724 :: GuestfsP -> CString -> IO (CInt)
726 zero :: GuestfsH -> String -> IO ()
728 r <- withCString device $ \device -> withForeignPtr h (\p -> c_zero p device)
735 foreign import ccall unsafe "guestfs_grub_install" c_grub_install
736 :: GuestfsP -> CString -> CString -> IO (CInt)
738 grub_install :: GuestfsH -> String -> String -> IO ()
739 grub_install h root device = do
740 r <- withCString root $ \root -> withCString device $ \device -> withForeignPtr h (\p -> c_grub_install p root device)
747 foreign import ccall unsafe "guestfs_cp" c_cp
748 :: GuestfsP -> CString -> CString -> IO (CInt)
750 cp :: GuestfsH -> String -> String -> IO ()
752 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp p src dest)
759 foreign import ccall unsafe "guestfs_cp_a" c_cp_a
760 :: GuestfsP -> CString -> CString -> IO (CInt)
762 cp_a :: GuestfsH -> String -> String -> IO ()
764 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp_a p src dest)
771 foreign import ccall unsafe "guestfs_mv" c_mv
772 :: GuestfsP -> CString -> CString -> IO (CInt)
774 mv :: GuestfsH -> String -> String -> IO ()
776 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_mv p src dest)
783 foreign import ccall unsafe "guestfs_ping_daemon" c_ping_daemon
784 :: GuestfsP -> IO (CInt)
786 ping_daemon :: GuestfsH -> IO ()
788 r <- withForeignPtr h (\p -> c_ping_daemon p)
795 foreign import ccall unsafe "guestfs_zerofree" c_zerofree
796 :: GuestfsP -> CString -> IO (CInt)
798 zerofree :: GuestfsH -> String -> IO ()
799 zerofree h device = do
800 r <- withCString device $ \device -> withForeignPtr h (\p -> c_zerofree p device)
807 foreign import ccall unsafe "guestfs_pvresize" c_pvresize
808 :: GuestfsP -> CString -> IO (CInt)
810 pvresize :: GuestfsH -> String -> IO ()
811 pvresize h device = do
812 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvresize p device)
819 foreign import ccall unsafe "guestfs_resize2fs" c_resize2fs
820 :: GuestfsP -> CString -> IO (CInt)
822 resize2fs :: GuestfsH -> String -> IO ()
823 resize2fs h device = do
824 r <- withCString device $ \device -> withForeignPtr h (\p -> c_resize2fs p device)
831 foreign import ccall unsafe "guestfs_e2fsck_f" c_e2fsck_f
832 :: GuestfsP -> CString -> IO (CInt)
834 e2fsck_f :: GuestfsH -> String -> IO ()
835 e2fsck_f h device = do
836 r <- withCString device $ \device -> withForeignPtr h (\p -> c_e2fsck_f p device)