halfs-0.2: Halfs/TheInodeMap.hs
-- |Basically hidden under the FSRoot module (also used by SyncStructures)
module Halfs.TheInodeMap (TheInodeMap(..), emptyInodeMap,
freeInode) where
import Data.Integral(INInt)
-- |Keeps track of freed inodes so we can reuse their space.
data TheInodeMap = TheInodeMap {
freeInodes :: [INInt] -- Inode Numbers
,imDirty :: Bool
,imMaxNum :: INInt
}
emptyInodeMap :: INInt -- first free inode number
-> TheInodeMap
emptyInodeMap n = TheInodeMap [] True n
-- |Add this inode to the free list.
freeInode :: TheInodeMap -> INInt -> TheInodeMap
freeInode im@TheInodeMap{freeInodes=l} i
= im{freeInodes=i:l, imDirty=True}