module Guestfs (
create,
+ test0,
launch,
wait_ready,
kill_subprocess,
set_qemu,
set_path,
set_append,
+ set_autosync,
+ set_verbose,
set_busy,
set_ready,
end_busy,
mount,
sync,
touch,
+ aug_init,
aug_close,
aug_set,
+ aug_insert,
aug_mv,
aug_save,
aug_load,
rm_rf,
mkdir,
mkdir_p,
+ chmod,
+ chown,
pvcreate,
vgcreate,
+ lvcreate,
mkfs,
+ sfdisk,
+ write_file,
umount,
umount_all,
lvm_remove_all,
blockdev_setro,
blockdev_setrw,
+ blockdev_setbsz,
blockdev_flushbufs,
blockdev_rereadpt,
upload,
cp,
cp_a,
mv,
+ drop_caches,
ping_daemon,
zerofree,
pvresize,
+ sfdisk_N,
+ vg_activate_all,
+ vg_activate,
+ lvresize,
resize2fs,
e2fsck_f,
+ sleep,
scrub_device,
scrub_file,
scrub_freespace
) where
import Foreign
import Foreign.C
+import Foreign.C.Types
import IO
import Control.Exception
import Data.Typeable
then return "no error"
else peekCString str
+foreign import ccall unsafe "guestfs_test0" c_test0
+ :: GuestfsP -> CString -> CString -> Ptr CString -> CInt -> CInt -> CString -> CString -> IO (CInt)
+
+test0 :: GuestfsH -> String -> Maybe String -> [String] -> Bool -> Int -> String -> String -> IO ()
+test0 h str optstr strlist b integer filein fileout = do
+ r <- withCString str $ \str -> maybeWith withCString optstr $ \optstr -> withMany withCString strlist $ \strlist -> withArray0 nullPtr strlist $ \strlist -> withCString filein $ \filein -> withCString fileout $ \fileout -> withForeignPtr h (\p -> c_test0 p str optstr strlist (fromBool b) (fromIntegral integer) filein fileout)
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
foreign import ccall unsafe "guestfs_launch" c_launch
:: GuestfsP -> IO (CInt)
fail err
else return ()
+foreign import ccall unsafe "guestfs_set_autosync" c_set_autosync
+ :: GuestfsP -> CInt -> IO (CInt)
+
+set_autosync :: GuestfsH -> Bool -> IO ()
+set_autosync h autosync = do
+ r <- withForeignPtr h (\p -> c_set_autosync p (fromBool autosync))
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
+foreign import ccall unsafe "guestfs_set_verbose" c_set_verbose
+ :: GuestfsP -> CInt -> IO (CInt)
+
+set_verbose :: GuestfsH -> Bool -> IO ()
+set_verbose h verbose = do
+ r <- withForeignPtr h (\p -> c_set_verbose p (fromBool verbose))
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
foreign import ccall unsafe "guestfs_set_busy" c_set_busy
:: GuestfsP -> IO (CInt)
fail err
else return ()
+foreign import ccall unsafe "guestfs_aug_init" c_aug_init
+ :: GuestfsP -> CString -> CInt -> IO (CInt)
+
+aug_init :: GuestfsH -> String -> Int -> IO ()
+aug_init h root flags = do
+ r <- withCString root $ \root -> withForeignPtr h (\p -> c_aug_init p root (fromIntegral flags))
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
foreign import ccall unsafe "guestfs_aug_close" c_aug_close
:: GuestfsP -> IO (CInt)
fail err
else return ()
+foreign import ccall unsafe "guestfs_aug_insert" c_aug_insert
+ :: GuestfsP -> CString -> CString -> CInt -> IO (CInt)
+
+aug_insert :: GuestfsH -> String -> String -> Bool -> IO ()
+aug_insert h path label before = do
+ r <- withCString path $ \path -> withCString label $ \label -> withForeignPtr h (\p -> c_aug_insert p path label (fromBool before))
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
foreign import ccall unsafe "guestfs_aug_mv" c_aug_mv
:: GuestfsP -> CString -> CString -> IO (CInt)
fail err
else return ()
+foreign import ccall unsafe "guestfs_chmod" c_chmod
+ :: GuestfsP -> CInt -> CString -> IO (CInt)
+
+chmod :: GuestfsH -> Int -> String -> IO ()
+chmod h mode path = do
+ r <- withCString path $ \path -> withForeignPtr h (\p -> c_chmod p (fromIntegral mode) path)
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
+foreign import ccall unsafe "guestfs_chown" c_chown
+ :: GuestfsP -> CInt -> CInt -> CString -> IO (CInt)
+
+chown :: GuestfsH -> Int -> Int -> String -> IO ()
+chown h owner group path = do
+ r <- withCString path $ \path -> withForeignPtr h (\p -> c_chown p (fromIntegral owner) (fromIntegral group) path)
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
foreign import ccall unsafe "guestfs_pvcreate" c_pvcreate
:: GuestfsP -> CString -> IO (CInt)
fail err
else return ()
+foreign import ccall unsafe "guestfs_lvcreate" c_lvcreate
+ :: GuestfsP -> CString -> CString -> CInt -> IO (CInt)
+
+lvcreate :: GuestfsH -> String -> String -> Int -> IO ()
+lvcreate h logvol volgroup mbytes = do
+ r <- withCString logvol $ \logvol -> withCString volgroup $ \volgroup -> withForeignPtr h (\p -> c_lvcreate p logvol volgroup (fromIntegral mbytes))
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
foreign import ccall unsafe "guestfs_mkfs" c_mkfs
:: GuestfsP -> CString -> CString -> IO (CInt)
fail err
else return ()
+foreign import ccall unsafe "guestfs_sfdisk" c_sfdisk
+ :: GuestfsP -> CString -> CInt -> CInt -> CInt -> Ptr CString -> IO (CInt)
+
+sfdisk :: GuestfsH -> String -> Int -> Int -> Int -> [String] -> IO ()
+sfdisk h device cyls heads sectors lines = do
+ r <- withCString device $ \device -> withMany withCString lines $ \lines -> withArray0 nullPtr lines $ \lines -> withForeignPtr h (\p -> c_sfdisk p device (fromIntegral cyls) (fromIntegral heads) (fromIntegral sectors) lines)
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
+foreign import ccall unsafe "guestfs_write_file" c_write_file
+ :: GuestfsP -> CString -> CString -> CInt -> IO (CInt)
+
+write_file :: GuestfsH -> String -> String -> Int -> IO ()
+write_file h path content size = do
+ r <- withCString path $ \path -> withCString content $ \content -> withForeignPtr h (\p -> c_write_file p path content (fromIntegral size))
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
foreign import ccall unsafe "guestfs_umount" c_umount
:: GuestfsP -> CString -> IO (CInt)
fail err
else return ()
+foreign import ccall unsafe "guestfs_blockdev_setbsz" c_blockdev_setbsz
+ :: GuestfsP -> CString -> CInt -> IO (CInt)
+
+blockdev_setbsz :: GuestfsH -> String -> Int -> IO ()
+blockdev_setbsz h device blocksize = do
+ r <- withCString device $ \device -> withForeignPtr h (\p -> c_blockdev_setbsz p device (fromIntegral blocksize))
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
foreign import ccall unsafe "guestfs_blockdev_flushbufs" c_blockdev_flushbufs
:: GuestfsP -> CString -> IO (CInt)
fail err
else return ()
+foreign import ccall unsafe "guestfs_drop_caches" c_drop_caches
+ :: GuestfsP -> CInt -> IO (CInt)
+
+drop_caches :: GuestfsH -> Int -> IO ()
+drop_caches h whattodrop = do
+ r <- withForeignPtr h (\p -> c_drop_caches p (fromIntegral whattodrop))
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
foreign import ccall unsafe "guestfs_ping_daemon" c_ping_daemon
:: GuestfsP -> IO (CInt)
fail err
else return ()
+foreign import ccall unsafe "guestfs_sfdisk_N" c_sfdisk_N
+ :: GuestfsP -> CString -> CInt -> CInt -> CInt -> CInt -> CString -> IO (CInt)
+
+sfdisk_N :: GuestfsH -> String -> Int -> Int -> Int -> Int -> String -> IO ()
+sfdisk_N h device n cyls heads sectors line = do
+ r <- withCString device $ \device -> withCString line $ \line -> withForeignPtr h (\p -> c_sfdisk_N p device (fromIntegral n) (fromIntegral cyls) (fromIntegral heads) (fromIntegral sectors) line)
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
+foreign import ccall unsafe "guestfs_vg_activate_all" c_vg_activate_all
+ :: GuestfsP -> CInt -> IO (CInt)
+
+vg_activate_all :: GuestfsH -> Bool -> IO ()
+vg_activate_all h activate = do
+ r <- withForeignPtr h (\p -> c_vg_activate_all p (fromBool activate))
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
+foreign import ccall unsafe "guestfs_vg_activate" c_vg_activate
+ :: GuestfsP -> CInt -> Ptr CString -> IO (CInt)
+
+vg_activate :: GuestfsH -> Bool -> [String] -> IO ()
+vg_activate h activate volgroups = do
+ r <- withMany withCString volgroups $ \volgroups -> withArray0 nullPtr volgroups $ \volgroups -> withForeignPtr h (\p -> c_vg_activate p (fromBool activate) volgroups)
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
+foreign import ccall unsafe "guestfs_lvresize" c_lvresize
+ :: GuestfsP -> CString -> CInt -> IO (CInt)
+
+lvresize :: GuestfsH -> String -> Int -> IO ()
+lvresize h device mbytes = do
+ r <- withCString device $ \device -> withForeignPtr h (\p -> c_lvresize p device (fromIntegral mbytes))
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
foreign import ccall unsafe "guestfs_resize2fs" c_resize2fs
:: GuestfsP -> CString -> IO (CInt)
fail err
else return ()
+foreign import ccall unsafe "guestfs_sleep" c_sleep
+ :: GuestfsP -> CInt -> IO (CInt)
+
+sleep :: GuestfsH -> Int -> IO ()
+sleep h secs = do
+ r <- withForeignPtr h (\p -> c_sleep p (fromIntegral secs))
+ if (r == -1)
+ then do
+ err <- last_error h
+ fail err
+ else return ()
+
foreign import ccall unsafe "guestfs_scrub_device" c_scrub_device
:: GuestfsP -> CString -> IO (CInt)