summaryrefslogtreecommitdiffstats
path: root/src/util/mmap_cache.h
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2012-12-20 04:10:25 +0000
committerJakub Hrozek <jhrozek@redhat.com>2012-12-20 19:59:54 +0100
commit70d56634069fc0f044899e3933f4e61bccefd2c3 (patch)
treeead3f05bd36e1375006f8d242e8a93a5bd2d978c /src/util/mmap_cache.h
parent884c92c83c3d4cdde5cff74fa19f710429532b81 (diff)
downloadsssd-70d56634069fc0f044899e3933f4e61bccefd2c3.tar.gz
sssd-70d56634069fc0f044899e3933f4e61bccefd2c3.tar.xz
sssd-70d56634069fc0f044899e3933f4e61bccefd2c3.zip
Carefully check records when forcibly invalidating
We should never try to invalidate an already invalid record as internal pointers will not be consistent. Carefully test that the record really is valid when we are fishing for free space, and properly invalidate records or return a fatal error if something goes wrong. In order to make the code more robust always invalidate the whole data space on initialization by setting all bits to 1, and make sure to invalidate the whole last allocated slot by converting rec->len to the number of slots instead of just the space used.
Diffstat (limited to 'src/util/mmap_cache.h')
-rw-r--r--src/util/mmap_cache.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/util/mmap_cache.h b/src/util/mmap_cache.h
index b3dac6ee2..407eeea69 100644
--- a/src/util/mmap_cache.h
+++ b/src/util/mmap_cache.h
@@ -47,8 +47,10 @@ typedef uint32_t rel_ptr_t;
#define MC_PTR_ADD(ptr, bytes) (void *)((uint8_t *)(ptr) + (bytes))
#define MC_PTR_DIFF(ptr, base) ((uint8_t *)(ptr) - (uint8_t *)(base))
-#define MC_INVALID_PTR (void *)0xffffffff
-#define MC_INVALID_VAL 0xffffffff
+#define MC_INVALID_VAL64 ((uint64_t)-1)
+#define MC_INVALID_VAL32 ((uint32_t)-1)
+#define MC_INVALID_VAL8 ((uint8_t)-1)
+#define MC_INVALID_VAL MC_INVALID_VAL32
/*
* 32 seem a good compromise for slot size