Fix detection of optional libvirt support in virt-inspector.
[libguestfs.git] / haskell / Guestfs.hs
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.
4   
5    Copyright (C) 2009 Red Hat Inc.
6   
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.
11   
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.
16   
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
20 -}
21
22 {-# INCLUDE <guestfs.h> #-}
23 {-# LANGUAGE ForeignFunctionInterface #-}
24
25 module Guestfs (
26   create,
27   launch,
28   wait_ready,
29   kill_subprocess,
30   add_drive,
31   add_cdrom,
32   add_drive_ro,
33   config,
34   set_qemu,
35   set_path,
36   set_append,
37   set_busy,
38   set_ready,
39   end_busy,
40   mount,
41   sync,
42   touch,
43   aug_close,
44   aug_set,
45   aug_mv,
46   aug_save,
47   aug_load,
48   rm,
49   rmdir,
50   rm_rf,
51   mkdir,
52   mkdir_p,
53   pvcreate,
54   vgcreate,
55   mkfs,
56   umount,
57   umount_all,
58   lvm_remove_all,
59   blockdev_setro,
60   blockdev_setrw,
61   blockdev_flushbufs,
62   blockdev_rereadpt,
63   upload,
64   download,
65   tar_in,
66   tar_out,
67   tgz_in,
68   tgz_out,
69   mount_ro,
70   mount_options,
71   mount_vfs,
72   lvremove,
73   vgremove,
74   pvremove,
75   set_e2label,
76   set_e2uuid,
77   zero,
78   grub_install,
79   cp,
80   cp_a,
81   mv,
82   ping_daemon,
83   zerofree,
84   pvresize,
85   resize2fs,
86   e2fsck_f,
87   scrub_device,
88   scrub_file,
89   scrub_freespace
90   ) where
91 import Foreign
92 import Foreign.C
93 import IO
94 import Control.Exception
95 import Data.Typeable
96
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
100
101 -- XXX define properly later XXX
102 data PV = PV
103 data VG = VG
104 data LV = LV
105 data IntBool = IntBool
106 data Stat = Stat
107 data StatVFS = StatVFS
108 data Hashtable = Hashtable
109
110 foreign import ccall unsafe "guestfs_create" c_create
111   :: IO GuestfsP
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 ()
116
117 create :: IO GuestfsH
118 create = do
119   p <- c_create
120   c_set_error_handler p nullPtr nullPtr
121   h <- newForeignPtr c_close p
122   return h
123
124 foreign import ccall unsafe "guestfs_last_error" c_last_error
125   :: GuestfsP -> IO CString
126
127 -- last_error :: GuestfsH -> IO (Maybe String)
128 -- last_error h = do
129 --   str <- withForeignPtr h (\p -> c_last_error p)
130 --   maybePeek peekCString str
131
132 last_error :: GuestfsH -> IO (String)
133 last_error h = do
134   str <- withForeignPtr h (\p -> c_last_error p)
135   if (str == nullPtr)
136     then return "no error"
137     else peekCString str
138
139 foreign import ccall unsafe "guestfs_launch" c_launch
140   :: GuestfsP -> IO (CInt)
141
142 launch :: GuestfsH -> IO ()
143 launch h = do
144   r <- withForeignPtr h (\p -> c_launch p)
145   if (r == -1)
146     then do
147       err <- last_error h
148       fail err
149     else return ()
150
151 foreign import ccall unsafe "guestfs_wait_ready" c_wait_ready
152   :: GuestfsP -> IO (CInt)
153
154 wait_ready :: GuestfsH -> IO ()
155 wait_ready h = do
156   r <- withForeignPtr h (\p -> c_wait_ready p)
157   if (r == -1)
158     then do
159       err <- last_error h
160       fail err
161     else return ()
162
163 foreign import ccall unsafe "guestfs_kill_subprocess" c_kill_subprocess
164   :: GuestfsP -> IO (CInt)
165
166 kill_subprocess :: GuestfsH -> IO ()
167 kill_subprocess h = do
168   r <- withForeignPtr h (\p -> c_kill_subprocess p)
169   if (r == -1)
170     then do
171       err <- last_error h
172       fail err
173     else return ()
174
175 foreign import ccall unsafe "guestfs_add_drive" c_add_drive
176   :: GuestfsP -> CString -> IO (CInt)
177
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)
181   if (r == -1)
182     then do
183       err <- last_error h
184       fail err
185     else return ()
186
187 foreign import ccall unsafe "guestfs_add_cdrom" c_add_cdrom
188   :: GuestfsP -> CString -> IO (CInt)
189
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)
193   if (r == -1)
194     then do
195       err <- last_error h
196       fail err
197     else return ()
198
199 foreign import ccall unsafe "guestfs_add_drive_ro" c_add_drive_ro
200   :: GuestfsP -> CString -> IO (CInt)
201
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)
205   if (r == -1)
206     then do
207       err <- last_error h
208       fail err
209     else return ()
210
211 foreign import ccall unsafe "guestfs_config" c_config
212   :: GuestfsP -> CString -> CString -> IO (CInt)
213
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)
217   if (r == -1)
218     then do
219       err <- last_error h
220       fail err
221     else return ()
222
223 foreign import ccall unsafe "guestfs_set_qemu" c_set_qemu
224   :: GuestfsP -> CString -> IO (CInt)
225
226 set_qemu :: GuestfsH -> String -> IO ()
227 set_qemu h qemu = do
228   r <- withCString qemu $ \qemu -> withForeignPtr h (\p -> c_set_qemu p qemu)
229   if (r == -1)
230     then do
231       err <- last_error h
232       fail err
233     else return ()
234
235 foreign import ccall unsafe "guestfs_set_path" c_set_path
236   :: GuestfsP -> CString -> IO (CInt)
237
238 set_path :: GuestfsH -> String -> IO ()
239 set_path h path = do
240   r <- withCString path $ \path -> withForeignPtr h (\p -> c_set_path p path)
241   if (r == -1)
242     then do
243       err <- last_error h
244       fail err
245     else return ()
246
247 foreign import ccall unsafe "guestfs_set_append" c_set_append
248   :: GuestfsP -> CString -> IO (CInt)
249
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)
253   if (r == -1)
254     then do
255       err <- last_error h
256       fail err
257     else return ()
258
259 foreign import ccall unsafe "guestfs_set_busy" c_set_busy
260   :: GuestfsP -> IO (CInt)
261
262 set_busy :: GuestfsH -> IO ()
263 set_busy h = do
264   r <- withForeignPtr h (\p -> c_set_busy p)
265   if (r == -1)
266     then do
267       err <- last_error h
268       fail err
269     else return ()
270
271 foreign import ccall unsafe "guestfs_set_ready" c_set_ready
272   :: GuestfsP -> IO (CInt)
273
274 set_ready :: GuestfsH -> IO ()
275 set_ready h = do
276   r <- withForeignPtr h (\p -> c_set_ready p)
277   if (r == -1)
278     then do
279       err <- last_error h
280       fail err
281     else return ()
282
283 foreign import ccall unsafe "guestfs_end_busy" c_end_busy
284   :: GuestfsP -> IO (CInt)
285
286 end_busy :: GuestfsH -> IO ()
287 end_busy h = do
288   r <- withForeignPtr h (\p -> c_end_busy p)
289   if (r == -1)
290     then do
291       err <- last_error h
292       fail err
293     else return ()
294
295 foreign import ccall unsafe "guestfs_mount" c_mount
296   :: GuestfsP -> CString -> CString -> IO (CInt)
297
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)
301   if (r == -1)
302     then do
303       err <- last_error h
304       fail err
305     else return ()
306
307 foreign import ccall unsafe "guestfs_sync" c_sync
308   :: GuestfsP -> IO (CInt)
309
310 sync :: GuestfsH -> IO ()
311 sync h = do
312   r <- withForeignPtr h (\p -> c_sync p)
313   if (r == -1)
314     then do
315       err <- last_error h
316       fail err
317     else return ()
318
319 foreign import ccall unsafe "guestfs_touch" c_touch
320   :: GuestfsP -> CString -> IO (CInt)
321
322 touch :: GuestfsH -> String -> IO ()
323 touch h path = do
324   r <- withCString path $ \path -> withForeignPtr h (\p -> c_touch p path)
325   if (r == -1)
326     then do
327       err <- last_error h
328       fail err
329     else return ()
330
331 foreign import ccall unsafe "guestfs_aug_close" c_aug_close
332   :: GuestfsP -> IO (CInt)
333
334 aug_close :: GuestfsH -> IO ()
335 aug_close h = do
336   r <- withForeignPtr h (\p -> c_aug_close p)
337   if (r == -1)
338     then do
339       err <- last_error h
340       fail err
341     else return ()
342
343 foreign import ccall unsafe "guestfs_aug_set" c_aug_set
344   :: GuestfsP -> CString -> CString -> IO (CInt)
345
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)
349   if (r == -1)
350     then do
351       err <- last_error h
352       fail err
353     else return ()
354
355 foreign import ccall unsafe "guestfs_aug_mv" c_aug_mv
356   :: GuestfsP -> CString -> CString -> IO (CInt)
357
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)
361   if (r == -1)
362     then do
363       err <- last_error h
364       fail err
365     else return ()
366
367 foreign import ccall unsafe "guestfs_aug_save" c_aug_save
368   :: GuestfsP -> IO (CInt)
369
370 aug_save :: GuestfsH -> IO ()
371 aug_save h = do
372   r <- withForeignPtr h (\p -> c_aug_save p)
373   if (r == -1)
374     then do
375       err <- last_error h
376       fail err
377     else return ()
378
379 foreign import ccall unsafe "guestfs_aug_load" c_aug_load
380   :: GuestfsP -> IO (CInt)
381
382 aug_load :: GuestfsH -> IO ()
383 aug_load h = do
384   r <- withForeignPtr h (\p -> c_aug_load p)
385   if (r == -1)
386     then do
387       err <- last_error h
388       fail err
389     else return ()
390
391 foreign import ccall unsafe "guestfs_rm" c_rm
392   :: GuestfsP -> CString -> IO (CInt)
393
394 rm :: GuestfsH -> String -> IO ()
395 rm h path = do
396   r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm p path)
397   if (r == -1)
398     then do
399       err <- last_error h
400       fail err
401     else return ()
402
403 foreign import ccall unsafe "guestfs_rmdir" c_rmdir
404   :: GuestfsP -> CString -> IO (CInt)
405
406 rmdir :: GuestfsH -> String -> IO ()
407 rmdir h path = do
408   r <- withCString path $ \path -> withForeignPtr h (\p -> c_rmdir p path)
409   if (r == -1)
410     then do
411       err <- last_error h
412       fail err
413     else return ()
414
415 foreign import ccall unsafe "guestfs_rm_rf" c_rm_rf
416   :: GuestfsP -> CString -> IO (CInt)
417
418 rm_rf :: GuestfsH -> String -> IO ()
419 rm_rf h path = do
420   r <- withCString path $ \path -> withForeignPtr h (\p -> c_rm_rf p path)
421   if (r == -1)
422     then do
423       err <- last_error h
424       fail err
425     else return ()
426
427 foreign import ccall unsafe "guestfs_mkdir" c_mkdir
428   :: GuestfsP -> CString -> IO (CInt)
429
430 mkdir :: GuestfsH -> String -> IO ()
431 mkdir h path = do
432   r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir p path)
433   if (r == -1)
434     then do
435       err <- last_error h
436       fail err
437     else return ()
438
439 foreign import ccall unsafe "guestfs_mkdir_p" c_mkdir_p
440   :: GuestfsP -> CString -> IO (CInt)
441
442 mkdir_p :: GuestfsH -> String -> IO ()
443 mkdir_p h path = do
444   r <- withCString path $ \path -> withForeignPtr h (\p -> c_mkdir_p p path)
445   if (r == -1)
446     then do
447       err <- last_error h
448       fail err
449     else return ()
450
451 foreign import ccall unsafe "guestfs_pvcreate" c_pvcreate
452   :: GuestfsP -> CString -> IO (CInt)
453
454 pvcreate :: GuestfsH -> String -> IO ()
455 pvcreate h device = do
456   r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvcreate p device)
457   if (r == -1)
458     then do
459       err <- last_error h
460       fail err
461     else return ()
462
463 foreign import ccall unsafe "guestfs_vgcreate" c_vgcreate
464   :: GuestfsP -> CString -> Ptr CString -> IO (CInt)
465
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)
469   if (r == -1)
470     then do
471       err <- last_error h
472       fail err
473     else return ()
474
475 foreign import ccall unsafe "guestfs_mkfs" c_mkfs
476   :: GuestfsP -> CString -> CString -> IO (CInt)
477
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)
481   if (r == -1)
482     then do
483       err <- last_error h
484       fail err
485     else return ()
486
487 foreign import ccall unsafe "guestfs_umount" c_umount
488   :: GuestfsP -> CString -> IO (CInt)
489
490 umount :: GuestfsH -> String -> IO ()
491 umount h pathordevice = do
492   r <- withCString pathordevice $ \pathordevice -> withForeignPtr h (\p -> c_umount p pathordevice)
493   if (r == -1)
494     then do
495       err <- last_error h
496       fail err
497     else return ()
498
499 foreign import ccall unsafe "guestfs_umount_all" c_umount_all
500   :: GuestfsP -> IO (CInt)
501
502 umount_all :: GuestfsH -> IO ()
503 umount_all h = do
504   r <- withForeignPtr h (\p -> c_umount_all p)
505   if (r == -1)
506     then do
507       err <- last_error h
508       fail err
509     else return ()
510
511 foreign import ccall unsafe "guestfs_lvm_remove_all" c_lvm_remove_all
512   :: GuestfsP -> IO (CInt)
513
514 lvm_remove_all :: GuestfsH -> IO ()
515 lvm_remove_all h = do
516   r <- withForeignPtr h (\p -> c_lvm_remove_all p)
517   if (r == -1)
518     then do
519       err <- last_error h
520       fail err
521     else return ()
522
523 foreign import ccall unsafe "guestfs_blockdev_setro" c_blockdev_setro
524   :: GuestfsP -> CString -> IO (CInt)
525
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)
529   if (r == -1)
530     then do
531       err <- last_error h
532       fail err
533     else return ()
534
535 foreign import ccall unsafe "guestfs_blockdev_setrw" c_blockdev_setrw
536   :: GuestfsP -> CString -> IO (CInt)
537
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)
541   if (r == -1)
542     then do
543       err <- last_error h
544       fail err
545     else return ()
546
547 foreign import ccall unsafe "guestfs_blockdev_flushbufs" c_blockdev_flushbufs
548   :: GuestfsP -> CString -> IO (CInt)
549
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)
553   if (r == -1)
554     then do
555       err <- last_error h
556       fail err
557     else return ()
558
559 foreign import ccall unsafe "guestfs_blockdev_rereadpt" c_blockdev_rereadpt
560   :: GuestfsP -> CString -> IO (CInt)
561
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)
565   if (r == -1)
566     then do
567       err <- last_error h
568       fail err
569     else return ()
570
571 foreign import ccall unsafe "guestfs_upload" c_upload
572   :: GuestfsP -> CString -> CString -> IO (CInt)
573
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)
577   if (r == -1)
578     then do
579       err <- last_error h
580       fail err
581     else return ()
582
583 foreign import ccall unsafe "guestfs_download" c_download
584   :: GuestfsP -> CString -> CString -> IO (CInt)
585
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)
589   if (r == -1)
590     then do
591       err <- last_error h
592       fail err
593     else return ()
594
595 foreign import ccall unsafe "guestfs_tar_in" c_tar_in
596   :: GuestfsP -> CString -> CString -> IO (CInt)
597
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)
601   if (r == -1)
602     then do
603       err <- last_error h
604       fail err
605     else return ()
606
607 foreign import ccall unsafe "guestfs_tar_out" c_tar_out
608   :: GuestfsP -> CString -> CString -> IO (CInt)
609
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)
613   if (r == -1)
614     then do
615       err <- last_error h
616       fail err
617     else return ()
618
619 foreign import ccall unsafe "guestfs_tgz_in" c_tgz_in
620   :: GuestfsP -> CString -> CString -> IO (CInt)
621
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)
625   if (r == -1)
626     then do
627       err <- last_error h
628       fail err
629     else return ()
630
631 foreign import ccall unsafe "guestfs_tgz_out" c_tgz_out
632   :: GuestfsP -> CString -> CString -> IO (CInt)
633
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)
637   if (r == -1)
638     then do
639       err <- last_error h
640       fail err
641     else return ()
642
643 foreign import ccall unsafe "guestfs_mount_ro" c_mount_ro
644   :: GuestfsP -> CString -> CString -> IO (CInt)
645
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)
649   if (r == -1)
650     then do
651       err <- last_error h
652       fail err
653     else return ()
654
655 foreign import ccall unsafe "guestfs_mount_options" c_mount_options
656   :: GuestfsP -> CString -> CString -> CString -> IO (CInt)
657
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)
661   if (r == -1)
662     then do
663       err <- last_error h
664       fail err
665     else return ()
666
667 foreign import ccall unsafe "guestfs_mount_vfs" c_mount_vfs
668   :: GuestfsP -> CString -> CString -> CString -> CString -> IO (CInt)
669
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)
673   if (r == -1)
674     then do
675       err <- last_error h
676       fail err
677     else return ()
678
679 foreign import ccall unsafe "guestfs_lvremove" c_lvremove
680   :: GuestfsP -> CString -> IO (CInt)
681
682 lvremove :: GuestfsH -> String -> IO ()
683 lvremove h device = do
684   r <- withCString device $ \device -> withForeignPtr h (\p -> c_lvremove p device)
685   if (r == -1)
686     then do
687       err <- last_error h
688       fail err
689     else return ()
690
691 foreign import ccall unsafe "guestfs_vgremove" c_vgremove
692   :: GuestfsP -> CString -> IO (CInt)
693
694 vgremove :: GuestfsH -> String -> IO ()
695 vgremove h vgname = do
696   r <- withCString vgname $ \vgname -> withForeignPtr h (\p -> c_vgremove p vgname)
697   if (r == -1)
698     then do
699       err <- last_error h
700       fail err
701     else return ()
702
703 foreign import ccall unsafe "guestfs_pvremove" c_pvremove
704   :: GuestfsP -> CString -> IO (CInt)
705
706 pvremove :: GuestfsH -> String -> IO ()
707 pvremove h device = do
708   r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvremove p device)
709   if (r == -1)
710     then do
711       err <- last_error h
712       fail err
713     else return ()
714
715 foreign import ccall unsafe "guestfs_set_e2label" c_set_e2label
716   :: GuestfsP -> CString -> CString -> IO (CInt)
717
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)
721   if (r == -1)
722     then do
723       err <- last_error h
724       fail err
725     else return ()
726
727 foreign import ccall unsafe "guestfs_set_e2uuid" c_set_e2uuid
728   :: GuestfsP -> CString -> CString -> IO (CInt)
729
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)
733   if (r == -1)
734     then do
735       err <- last_error h
736       fail err
737     else return ()
738
739 foreign import ccall unsafe "guestfs_zero" c_zero
740   :: GuestfsP -> CString -> IO (CInt)
741
742 zero :: GuestfsH -> String -> IO ()
743 zero h device = do
744   r <- withCString device $ \device -> withForeignPtr h (\p -> c_zero p device)
745   if (r == -1)
746     then do
747       err <- last_error h
748       fail err
749     else return ()
750
751 foreign import ccall unsafe "guestfs_grub_install" c_grub_install
752   :: GuestfsP -> CString -> CString -> IO (CInt)
753
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)
757   if (r == -1)
758     then do
759       err <- last_error h
760       fail err
761     else return ()
762
763 foreign import ccall unsafe "guestfs_cp" c_cp
764   :: GuestfsP -> CString -> CString -> IO (CInt)
765
766 cp :: GuestfsH -> String -> String -> IO ()
767 cp h src dest = do
768   r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp p src dest)
769   if (r == -1)
770     then do
771       err <- last_error h
772       fail err
773     else return ()
774
775 foreign import ccall unsafe "guestfs_cp_a" c_cp_a
776   :: GuestfsP -> CString -> CString -> IO (CInt)
777
778 cp_a :: GuestfsH -> String -> String -> IO ()
779 cp_a h src dest = do
780   r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_cp_a p src dest)
781   if (r == -1)
782     then do
783       err <- last_error h
784       fail err
785     else return ()
786
787 foreign import ccall unsafe "guestfs_mv" c_mv
788   :: GuestfsP -> CString -> CString -> IO (CInt)
789
790 mv :: GuestfsH -> String -> String -> IO ()
791 mv h src dest = do
792   r <- withCString src $ \src -> withCString dest $ \dest -> withForeignPtr h (\p -> c_mv p src dest)
793   if (r == -1)
794     then do
795       err <- last_error h
796       fail err
797     else return ()
798
799 foreign import ccall unsafe "guestfs_ping_daemon" c_ping_daemon
800   :: GuestfsP -> IO (CInt)
801
802 ping_daemon :: GuestfsH -> IO ()
803 ping_daemon h = do
804   r <- withForeignPtr h (\p -> c_ping_daemon p)
805   if (r == -1)
806     then do
807       err <- last_error h
808       fail err
809     else return ()
810
811 foreign import ccall unsafe "guestfs_zerofree" c_zerofree
812   :: GuestfsP -> CString -> IO (CInt)
813
814 zerofree :: GuestfsH -> String -> IO ()
815 zerofree h device = do
816   r <- withCString device $ \device -> withForeignPtr h (\p -> c_zerofree p device)
817   if (r == -1)
818     then do
819       err <- last_error h
820       fail err
821     else return ()
822
823 foreign import ccall unsafe "guestfs_pvresize" c_pvresize
824   :: GuestfsP -> CString -> IO (CInt)
825
826 pvresize :: GuestfsH -> String -> IO ()
827 pvresize h device = do
828   r <- withCString device $ \device -> withForeignPtr h (\p -> c_pvresize p device)
829   if (r == -1)
830     then do
831       err <- last_error h
832       fail err
833     else return ()
834
835 foreign import ccall unsafe "guestfs_resize2fs" c_resize2fs
836   :: GuestfsP -> CString -> IO (CInt)
837
838 resize2fs :: GuestfsH -> String -> IO ()
839 resize2fs h device = do
840   r <- withCString device $ \device -> withForeignPtr h (\p -> c_resize2fs p device)
841   if (r == -1)
842     then do
843       err <- last_error h
844       fail err
845     else return ()
846
847 foreign import ccall unsafe "guestfs_e2fsck_f" c_e2fsck_f
848   :: GuestfsP -> CString -> IO (CInt)
849
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)
853   if (r == -1)
854     then do
855       err <- last_error h
856       fail err
857     else return ()
858
859 foreign import ccall unsafe "guestfs_scrub_device" c_scrub_device
860   :: GuestfsP -> CString -> IO (CInt)
861
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)
865   if (r == -1)
866     then do
867       err <- last_error h
868       fail err
869     else return ()
870
871 foreign import ccall unsafe "guestfs_scrub_file" c_scrub_file
872   :: GuestfsP -> CString -> IO (CInt)
873
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)
877   if (r == -1)
878     then do
879       err <- last_error h
880       fail err
881     else return ()
882
883 foreign import ccall unsafe "guestfs_scrub_freespace" c_scrub_freespace
884   :: GuestfsP -> CString -> IO (CInt)
885
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)
889   if (r == -1)
890     then do
891       err <- last_error h
892       fail err
893     else return ()
894