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 #-}
94 import Control.Exception
97 data GuestfsS = GuestfsS -- represents the opaque C struct
98 type GuestfsP = Ptr GuestfsS -- guestfs_h *
99 type GuestfsH = ForeignPtr GuestfsS -- guestfs_h * with attached finalizer
101 -- XXX define properly later XXX
105 data IntBool = IntBool
107 data StatVFS = StatVFS
108 data Hashtable = Hashtable
110 foreign import ccall unsafe "guestfs_create" c_create
112 foreign import ccall unsafe "&guestfs_close" c_close
113 :: FunPtr (GuestfsP -> IO ())
114 foreign import ccall unsafe "guestfs_set_error_handler" c_set_error_handler
115 :: GuestfsP -> Ptr CInt -> Ptr CInt -> IO ()
117 create :: IO GuestfsH
120 c_set_error_handler p nullPtr nullPtr
121 h <- newForeignPtr c_close p
124 foreign import ccall unsafe "guestfs_last_error" c_last_error
125 :: GuestfsP -> IO CString
127 -- last_error :: GuestfsH -> IO (Maybe String)
129 -- str <- withForeignPtr h (\p -> c_last_error p)
130 -- maybePeek peekCString str
132 last_error :: GuestfsH -> IO (String)
134 str <- withForeignPtr h (\p -> c_last_error p)
136 then return "no error"
139 foreign import ccall unsafe "guestfs_launch" c_launch
140 :: GuestfsP -> IO (CInt)
142 launch :: GuestfsH -> IO ()
144 r <- withForeignPtr h (\p -> c_launch p)
151 foreign import ccall unsafe "guestfs_wait_ready" c_wait_ready
152 :: GuestfsP -> IO (CInt)
154 wait_ready :: GuestfsH -> IO ()
156 r <- withForeignPtr h (\p -> c_wait_ready p)
163 foreign import ccall unsafe "guestfs_kill_subprocess" c_kill_subprocess
164 :: GuestfsP -> IO (CInt)
166 kill_subprocess :: GuestfsH -> IO ()
167 kill_subprocess h = do
168 r <- withForeignPtr h (\p -> c_kill_subprocess p)
175 foreign import ccall unsafe "guestfs_add_drive" c_add_drive
176 :: GuestfsP -> CString -> IO (CInt)
178 add_drive :: GuestfsH -> String -> IO ()
179 add_drive h filename = do
180 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_drive p filename)
187 foreign import ccall unsafe "guestfs_add_cdrom" c_add_cdrom
188 :: GuestfsP -> CString -> IO (CInt)
190 add_cdrom :: GuestfsH -> String -> IO ()
191 add_cdrom h filename = do
192 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_cdrom p filename)
199 foreign import ccall unsafe "guestfs_add_drive_ro" c_add_drive_ro
200 :: GuestfsP -> CString -> IO (CInt)
202 add_drive_ro :: GuestfsH -> String -> IO ()
203 add_drive_ro h filename = do
204 r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_drive_ro p filename)
211 foreign import ccall unsafe "guestfs_config" c_config
212 :: GuestfsP -> CString -> CString -> IO (CInt)
214 config :: GuestfsH -> String -> Maybe String -> IO ()
215 config h qemuparam qemuvalue = do
216 r <- withCString qemuparam $ \qemuparam -> maybeWith withCString qemuvalue $ \qemuvalue -> withForeignPtr h (\p -> c_config p qemuparam qemuvalue)
223 foreign import ccall unsafe "guestfs_set_qemu" c_set_qemu
224 :: GuestfsP -> CString -> IO (CInt)
226 set_qemu :: GuestfsH -> String -> IO ()
228 r <- withCString qemu $ \qemu -> withForeignPtr h (\p -> c_set_qemu p qemu)
235 foreign import ccall unsafe "guestfs_set_path" c_set_path
236 :: GuestfsP -> CString -> IO (CInt)
238 set_path :: GuestfsH -> String -> IO ()
240 r <- withCString path $ \path -> withForeignPtr h (\p -> c_set_path p path)
247 foreign import ccall unsafe "guestfs_set_append" c_set_append
248 :: GuestfsP -> CString -> IO (CInt)
250 set_append :: GuestfsH -> String -> IO ()
251 set_append h append = do
252 r <- withCString append $ \append -> withForeignPtr h (\p -> c_set_append p append)
259 foreign import ccall unsafe "guestfs_set_busy" c_set_busy
260 :: GuestfsP -> IO (CInt)
262 set_busy :: GuestfsH -> IO ()
264 r <- withForeignPtr h (\p -> c_set_busy p)
271 foreign import ccall unsafe "guestfs_set_ready" c_set_ready
272 :: GuestfsP -> IO (CInt)
274 set_ready :: GuestfsH -> IO ()
276 r <- withForeignPtr h (\p -> c_set_ready p)
283 foreign import ccall unsafe "guestfs_end_busy" c_end_busy
284 :: GuestfsP -> IO (CInt)
286 end_busy :: GuestfsH -> IO ()
288 r <- withForeignPtr h (\p -> c_end_busy p)
295 foreign import ccall unsafe "guestfs_mount" c_mount
296 :: GuestfsP -> CString -> CString -> IO (CInt)
298 mount :: GuestfsH -> String -> String -> IO ()
299 mount h device mountpoint = do
300 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount p device mountpoint)
307 foreign import ccall unsafe "guestfs_sync" c_sync
308 :: GuestfsP -> IO (CInt)
310 sync :: GuestfsH -> IO ()
312 r <- withForeignPtr h (\p -> c_sync p)
319 foreign import ccall unsafe "guestfs_touch" c_touch
320 :: GuestfsP -> CString -> IO (CInt)
322 touch :: GuestfsH -> String -> IO ()
324 r <- withCString path $ \path -> withForeignPtr h (\p -> c_touch p path)
331 foreign import ccall unsafe "guestfs_aug_close" c_aug_close
332 :: GuestfsP -> IO (CInt)
334 aug_close :: GuestfsH -> IO ()
336 r <- withForeignPtr h (\p -> c_aug_close p)
343 foreign import ccall unsafe "guestfs_aug_set" c_aug_set
344 :: GuestfsP -> CString -> CString -> IO (CInt)
346 aug_set :: GuestfsH -> String -> String -> IO ()
347 aug_set h path val = do
348 r <- withCString path $ \path -> withCString val $ \val -> withForeignPtr h (\p -> c_aug_set p path val)
355 foreign import ccall unsafe "guestfs_aug_mv" c_aug_mv
356 :: GuestfsP -> CString -> CString -> IO (CInt)
358 aug_mv :: GuestfsH -> String -> String -> IO ()
359 aug_mv h src dest = do
360 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_aug_mv p src dest)
367 foreign import ccall unsafe "guestfs_aug_save" c_aug_save
368 :: GuestfsP -> IO (CInt)
370 aug_save :: GuestfsH -> IO ()
372 r <- withForeignPtr h (\p -> c_aug_save p)
379 foreign import ccall unsafe "guestfs_aug_load" c_aug_load
380 :: GuestfsP -> IO (CInt)
382 aug_load :: GuestfsH -> IO ()
384 r <- withForeignPtr h (\p -> c_aug_load p)
391 foreign import ccall unsafe "guestfs_rm" c_rm
392 :: GuestfsP -> CString -> IO (CInt)
394 rm :: GuestfsH -> String -> IO ()
396 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm p path)
403 foreign import ccall unsafe "guestfs_rmdir" c_rmdir
404 :: GuestfsP -> CString -> IO (CInt)
406 rmdir :: GuestfsH -> String -> IO ()
408 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rmdir p path)
415 foreign import ccall unsafe "guestfs_rm_rf" c_rm_rf
416 :: GuestfsP -> CString -> IO (CInt)
418 rm_rf :: GuestfsH -> String -> IO ()
420 r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm_rf p path)
427 foreign import ccall unsafe "guestfs_mkdir" c_mkdir
428 :: GuestfsP -> CString -> IO (CInt)
430 mkdir :: GuestfsH -> String -> IO ()
432 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir p path)
439 foreign import ccall unsafe "guestfs_mkdir_p" c_mkdir_p
440 :: GuestfsP -> CString -> IO (CInt)
442 mkdir_p :: GuestfsH -> String -> IO ()
444 r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir_p p path)
451 foreign import ccall unsafe "guestfs_pvcreate" c_pvcreate
452 :: GuestfsP -> CString -> IO (CInt)
454 pvcreate :: GuestfsH -> String -> IO ()
455 pvcreate h device = do
456 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvcreate p device)
463 foreign import ccall unsafe "guestfs_vgcreate" c_vgcreate
464 :: GuestfsP -> CString -> Ptr CString -> IO (CInt)
466 vgcreate :: GuestfsH -> String -> [String] -> IO ()
467 vgcreate h volgroup physvols = do
468 r <- withCString volgroup $ \volgroup -> withMany withCString physvols $ \physvols -> withArray0 nullPtr physvols $ \physvols -> withForeignPtr h (\p -> c_vgcreate p volgroup physvols)
475 foreign import ccall unsafe "guestfs_mkfs" c_mkfs
476 :: GuestfsP -> CString -> CString -> IO (CInt)
478 mkfs :: GuestfsH -> String -> String -> IO ()
479 mkfs h fstype device = do
480 r <- withCString fstype $ \fstype -> withCString device $ \device -> withForeignPtr h (\p -> c_mkfs p fstype device)
487 foreign import ccall unsafe "guestfs_umount" c_umount
488 :: GuestfsP -> CString -> IO (CInt)
490 umount :: GuestfsH -> String -> IO ()
491 umount h pathordevice = do
492 r <- withCString pathordevice $ \pathordevice -> withForeignPtr h (\p -> c_umount p pathordevice)
499 foreign import ccall unsafe "guestfs_umount_all" c_umount_all
500 :: GuestfsP -> IO (CInt)
502 umount_all :: GuestfsH -> IO ()
504 r <- withForeignPtr h (\p -> c_umount_all p)
511 foreign import ccall unsafe "guestfs_lvm_remove_all" c_lvm_remove_all
512 :: GuestfsP -> IO (CInt)
514 lvm_remove_all :: GuestfsH -> IO ()
515 lvm_remove_all h = do
516 r <- withForeignPtr h (\p -> c_lvm_remove_all p)
523 foreign import ccall unsafe "guestfs_blockdev_setro" c_blockdev_setro
524 :: GuestfsP -> CString -> IO (CInt)
526 blockdev_setro :: GuestfsH -> String -> IO ()
527 blockdev_setro h device = do
528 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setro p device)
535 foreign import ccall unsafe "guestfs_blockdev_setrw" c_blockdev_setrw
536 :: GuestfsP -> CString -> IO (CInt)
538 blockdev_setrw :: GuestfsH -> String -> IO ()
539 blockdev_setrw h device = do
540 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setrw p device)
547 foreign import ccall unsafe "guestfs_blockdev_flushbufs" c_blockdev_flushbufs
548 :: GuestfsP -> CString -> IO (CInt)
550 blockdev_flushbufs :: GuestfsH -> String -> IO ()
551 blockdev_flushbufs h device = do
552 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_flushbufs p device)
559 foreign import ccall unsafe "guestfs_blockdev_rereadpt" c_blockdev_rereadpt
560 :: GuestfsP -> CString -> IO (CInt)
562 blockdev_rereadpt :: GuestfsH -> String -> IO ()
563 blockdev_rereadpt h device = do
564 r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_rereadpt p device)
571 foreign import ccall unsafe "guestfs_upload" c_upload
572 :: GuestfsP -> CString -> CString -> IO (CInt)
574 upload :: GuestfsH -> String -> String -> IO ()
575 upload h filename remotefilename = do
576 r <- withCString filename $ \filename -> withCString remotefilename $ \remotefilename -> withForeignPtr h (\p -> c_upload p filename remotefilename)
583 foreign import ccall unsafe "guestfs_download" c_download
584 :: GuestfsP -> CString -> CString -> IO (CInt)
586 download :: GuestfsH -> String -> String -> IO ()
587 download h remotefilename filename = do
588 r <- withCString remotefilename $ \remotefilename -> withCString filename $ \filename -> withForeignPtr h (\p -> c_download p remotefilename filename)
595 foreign import ccall unsafe "guestfs_tar_in" c_tar_in
596 :: GuestfsP -> CString -> CString -> IO (CInt)
598 tar_in :: GuestfsH -> String -> String -> IO ()
599 tar_in h tarfile directory = do
600 r <- withCString tarfile $ \tarfile -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tar_in p tarfile directory)
607 foreign import ccall unsafe "guestfs_tar_out" c_tar_out
608 :: GuestfsP -> CString -> CString -> IO (CInt)
610 tar_out :: GuestfsH -> String -> String -> IO ()
611 tar_out h directory tarfile = do
612 r <- withCString directory $ \directory -> withCString tarfile $ \tarfile -> withForeignPtr h (\p -> c_tar_out p directory tarfile)
619 foreign import ccall unsafe "guestfs_tgz_in" c_tgz_in
620 :: GuestfsP -> CString -> CString -> IO (CInt)
622 tgz_in :: GuestfsH -> String -> String -> IO ()
623 tgz_in h tarball directory = do
624 r <- withCString tarball $ \tarball -> withCString directory $ \directory -> withForeignPtr h (\p -> c_tgz_in p tarball directory)
631 foreign import ccall unsafe "guestfs_tgz_out" c_tgz_out
632 :: GuestfsP -> CString -> CString -> IO (CInt)
634 tgz_out :: GuestfsH -> String -> String -> IO ()
635 tgz_out h directory tarball = do
636 r <- withCString directory $ \directory -> withCString tarball $ \tarball -> withForeignPtr h (\p -> c_tgz_out p directory tarball)
643 foreign import ccall unsafe "guestfs_mount_ro" c_mount_ro
644 :: GuestfsP -> CString -> CString -> IO (CInt)
646 mount_ro :: GuestfsH -> String -> String -> IO ()
647 mount_ro h device mountpoint = do
648 r <- withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_ro p device mountpoint)
655 foreign import ccall unsafe "guestfs_mount_options" c_mount_options
656 :: GuestfsP -> CString -> CString -> CString -> IO (CInt)
658 mount_options :: GuestfsH -> String -> String -> String -> IO ()
659 mount_options h options device mountpoint = do
660 r <- withCString options $ \options -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_options p options device mountpoint)
667 foreign import ccall unsafe "guestfs_mount_vfs" c_mount_vfs
668 :: GuestfsP -> CString -> CString -> CString -> CString -> IO (CInt)
670 mount_vfs :: GuestfsH -> String -> String -> String -> String -> IO ()
671 mount_vfs h options vfstype device mountpoint = do
672 r <- withCString options $ \options -> withCString vfstype $ \vfstype -> withCString device $ \device -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_vfs p options vfstype device mountpoint)
679 foreign import ccall unsafe "guestfs_lvremove" c_lvremove
680 :: GuestfsP -> CString -> IO (CInt)
682 lvremove :: GuestfsH -> String -> IO ()
683 lvremove h device = do
684 r <- withCString device $ \device -> withForeignPtr h (\p -> c_lvremove p device)
691 foreign import ccall unsafe "guestfs_vgremove" c_vgremove
692 :: GuestfsP -> CString -> IO (CInt)
694 vgremove :: GuestfsH -> String -> IO ()
695 vgremove h vgname = do
696 r <- withCString vgname $ \vgname -> withForeignPtr h (\p -> c_vgremove p vgname)
703 foreign import ccall unsafe "guestfs_pvremove" c_pvremove
704 :: GuestfsP -> CString -> IO (CInt)
706 pvremove :: GuestfsH -> String -> IO ()
707 pvremove h device = do
708 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvremove p device)
715 foreign import ccall unsafe "guestfs_set_e2label" c_set_e2label
716 :: GuestfsP -> CString -> CString -> IO (CInt)
718 set_e2label :: GuestfsH -> String -> String -> IO ()
719 set_e2label h device label = do
720 r <- withCString device $ \device -> withCString label $ \label -> withForeignPtr h (\p -> c_set_e2label p device label)
727 foreign import ccall unsafe "guestfs_set_e2uuid" c_set_e2uuid
728 :: GuestfsP -> CString -> CString -> IO (CInt)
730 set_e2uuid :: GuestfsH -> String -> String -> IO ()
731 set_e2uuid h device uuid = do
732 r <- withCString device $ \device -> withCString uuid $ \uuid -> withForeignPtr h (\p -> c_set_e2uuid p device uuid)
739 foreign import ccall unsafe "guestfs_zero" c_zero
740 :: GuestfsP -> CString -> IO (CInt)
742 zero :: GuestfsH -> String -> IO ()
744 r <- withCString device $ \device -> withForeignPtr h (\p -> c_zero p device)
751 foreign import ccall unsafe "guestfs_grub_install" c_grub_install
752 :: GuestfsP -> CString -> CString -> IO (CInt)
754 grub_install :: GuestfsH -> String -> String -> IO ()
755 grub_install h root device = do
756 r <- withCString root $ \root -> withCString device $ \device -> withForeignPtr h (\p -> c_grub_install p root device)
763 foreign import ccall unsafe "guestfs_cp" c_cp
764 :: GuestfsP -> CString -> CString -> IO (CInt)
766 cp :: GuestfsH -> String -> String -> IO ()
768 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp p src dest)
775 foreign import ccall unsafe "guestfs_cp_a" c_cp_a
776 :: GuestfsP -> CString -> CString -> IO (CInt)
778 cp_a :: GuestfsH -> String -> String -> IO ()
780 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp_a p src dest)
787 foreign import ccall unsafe "guestfs_mv" c_mv
788 :: GuestfsP -> CString -> CString -> IO (CInt)
790 mv :: GuestfsH -> String -> String -> IO ()
792 r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_mv p src dest)
799 foreign import ccall unsafe "guestfs_ping_daemon" c_ping_daemon
800 :: GuestfsP -> IO (CInt)
802 ping_daemon :: GuestfsH -> IO ()
804 r <- withForeignPtr h (\p -> c_ping_daemon p)
811 foreign import ccall unsafe "guestfs_zerofree" c_zerofree
812 :: GuestfsP -> CString -> IO (CInt)
814 zerofree :: GuestfsH -> String -> IO ()
815 zerofree h device = do
816 r <- withCString device $ \device -> withForeignPtr h (\p -> c_zerofree p device)
823 foreign import ccall unsafe "guestfs_pvresize" c_pvresize
824 :: GuestfsP -> CString -> IO (CInt)
826 pvresize :: GuestfsH -> String -> IO ()
827 pvresize h device = do
828 r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvresize p device)
835 foreign import ccall unsafe "guestfs_resize2fs" c_resize2fs
836 :: GuestfsP -> CString -> IO (CInt)
838 resize2fs :: GuestfsH -> String -> IO ()
839 resize2fs h device = do
840 r <- withCString device $ \device -> withForeignPtr h (\p -> c_resize2fs p device)
847 foreign import ccall unsafe "guestfs_e2fsck_f" c_e2fsck_f
848 :: GuestfsP -> CString -> IO (CInt)
850 e2fsck_f :: GuestfsH -> String -> IO ()
851 e2fsck_f h device = do
852 r <- withCString device $ \device -> withForeignPtr h (\p -> c_e2fsck_f p device)
859 foreign import ccall unsafe "guestfs_scrub_device" c_scrub_device
860 :: GuestfsP -> CString -> IO (CInt)
862 scrub_device :: GuestfsH -> String -> IO ()
863 scrub_device h device = do
864 r <- withCString device $ \device -> withForeignPtr h (\p -> c_scrub_device p device)
871 foreign import ccall unsafe "guestfs_scrub_file" c_scrub_file
872 :: GuestfsP -> CString -> IO (CInt)
874 scrub_file :: GuestfsH -> String -> IO ()
875 scrub_file h file = do
876 r <- withCString file $ \file -> withForeignPtr h (\p -> c_scrub_file p file)
883 foreign import ccall unsafe "guestfs_scrub_freespace" c_scrub_freespace
884 :: GuestfsP -> CString -> IO (CInt)
886 scrub_freespace :: GuestfsH -> String -> IO ()
887 scrub_freespace h dir = do
888 r <- withCString dir $ \dir -> withForeignPtr h (\p -> c_scrub_freespace p dir)