more readme, some renaming
This commit is contained in:
parent
4ce12b1472
commit
59d9e9c084
23
README
23
README
|
|
@ -1 +1,24 @@
|
|||
noisebox -- a FUSE filesystem that contains predictable PRNG output.
|
||||
|
||||
|
||||
Requirements
|
||||
---
|
||||
|
||||
Pretty light. Tested to compile on Fedora and Ubuntu. Requires a
|
||||
compiler and associated toolchain.
|
||||
|
||||
Required packages:
|
||||
|
||||
* libfuse-devel
|
||||
|
||||
Required non-packages (as of this writing):
|
||||
|
||||
* pcg-c [https://github.com/imneme/pcg-c]
|
||||
|
||||
|
||||
TODO
|
||||
---
|
||||
|
||||
* Add some unit tests.
|
||||
* Fix mersenne output.
|
||||
* Profile memory usage. I suspect there are leaks.
|
||||
|
|
|
|||
10
fuse.c
10
fuse.c
|
|
@ -196,10 +196,12 @@ static int do_open(const char* path, struct fuse_file_info* fi) {
|
|||
}
|
||||
|
||||
// check if file is already opened.
|
||||
get_file_state(path, fi);
|
||||
if(fi->fh) {
|
||||
return 0;
|
||||
}
|
||||
// never mind, we want to support multiple concurrent reads from
|
||||
// the same file.
|
||||
// get_file_state(path, fi);
|
||||
// if(fi->fh) {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
if(n->do_open) {
|
||||
ret = n->do_open(path, fi);
|
||||
|
|
|
|||
12
mersenne.c
12
mersenne.c
|
|
@ -34,17 +34,17 @@ enum {
|
|||
|
||||
|
||||
// state for single generator.
|
||||
struct mt_state {
|
||||
typedef struct mt_random_t {
|
||||
uint32_t mt[N];
|
||||
int index;
|
||||
off_t begin;
|
||||
size_t consumed;
|
||||
char overflow[4];
|
||||
int overflow_len;
|
||||
};
|
||||
} mt_random_t;
|
||||
|
||||
|
||||
static void twist(struct mt_state *state) {
|
||||
static void twist(mt_random_t *state) {
|
||||
uint32_t i, x, xA;
|
||||
uint32_t *mt = state->mt;
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ static void twist(struct mt_state *state) {
|
|||
state->index = 0;
|
||||
}
|
||||
|
||||
static void mt_init(struct mt_state *state, const uint32_t seed) {
|
||||
static void mt_init(mt_random_t *state, const uint32_t seed) {
|
||||
uint32_t i;
|
||||
uint32_t *mt = state->mt;
|
||||
mt[0] = seed;
|
||||
|
|
@ -72,7 +72,7 @@ static void mt_init(struct mt_state *state, const uint32_t seed) {
|
|||
twist(state);
|
||||
}
|
||||
|
||||
static uint32_t extract_u32(struct mt_state *state) {
|
||||
static uint32_t extract_u32(mt_random_t *state) {
|
||||
uint32_t y;
|
||||
|
||||
if(state->index >= N) {
|
||||
|
|
@ -111,7 +111,7 @@ static int get_noise(size_t n, off_t offset, char* buf,
|
|||
printf("getting random bits: %i@%i (%i)\n", n, offset, n*sizeof(char));
|
||||
|
||||
// FIXME this is wrong.
|
||||
struct mt_state *state = (struct mt_state *)(fi->fh);
|
||||
mt_random_t *state = (mt_random_t *)(fi->fh);
|
||||
float buf_ratio = (float)sizeof(char)/(float)sizeof(uint32_t);
|
||||
if(offset != state->consumed * buf_ratio) {
|
||||
printf("wrong offset, discarding state\n");
|
||||
|
|
|
|||
Loading…
Reference in New Issue