Do pi lookup on read and write.
This commit is contained in:
parent
448f0db84f
commit
f177862384
12
src/pifs.c
12
src/pifs.c
|
@ -2,6 +2,7 @@
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -11,6 +12,8 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <fuse/fuse.h>
|
#include <fuse/fuse.h>
|
||||||
|
|
||||||
|
unsigned char get_byte(int id);
|
||||||
|
|
||||||
struct options {
|
struct options {
|
||||||
char *mdd;
|
char *mdd;
|
||||||
} options;
|
} options;
|
||||||
|
@ -149,7 +152,7 @@ static int pifs_read(const char *path, char *buf, size_t count, off_t offset,
|
||||||
} else if (ret == 0) {
|
} else if (ret == 0) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
*buf = (char) index;
|
*buf = (char) get_byte(index);
|
||||||
buf++;
|
buf++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +168,12 @@ static int pifs_write(const char *path, const char *buf, size_t count,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (size_t i = 0; i < count; i++) {
|
||||||
short index = (short) *buf;
|
short index;
|
||||||
|
for (index = 0; index < SHRT_MAX; index++) {
|
||||||
|
if (get_byte(index) == *buf) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
ret = write(info->fh, &index, sizeof index);
|
ret = write(info->fh, &index, sizeof index);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
Loading…
Reference in New Issue