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.
|
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.
|
// check if file is already opened.
|
||||||
get_file_state(path, fi);
|
// never mind, we want to support multiple concurrent reads from
|
||||||
if(fi->fh) {
|
// the same file.
|
||||||
return 0;
|
// get_file_state(path, fi);
|
||||||
}
|
// if(fi->fh) {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
|
||||||
if(n->do_open) {
|
if(n->do_open) {
|
||||||
ret = n->do_open(path, fi);
|
ret = n->do_open(path, fi);
|
||||||
|
|
|
||||||
12
mersenne.c
12
mersenne.c
|
|
@ -34,17 +34,17 @@ enum {
|
||||||
|
|
||||||
|
|
||||||
// state for single generator.
|
// state for single generator.
|
||||||
struct mt_state {
|
typedef struct mt_random_t {
|
||||||
uint32_t mt[N];
|
uint32_t mt[N];
|
||||||
int index;
|
int index;
|
||||||
off_t begin;
|
off_t begin;
|
||||||
size_t consumed;
|
size_t consumed;
|
||||||
char overflow[4];
|
char overflow[4];
|
||||||
int overflow_len;
|
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 i, x, xA;
|
||||||
uint32_t *mt = state->mt;
|
uint32_t *mt = state->mt;
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ static void twist(struct mt_state *state) {
|
||||||
state->index = 0;
|
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 i;
|
||||||
uint32_t *mt = state->mt;
|
uint32_t *mt = state->mt;
|
||||||
mt[0] = seed;
|
mt[0] = seed;
|
||||||
|
|
@ -72,7 +72,7 @@ static void mt_init(struct mt_state *state, const uint32_t seed) {
|
||||||
twist(state);
|
twist(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t extract_u32(struct mt_state *state) {
|
static uint32_t extract_u32(mt_random_t *state) {
|
||||||
uint32_t y;
|
uint32_t y;
|
||||||
|
|
||||||
if(state->index >= N) {
|
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));
|
printf("getting random bits: %i@%i (%i)\n", n, offset, n*sizeof(char));
|
||||||
|
|
||||||
// FIXME this is wrong.
|
// 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);
|
float buf_ratio = (float)sizeof(char)/(float)sizeof(uint32_t);
|
||||||
if(offset != state->consumed * buf_ratio) {
|
if(offset != state->consumed * buf_ratio) {
|
||||||
printf("wrong offset, discarding state\n");
|
printf("wrong offset, discarding state\n");
|
||||||
|
|
|
||||||
2
pcg.c
2
pcg.c
|
|
@ -39,7 +39,7 @@ static int do_open(const char *path, struct fuse_file_info *fi) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_release(const char *path, struct fuse_file_info *fi) {
|
static int do_release(const char *path, struct fuse_file_info *fi) {
|
||||||
free((void *)fi->fh);
|
free((void *)(fi->fh));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue