add a configure check for StatFS

This way, the build log will indicate whether StatFS can be relied on.
I've tested all the failing architectures now, and on all of them,
the StatFS code now returns Nothing, rather than Just nonsense.

Also, if annex.diskreserve is set on a platform where StatFS is not
working, git-annex will complain.

Also, the Makefile was missing the sources target used when building with
cabal.
This commit is contained in:
Joey Hess 2012-01-15 13:26:17 -04:00
parent 0eed604446
commit 81856c3175
5 changed files with 28 additions and 4 deletions

View file

@ -177,6 +177,7 @@ checkDiskSpace' adjustment key = do
r <- getConfig g "diskreserve" "" r <- getConfig g "diskreserve" ""
let reserve = fromMaybe megabyte $ readSize dataUnits r let reserve = fromMaybe megabyte $ readSize dataUnits r
stats <- liftIO $ getFileSystemStats (gitAnnexDir g) stats <- liftIO $ getFileSystemStats (gitAnnexDir g)
sanitycheck r stats
case (stats, keySize key) of case (stats, keySize key) of
(Nothing, _) -> return () (Nothing, _) -> return ()
(_, Nothing) -> return () (_, Nothing) -> return ()
@ -189,7 +190,17 @@ checkDiskSpace' adjustment key = do
needmorespace n = unlessM (Annex.getState Annex.force) $ needmorespace n = unlessM (Annex.getState Annex.force) $
error $ "not enough free space, need " ++ error $ "not enough free space, need " ++
roughSize storageUnits True n ++ roughSize storageUnits True n ++
" more (use --force to override this check or adjust annex.diskreserve)" " more" ++ forcemsg
forcemsg = " (use --force to override this check or adjust annex.diskreserve)"
sanitycheck r stats
| not (null r) && isNothing stats = do
unlessM (Annex.getState Annex.force) $
error $ "You have configured a diskreserve of "
++ r ++
" but disk space checking is not working"
++ forcemsg
return ()
| otherwise = return ()
{- Moves a file into .git/annex/objects/ {- Moves a file into .git/annex/objects/
- -

View file

@ -21,11 +21,13 @@ endif
all: $(all) all: $(all)
sources: $(sources)
# Disables optimisation. Not for production use. # Disables optimisation. Not for production use.
fast: GHCFLAGS=-Wall $(IGNORE) fast: GHCFLAGS=-Wall $(IGNORE)
fast: $(bins) fast: $(bins)
Build/SysConfig.hs: configure.hs Build/TestConfig.hs Build/SysConfig.hs: configure.hs Build/TestConfig.hs Utility/StatFS.hs
$(GHCMAKE) configure $(GHCMAKE) configure
./configure ./configure

View file

@ -2,9 +2,11 @@
import System.Directory import System.Directory
import Data.List import Data.List
import Data.Maybe
import System.Cmd.Utils import System.Cmd.Utils
import Build.TestConfig import Build.TestConfig
import Utility.StatFS
tests :: [TestCase] tests :: [TestCase]
tests = tests =
@ -21,6 +23,7 @@ tests =
, TestCase "wget" $ testCmd "wget" "wget --version >/dev/null" , TestCase "wget" $ testCmd "wget" "wget --version >/dev/null"
, TestCase "bup" $ testCmd "bup" "bup --version >/dev/null" , TestCase "bup" $ testCmd "bup" "bup --version >/dev/null"
, TestCase "gpg" $ testCmd "gpg" "gpg --version >/dev/null" , TestCase "gpg" $ testCmd "gpg" "gpg --version >/dev/null"
, TestCase "StatFS" testStatFS
] ++ shaTestCases [1, 256, 512, 224, 384] ] ++ shaTestCases [1, 256, 512, 224, 384]
shaTestCases :: [Int] -> [TestCase] shaTestCases :: [Int] -> [TestCase]
@ -63,6 +66,11 @@ getGitVersion = do
let version = last $ words $ head $ lines s let version = last $ words $ head $ lines s
return $ Config "gitversion" (StringConfig version) return $ Config "gitversion" (StringConfig version)
testStatFS :: Test
testStatFS = do
s <- getFileSystemStats "."
return $ Config "statfs_sane" $ BoolConfig $ isJust s
{- Set up cabal file with version. -} {- Set up cabal file with version. -}
cabalSetup :: IO () cabalSetup :: IO ()
cabalSetup = do cabalSetup = do

5
debian/changelog vendored
View file

@ -1,6 +1,9 @@
git-annex (3.20120114) UNRELEASED; urgency=low git-annex (3.20120114) UNRELEASED; urgency=low
* Add a sanity check for bad StatFS results. * Add a sanity check for bad StatFS results. On architectures
where StatFS does not currently work (s390, mips, powerpc, sparc),
this disables the diskreserve checking code, and attempting to
configure an annex.diskreserve will result in an error.
-- Joey Hess <joeyh@debian.org> Sat, 14 Jan 2012 17:12:04 -0400 -- Joey Hess <joeyh@debian.org> Sat, 14 Jan 2012 17:12:04 -0400

View file

@ -1,5 +1,5 @@
Name: git-annex Name: git-annex
Version: 3.20120113 Version: 3.20120114
Cabal-Version: >= 1.6 Cabal-Version: >= 1.6
License: GPL License: GPL
Maintainer: Joey Hess <joey@kitenet.net> Maintainer: Joey Hess <joey@kitenet.net>