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
refactor: restructure the user space stuff.
[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 e32ec333c3b7d1965b2d75dc95f303d1ff256077..2371eb8b257b63b1991986e5f04a954ee324798f 100644
(file)
--- a/
lunaix-os/kernel/fs/twimap.c
+++ b/
lunaix-os/kernel/fs/twimap.c
@@
-6,7
+6,7
@@
#include <klibc/stdio.h>
#include <klibc/string.h>
#include <klibc/stdio.h>
#include <klibc/string.h>
-#define TWIMAP_BUFFER_SIZE
1024
+#define TWIMAP_BUFFER_SIZE
4096
void
__twimap_default_reset(struct twimap* map)
void
__twimap_default_reset(struct twimap* map)
@@
-40,9
+40,9
@@
twimap_read(struct twimap* map, void* buffer, size_t len, size_t 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));
+ } while (pos <
=
fpos && map->go_next(map));
- if (pos < fpos) {
+ if (pos <
=
fpos) {
vfree(map->buffer);
return 0;
}
vfree(map->buffer);
return 0;
}
@@
-62,6
+62,11
@@
twimap_read(struct twimap* map, void* buffer, size_t len, size_t fpos)
acc_size += rdlen;
}
acc_size += rdlen;
}
+ if (acc_size <= len - 1) {
+ // pad zero
+ *(char*)(buffer + acc_size + 1) = 0;
+ }
+
vfree(map->buffer);
return acc_size;
}
vfree(map->buffer);
return acc_size;
}
@@
-75,7
+80,7
@@
twimap_printf(struct twimap* mapping, const char* fmt, ...)
char* buf = mapping->buffer + mapping->size_acc;
mapping->size_acc +=
char* buf = mapping->buffer + mapping->size_acc;
mapping->size_acc +=
- __ksprintf_internal(buf, fmt, TWIMAP_BUFFER_SIZE, args);
+ __ksprintf_internal(buf, fmt, TWIMAP_BUFFER_SIZE, args)
- 1
;
va_end(args);
}
va_end(args);
}
@@
-112,6
+117,7
@@
twimap_create(void* data)
struct v_file_ops twimap_file_ops = { .close = default_file_close,
.read = __twimap_file_read,
struct v_file_ops twimap_file_ops = { .close = default_file_close,
.read = __twimap_file_read,
+ .read_page = __twimap_file_read,
.readdir = default_file_readdir,
.seek = default_file_seek,
.write = default_file_write };
\ No newline at end of file
.readdir = default_file_readdir,
.seek = default_file_seek,
.write = default_file_write };
\ No newline at end of file