projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Clean up. Add set polarity prototype.
[bertos.git]
/
bertos
/
emul
/
kfile_posix.c
diff --git
a/bertos/emul/kfile_posix.c
b/bertos/emul/kfile_posix.c
index 593571d4bfb8494c45540f35684d69a6052fde6d..1f09aaff7062dd461856aee0ecaa6a7e21ed70cf 100644
(file)
--- a/
bertos/emul/kfile_posix.c
+++ b/
bertos/emul/kfile_posix.c
@@
-37,6
+37,7
@@
*/
#include <emul/kfile_posix.h>
*/
#include <emul/kfile_posix.h>
+#include <string.h>
static size_t kfile_posix_read(struct KFile *_fd, void *buf, size_t size)
{
static size_t kfile_posix_read(struct KFile *_fd, void *buf, size_t size)
{
@@
-67,9
+68,13
@@
static kfile_off_t kfile_posix_seek(struct KFile *_fd, kfile_off_t offset, KSeek
break;
default:
ASSERT(0);
break;
default:
ASSERT(0);
+ return EOF;
}
}
+ int err = fseek(fd->fp, offset, std_whence);
+ if (err)
+ return err;
- return f
seek(fd->fp, offset, std_whence
);
+ return f
tell(fd->fp
);
}
static int kfile_posix_close(struct KFile *_fd)
}
static int kfile_posix_close(struct KFile *_fd)
@@
-86,7
+91,8
@@
static int kfile_posix_flush(struct KFile *_fd)
FILE *kfile_posix_init(KFilePosix *file, const char *filename, const char *mode)
{
FILE *kfile_posix_init(KFilePosix *file, const char *filename, const char *mode)
{
- file->fd._type = KFT_KFILEPOSIX;
+ memset(file, 0, sizeof(*file));
+ DB(file->fd._type = KFT_KFILEPOSIX);
file->fd.read = kfile_posix_read;
file->fd.write = kfile_posix_write;
file->fd.close = kfile_posix_close;
file->fd.read = kfile_posix_read;
file->fd.write = kfile_posix_write;
file->fd.close = kfile_posix_close;