git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
allow specifiying access mode when creating twifs file node
[lunaix-os.git]
/
lunaix-os
/
kernel
/
fs
/
twimap.c
diff --git
a/lunaix-os/kernel/fs/twimap.c
b/lunaix-os/kernel/fs/twimap.c
index e72f6c2e20dc50428d138d7bbdc3fa004a1a49cf..62bdaeda41a53b27a520ffdb8f06826cb4ef0e8d 100644
(file)
--- a/
lunaix-os/kernel/fs/twimap.c
+++ b/
lunaix-os/kernel/fs/twimap.c
@@
-6,7
+6,7
@@
#include <klibc/strfmt.h>
#include <klibc/string.h>
#include <klibc/strfmt.h>
#include <klibc/string.h>
-#include <
sys/m
m/pagetable.h>
+#include <
as
m/pagetable.h>
#define TWIMAP_BUFFER_SIZE PAGE_SIZE
#define TWIMAP_BUFFER_SIZE PAGE_SIZE
@@
-39,16
+39,22
@@
int
twimap_read(struct twimap* map, void* buffer, size_t len, size_t fpos)
{
map->buffer = valloc(TWIMAP_BUFFER_SIZE);
twimap_read(struct twimap* map, void* buffer, size_t len, size_t fpos)
{
map->buffer = valloc(TWIMAP_BUFFER_SIZE);
+ map->size_acc = 0;
+
map->reset(map);
// FIXME what if TWIMAP_BUFFER_SIZE is not big enough?
map->reset(map);
// FIXME what if TWIMAP_BUFFER_SIZE is not big enough?
- size_t pos =
0
;
-
do
{
+ size_t pos =
map->size_acc
;
+
while (pos <= fpos)
{
map->size_acc = 0;
map->read(map);
pos += map->size_acc;
map->size_acc = 0;
map->read(map);
pos += map->size_acc;
- } while (pos <= fpos && map->go_next(map));
+
+ if (!map->go_next(map)) {
+ break;
+ }
+ }
if (pos <= fpos) {
vfree(map->buffer);
if (pos <= fpos) {
vfree(map->buffer);