X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=haskell%2FGuestfs.hs;h=3148450dd54fed8f0830742a810306690922418d;hb=f850e1f065fb04df7cc87a921ab3c658741cc393;hp=94152d2531010c4da760274c84fd34d146e7b70d;hpb=ef2b0cf761b6281a6a728aacb6ac0ec91fad33c8;p=libguestfs.git diff --git a/haskell/Guestfs.hs b/haskell/Guestfs.hs index 94152d2..3148450 100644 --- a/haskell/Guestfs.hs +++ b/haskell/Guestfs.hs @@ -45,6 +45,8 @@ module Guestfs ( set_busy, set_ready, end_busy, + set_memsize, + get_memsize, mount, sync, touch, @@ -116,7 +118,15 @@ module Guestfs ( ntfs_3g_probe, scrub_device, scrub_file, - scrub_freespace + scrub_freespace, + wc_l, + wc_w, + wc_c, + du, + mount_loop, + mkswap, + mkswap_L, + mkswap_U ) where import Foreign import Foreign.C @@ -419,6 +429,30 @@ end_busy h = do fail err else return () +foreign import ccall unsafe "guestfs_set_memsize" c_set_memsize + :: GuestfsP -> CInt -> IO (CInt) + +set_memsize :: GuestfsH -> Int -> IO () +set_memsize h memsize = do + r <- withForeignPtr h (\p -> c_set_memsize p (fromIntegral memsize)) + if (r == -1) + then do + err <- last_error h + fail err + else return () + +foreign import ccall unsafe "guestfs_get_memsize" c_get_memsize + :: GuestfsP -> IO (CInt) + +get_memsize :: GuestfsH -> IO (Int) +get_memsize h = do + r <- withForeignPtr h (\p -> c_get_memsize p) + if (r == -1) + then do + err <- last_error h + fail err + else return (fromIntegral r) + foreign import ccall unsafe "guestfs_mount" c_mount :: GuestfsP -> CString -> CString -> IO (CInt) @@ -1155,8 +1189,8 @@ 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) +sfdisk_N h device partnum cyls heads sectors line = do + r <- withCString device $ \device -> withCString line $ \line -> withForeignPtr h (\p -> c_sfdisk_N p device (fromIntegral partnum) (fromIntegral cyls) (fromIntegral heads) (fromIntegral sectors) line) if (r == -1) then do err <- last_error h @@ -1283,3 +1317,99 @@ scrub_freespace h dir = do fail err else return () +foreign import ccall unsafe "guestfs_wc_l" c_wc_l + :: GuestfsP -> CString -> IO (CInt) + +wc_l :: GuestfsH -> String -> IO (Int) +wc_l h path = do + r <- withCString path $ \path -> withForeignPtr h (\p -> c_wc_l p path) + if (r == -1) + then do + err <- last_error h + fail err + else return (fromIntegral r) + +foreign import ccall unsafe "guestfs_wc_w" c_wc_w + :: GuestfsP -> CString -> IO (CInt) + +wc_w :: GuestfsH -> String -> IO (Int) +wc_w h path = do + r <- withCString path $ \path -> withForeignPtr h (\p -> c_wc_w p path) + if (r == -1) + then do + err <- last_error h + fail err + else return (fromIntegral r) + +foreign import ccall unsafe "guestfs_wc_c" c_wc_c + :: GuestfsP -> CString -> IO (CInt) + +wc_c :: GuestfsH -> String -> IO (Int) +wc_c h path = do + r <- withCString path $ \path -> withForeignPtr h (\p -> c_wc_c p path) + if (r == -1) + then do + err <- last_error h + fail err + else return (fromIntegral r) + +foreign import ccall unsafe "guestfs_du" c_du + :: GuestfsP -> CString -> IO (Int64) + +du :: GuestfsH -> String -> IO (Integer) +du h path = do + r <- withCString path $ \path -> withForeignPtr h (\p -> c_du p path) + if (r == -1) + then do + err <- last_error h + fail err + else return (fromIntegral r) + +foreign import ccall unsafe "guestfs_mount_loop" c_mount_loop + :: GuestfsP -> CString -> CString -> IO (CInt) + +mount_loop :: GuestfsH -> String -> String -> IO () +mount_loop h file mountpoint = do + r <- withCString file $ \file -> withCString mountpoint $ \mountpoint -> withForeignPtr h (\p -> c_mount_loop p file mountpoint) + if (r == -1) + then do + err <- last_error h + fail err + else return () + +foreign import ccall unsafe "guestfs_mkswap" c_mkswap + :: GuestfsP -> CString -> IO (CInt) + +mkswap :: GuestfsH -> String -> IO () +mkswap h device = do + r <- withCString device $ \device -> withForeignPtr h (\p -> c_mkswap p device) + if (r == -1) + then do + err <- last_error h + fail err + else return () + +foreign import ccall unsafe "guestfs_mkswap_L" c_mkswap_L + :: GuestfsP -> CString -> CString -> IO (CInt) + +mkswap_L :: GuestfsH -> String -> String -> IO () +mkswap_L h label device = do + r <- withCString label $ \label -> withCString device $ \device -> withForeignPtr h (\p -> c_mkswap_L p label device) + if (r == -1) + then do + err <- last_error h + fail err + else return () + +foreign import ccall unsafe "guestfs_mkswap_U" c_mkswap_U + :: GuestfsP -> CString -> CString -> IO (CInt) + +mkswap_U :: GuestfsH -> String -> String -> IO () +mkswap_U h uuid device = do + r <- withCString uuid $ \uuid -> withCString device $ \device -> withForeignPtr h (\p -> c_mkswap_U p uuid device) + if (r == -1) + then do + err <- last_error h + fail err + else return () +