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 #-}
91 import Control.Exception
94 data GuestfsS = GuestfsS -- represents the opaque C struct
95 type GuestfsP = Ptr GuestfsS -- guestfs_h *
96 type GuestfsH = ForeignPtr GuestfsS -- guestfs_h * with attached finalizer
98 -- XXX define properly later XXX
102 data IntBool = IntBool
104 data StatVFS = StatVFS
105 data Hashtable = Hashtable
107 foreign import ccall unsafe "guestfs_create" c_create
109 foreign import ccall unsafe "&guestfs_close" c_close
110 :: FunPtr (GuestfsP -> IO ())
111 foreign import ccall unsafe "guestfs_set_error_handler" c_set_error_handler
112 :: GuestfsP -> Ptr CInt -> Ptr CInt -> IO ()
114 create :: IO GuestfsH
117 c_set_error_handler p nullPtr nullPtr
118 h <- newForeignPtr c_close p
121 foreign import ccall unsafe "guestfs_last_error" c_last_error
122 :: GuestfsP -> IO CString
124 -- last_error :: GuestfsH -> IO (Maybe String)
126 -- str <- withForeignPtr h (\p -> c_last_error p)
127 -- maybePeek peekCString str
129 last_error :: GuestfsH -> IO (String)
131 str <- withForeignPtr h (\p -> c_last_error p)
133 then return "no error"
136 foreign import ccall unsafe "guestfs_launch" c_launch
137 :: GuestfsP -> IO (CInt)
139 launch :: GuestfsH -> IO ()
141 r <- withForeignPtr h (\p -> c_launch p)
148 foreign import ccall unsafe "guestfs_wait_ready" c_wait_ready
149 :: GuestfsP -> IO (CInt)
151 wait_ready :: GuestfsH -> IO ()
153 r <- withForeignPtr h (\p -> c_wait_ready p)
160 foreign import ccall unsafe "guestfs_kill_subprocess" c_kill_subprocess
161 :: GuestfsP -> IO (CInt)
163 kill_subprocess :: GuestfsH -> IO ()
164 kill_subprocess h = do
165 r <- withForeignPtr h (\p -> c_kill_subprocess p)
172 foreign import ccall unsafe "guestfs_add_drive" c_add_drive
173 :: GuestfsP -> CString -> IO (CInt)
175 add_drive :: GuestfsH -> String -> IO ()
176 add_drive h filename = do
177 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_drive p filename)
184 foreign import ccall unsafe "guestfs_add_cdrom" c_add_cdrom
185 :: GuestfsP -> CString -> IO (CInt)
187 add_cdrom :: GuestfsH -> String -> IO ()
188 add_cdrom h filename = do
189 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_cdrom p filename)
196 foreign import ccall unsafe "guestfs_add_drive_ro" c_add_drive_ro
197 :: GuestfsP -> CString -> IO (CInt)
199 add_drive_ro :: GuestfsH -> String -> IO ()
200 add_drive_ro h filename = do
201 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_drive_ro p filename)
208 foreign import ccall unsafe "guestfs_config" c_config
209 :: GuestfsP -> CString -> CString -> IO (CInt)
211 config :: GuestfsH -> String -> Maybe String -> IO ()
212 config h qemuparam qemuvalue = do
213 r <- withCString qemuparam $ \qemuparam -> maybeWith withCString qemuvalue $ \qemuvalue -> withForeignPtr h (\p -> c_config p qemuparam qemuvalue)
220 foreign import ccall unsafe "guestfs_set_qemu" c_set_qemu
221 :: GuestfsP -> CString -> IO (CInt)
223 set_qemu :: GuestfsH -> String -> IO ()
225 r <- withCString qemu $ \qemu -> withForeignPtr h (\p -> c_set_qemu p qemu)
232 foreign import ccall unsafe "guestfs_set_path" c_set_path
233 :: GuestfsP -> CString -> IO (CInt)
235 set_path :: GuestfsH -> String -> IO ()
237 r <- withCString path $ \path -> withForeignPtr h (\p -> c_set_path p path)
244 foreign import ccall unsafe "guestfs_set_append" c_set_append
245 :: GuestfsP -> CString -> IO (CInt)
247 set_append :: GuestfsH -> String -> IO ()
248 set_append h append = do
249 r <- withCString append $ \append -> withForeignPtr h (\p -> c_set_append p append)
256 foreign import ccall unsafe "guestfs_set_busy" c_set_busy
257 :: GuestfsP -> IO (CInt)
259 set_busy :: GuestfsH -> IO ()
261 r <- withForeignPtr h (\p -> c_set_busy p)
268 foreign import ccall unsafe "guestfs_set_ready" c_set_ready
269 :: GuestfsP -> IO (CInt)
271 set_ready :: GuestfsH -> IO ()
273 r <- withForeignPtr h (\p -> c_set_ready p)
280 foreign import ccall unsafe "guestfs_end_busy" c_end_busy
281 :: GuestfsP -> IO (CInt)
283 end_busy :: GuestfsH -> IO ()
285 r <- withForeignPtr h (\p -> c_end_busy p)
292 foreign import ccall unsafe "guestfs_mount" c_mount
293 :: GuestfsP -> CString -> CString -> IO (CInt)
295 mount :: GuestfsH -> String -> String -> IO ()
296 mount h device mountpoint = do
297 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount p device mountpoint)
304 foreign import ccall unsafe "guestfs_sync" c_sync
305 :: GuestfsP -> IO (CInt)
307 sync :: GuestfsH -> IO ()
309 r <- withForeignPtr h (\p -> c_sync p)
316 foreign import ccall unsafe "guestfs_touch" c_touch
317 :: GuestfsP -> CString -> IO (CInt)
319 touch :: GuestfsH -> String -> IO ()
321 r <- withCString path $ \path -> withForeignPtr h (\p -> c_touch p path)
328 foreign import ccall unsafe "guestfs_aug_close" c_aug_close
329 :: GuestfsP -> IO (CInt)
331 aug_close :: GuestfsH -> IO ()
333 r <- withForeignPtr h (\p -> c_aug_close p)
340 foreign import ccall unsafe "guestfs_aug_set" c_aug_set
341 :: GuestfsP -> CString -> CString -> IO (CInt)
343 aug_set :: GuestfsH -> String -> String -> IO ()
344 aug_set h path val = do
345 r <- withCString path $ \path -> withCString val $ \val -> withForeignPtr h (\p -> c_aug_set p path val)
352 foreign import ccall unsafe "guestfs_aug_mv" c_aug_mv
353 :: GuestfsP -> CString -> CString -> IO (CInt)
355 aug_mv :: GuestfsH -> String -> String -> IO ()
356 aug_mv h src dest = do
357 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_aug_mv p src dest)
364 foreign import ccall unsafe "guestfs_aug_save" c_aug_save
365 :: GuestfsP -> IO (CInt)
367 aug_save :: GuestfsH -> IO ()
369 r <- withForeignPtr h (\p -> c_aug_save p)
376 foreign import ccall unsafe "guestfs_aug_load" c_aug_load
377 :: GuestfsP -> IO (CInt)
379 aug_load :: GuestfsH -> IO ()
381 r <- withForeignPtr h (\p -> c_aug_load p)
388 foreign import ccall unsafe "guestfs_rm" c_rm
389 :: GuestfsP -> CString -> IO (CInt)
391 rm :: GuestfsH -> String -> IO ()
393 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm p path)
400 foreign import ccall unsafe "guestfs_rmdir" c_rmdir
401 :: GuestfsP -> CString -> IO (CInt)
403 rmdir :: GuestfsH -> String -> IO ()
405 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rmdir p path)
412 foreign import ccall unsafe "guestfs_rm_rf" c_rm_rf
413 :: GuestfsP -> CString -> IO (CInt)
415 rm_rf :: GuestfsH -> String -> IO ()
417 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm_rf p path)
424 foreign import ccall unsafe "guestfs_mkdir" c_mkdir
425 :: GuestfsP -> CString -> IO (CInt)
427 mkdir :: GuestfsH -> String -> IO ()
429 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir p path)
436 foreign import ccall unsafe "guestfs_mkdir_p" c_mkdir_p
437 :: GuestfsP -> CString -> IO (CInt)
439 mkdir_p :: GuestfsH -> String -> IO ()
441 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir_p p path)
448 foreign import ccall unsafe "guestfs_pvcreate" c_pvcreate
449 :: GuestfsP -> CString -> IO (CInt)
451 pvcreate :: GuestfsH -> String -> IO ()
452 pvcreate h device = do
453 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvcreate p device)
460 foreign import ccall unsafe "guestfs_vgcreate" c_vgcreate
461 :: GuestfsP -> CString -> Ptr CString -> IO (CInt)
463 vgcreate :: GuestfsH -> String -> [String] -> IO ()
464 vgcreate h volgroup physvols = do
465 r <- withCString volgroup $ \volgroup -> withMany withCString physvols $ \physvols -> withArray0 nullPtr physvols $ \physvols -> withForeignPtr h (\p -> c_vgcreate p volgroup physvols)
472 foreign import ccall unsafe "guestfs_mkfs" c_mkfs
473 :: GuestfsP -> CString -> CString -> IO (CInt)
475 mkfs :: GuestfsH -> String -> String -> IO ()
476 mkfs h fstype device = do
477 r <- withCString fstype $ \fstype -> withCString device $ \device -> withForeignPtr h (\p -> c_mkfs p fstype device)
484 foreign import ccall unsafe "guestfs_umount" c_umount
485 :: GuestfsP -> CString -> IO (CInt)
487 umount :: GuestfsH -> String -> IO ()
488 umount h pathordevice = do
489 r <- withCString pathordevice $ \pathordevice -> withForeignPtr h (\p -> c_umount p pathordevice)
496 foreign import ccall unsafe "guestfs_umount_all" c_umount_all
497 :: GuestfsP -> IO (CInt)
499 umount_all :: GuestfsH -> IO ()
501 r <- withForeignPtr h (\p -> c_umount_all p)
508 foreign import ccall unsafe "guestfs_lvm_remove_all" c_lvm_remove_all
509 :: GuestfsP -> IO (CInt)
511 lvm_remove_all :: GuestfsH -> IO ()
512 lvm_remove_all h = do
513 r <- withForeignPtr h (\p -> c_lvm_remove_all p)
520 foreign import ccall unsafe "guestfs_blockdev_setro" c_blockdev_setro
521 :: GuestfsP -> CString -> IO (CInt)
523 blockdev_setro :: GuestfsH -> String -> IO ()
524 blockdev_setro h device = do
525 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setro p device)
532 foreign import ccall unsafe "guestfs_blockdev_setrw" c_blockdev_setrw
533 :: GuestfsP -> CString -> IO (CInt)
535 blockdev_setrw :: GuestfsH -> String -> IO ()
536 blockdev_setrw h device = do
537 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setrw p device)
544 foreign import ccall unsafe "guestfs_blockdev_flushbufs" c_blockdev_flushbufs
545 :: GuestfsP -> CString -> IO (CInt)
547 blockdev_flushbufs :: GuestfsH -> String -> IO ()
548 blockdev_flushbufs h device = do
549 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_flushbufs p device)
556 foreign import ccall unsafe "guestfs_blockdev_rereadpt" c_blockdev_rereadpt
557 :: GuestfsP -> CString -> IO (CInt)
559 blockdev_rereadpt :: GuestfsH -> String -> IO ()
560 blockdev_rereadpt h device = do
561 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_rereadpt p device)
568 foreign import ccall unsafe "guestfs_upload" c_upload
569 :: GuestfsP -> CString -> CString -> IO (CInt)
571 upload :: GuestfsH -> String -> String -> IO ()
572 upload h filename remotefilename = do
573 r <- withCString filename $ \filename -> withCString remotefilename $ \remotefilename -> withForeignPtr h (\p -> c_upload p filename remotefilename)
580 foreign import ccall unsafe "guestfs_download" c_download
581 :: GuestfsP -> CString -> CString -> IO (CInt)
583 download :: GuestfsH -> String -> String -> IO ()
584 download h remotefilename filename = do
585 r <- withCString remotefilename $ \remotefilename -> withCString filename $ \filename -> withForeignPtr h (\p -> c_download p remotefilename filename)
592 foreign import ccall unsafe "guestfs_tar_in" c_tar_in
593 :: GuestfsP -> CString -> CString -> IO (CInt)
595 tar_in :: GuestfsH -> String -> String -> IO ()
596 tar_in h tarfile directory = do
597 r <- withCString tarfile $ \tarfile -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tar_in p tarfile directory)
604 foreign import ccall unsafe "guestfs_tar_out" c_tar_out
605 :: GuestfsP -> CString -> CString -> IO (CInt)
607 tar_out :: GuestfsH -> String -> String -> IO ()
608 tar_out h directory tarfile = do
609 r <- withCString directory $ \directory -> withCString tarfile $ \tarfile -> withForeignPtr h (\p -> c_tar_out p directory tarfile)
616 foreign import ccall unsafe "guestfs_tgz_in" c_tgz_in
617 :: GuestfsP -> CString -> CString -> IO (CInt)
619 tgz_in :: GuestfsH -> String -> String -> IO ()
620 tgz_in h tarball directory = do
621 r <- withCString tarball $ \tarball -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tgz_in p tarball directory)
628 foreign import ccall unsafe "guestfs_tgz_out" c_tgz_out
629 :: GuestfsP -> CString -> CString -> IO (CInt)
631 tgz_out :: GuestfsH -> String -> String -> IO ()
632 tgz_out h directory tarball = do
633 r <- withCString directory $ \directory -> withCString tarball $ \tarball -> withForeignPtr h (\p -> c_tgz_out p directory tarball)
640 foreign import ccall unsafe "guestfs_mount_ro" c_mount_ro
641 :: GuestfsP -> CString -> CString -> IO (CInt)
643 mount_ro :: GuestfsH -> String -> String -> IO ()
644 mount_ro h device mountpoint = do
645 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_ro p device mountpoint)
652 foreign import ccall unsafe "guestfs_mount_options" c_mount_options
653 :: GuestfsP -> CString -> CString -> CString -> IO (CInt)
655 mount_options :: GuestfsH -> String -> String -> String -> IO ()
656 mount_options h options device mountpoint = do
657 r <- withCString options $ \options -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_options p options device mountpoint)
664 foreign import ccall unsafe "guestfs_mount_vfs" c_mount_vfs
665 :: GuestfsP -> CString -> CString -> CString -> CString -> IO (CInt)
667 mount_vfs :: GuestfsH -> String -> String -> String -> String -> IO ()
668 mount_vfs h options vfstype device mountpoint = do
669 r <- withCString options $ \options -> withCString vfstype $ \vfstype -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_vfs p options vfstype device mountpoint)
676 foreign import ccall unsafe "guestfs_lvremove" c_lvremove
677 :: GuestfsP -> CString -> IO (CInt)
679 lvremove :: GuestfsH -> String -> IO ()
680 lvremove h device = do
681 r <- withCString device $ \device -> withForeignPtr h (\p -> c_lvremove p device)
688 foreign import ccall unsafe "guestfs_vgremove" c_vgremove
689 :: GuestfsP -> CString -> IO (CInt)
691 vgremove :: GuestfsH -> String -> IO ()
692 vgremove h vgname = do
693 r <- withCString vgname $ \vgname -> withForeignPtr h (\p -> c_vgremove p vgname)
700 foreign import ccall unsafe "guestfs_pvremove" c_pvremove
701 :: GuestfsP -> CString -> IO (CInt)
703 pvremove :: GuestfsH -> String -> IO ()
704 pvremove h device = do
705 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvremove p device)
712 foreign import ccall unsafe "guestfs_set_e2label" c_set_e2label
713 :: GuestfsP -> CString -> CString -> IO (CInt)
715 set_e2label :: GuestfsH -> String -> String -> IO ()
716 set_e2label h device label = do
717 r <- withCString device $ \device -> withCString label $ \label -> withForeignPtr h (\p -> c_set_e2label p device label)
724 foreign import ccall unsafe "guestfs_set_e2uuid" c_set_e2uuid
725 :: GuestfsP -> CString -> CString -> IO (CInt)
727 set_e2uuid :: GuestfsH -> String -> String -> IO ()
728 set_e2uuid h device uuid = do
729 r <- withCString device $ \device -> withCString uuid $ \uuid -> withForeignPtr h (\p -> c_set_e2uuid p device uuid)
736 foreign import ccall unsafe "guestfs_zero" c_zero
737 :: GuestfsP -> CString -> IO (CInt)
739 zero :: GuestfsH -> String -> IO ()
741 r <- withCString device $ \device -> withForeignPtr h (\p -> c_zero p device)
748 foreign import ccall unsafe "guestfs_grub_install" c_grub_install
749 :: GuestfsP -> CString -> CString -> IO (CInt)
751 grub_install :: GuestfsH -> String -> String -> IO ()
752 grub_install h root device = do
753 r <- withCString root $ \root -> withCString device $ \device -> withForeignPtr h (\p -> c_grub_install p root device)
760 foreign import ccall unsafe "guestfs_cp" c_cp
761 :: GuestfsP -> CString -> CString -> IO (CInt)
763 cp :: GuestfsH -> String -> String -> IO ()
765 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp p src dest)
772 foreign import ccall unsafe "guestfs_cp_a" c_cp_a
773 :: GuestfsP -> CString -> CString -> IO (CInt)
775 cp_a :: GuestfsH -> String -> String -> IO ()
777 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp_a p src dest)
784 foreign import ccall unsafe "guestfs_mv" c_mv
785 :: GuestfsP -> CString -> CString -> IO (CInt)
787 mv :: GuestfsH -> String -> String -> IO ()
789 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_mv p src dest)
796 foreign import ccall unsafe "guestfs_ping_daemon" c_ping_daemon
797 :: GuestfsP -> IO (CInt)
799 ping_daemon :: GuestfsH -> IO ()
801 r <- withForeignPtr h (\p -> c_ping_daemon p)
808 foreign import ccall unsafe "guestfs_zerofree" c_zerofree
809 :: GuestfsP -> CString -> IO (CInt)
811 zerofree :: GuestfsH -> String -> IO ()
812 zerofree h device = do
813 r <- withCString device $ \device -> withForeignPtr h (\p -> c_zerofree p device)
820 foreign import ccall unsafe "guestfs_pvresize" c_pvresize
821 :: GuestfsP -> CString -> IO (CInt)
823 pvresize :: GuestfsH -> String -> IO ()
824 pvresize h device = do
825 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvresize p device)
832 foreign import ccall unsafe "guestfs_resize2fs" c_resize2fs
833 :: GuestfsP -> CString -> IO (CInt)
835 resize2fs :: GuestfsH -> String -> IO ()
836 resize2fs h device = do
837 r <- withCString device $ \device -> withForeignPtr h (\p -> c_resize2fs p device)
844 foreign import ccall unsafe "guestfs_e2fsck_f" c_e2fsck_f
845 :: GuestfsP -> CString -> IO (CInt)
847 e2fsck_f :: GuestfsH -> String -> IO ()
848 e2fsck_f h device = do
849 r <- withCString device $ \device -> withForeignPtr h (\p -> c_e2fsck_f p device)