summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/plugin.h10
-rw-r--r--firmware/common/file.c12
-rw-r--r--firmware/include/file.h36
-rw-r--r--uisimulator/x11/file.h2
-rw-r--r--uisimulator/x11/io.c2
5 files changed, 43 insertions, 19 deletions
diff --git a/apps/plugin.h b/apps/plugin.h
index 5bebcd701f..e7ec86aa53 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -135,13 +135,13 @@ struct plugin_api {
/* file */
int (*open)(const char* pathname, int flags);
int (*close)(int fd);
- int (*read)(int fd, void* buf, int count);
- int (*lseek)(int fd, int offset, int whence);
- int (*creat)(const char *pathname, int mode);
- int (*write)(int fd, void* buf, int count);
+ ssize_t (*read)(int fd, void* buf, size_t count);
+ off_t (*lseek)(int fd, off_t offset, int whence);
+ int (*creat)(const char *pathname, mode_t mode);
+ ssize_t (*write)(int fd, const void* buf, size_t count);
int (*remove)(const char* pathname);
int (*rename)(const char* path, const char* newname);
- int (*ftruncate)(int fd, unsigned int size);
+ int (*ftruncate)(int fd, off_t length);
int (*filesize)(int fd);
int (*fprintf)(int fd, const char *fmt, ...);
int (*read_line)(int fd, char* buffer, int buffer_size);
diff --git a/firmware/common/file.c b/firmware/common/file.c
index b4b879f8fb..f81038fa77 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -52,7 +52,7 @@ static struct filedesc openfiles[MAX_OPEN_FILES];
static int flush_cache(int fd);
-int creat(const char *pathname, int mode)
+int creat(const char *pathname, mode_t mode)
{
(void)mode;
return open(pathname, O_WRONLY|O_CREAT|O_TRUNC);
@@ -307,7 +307,7 @@ int rename(const char* path, const char* newpath)
return 0;
}
-int ftruncate(int fd, unsigned int size)
+int ftruncate(int fd, off_t size)
{
int rc, sector;
struct filedesc* file = &openfiles[fd];
@@ -513,22 +513,22 @@ static int readwrite(int fd, void* buf, int count, bool write)
return nread;
}
-int write(int fd, void* buf, int count)
+ssize_t write(int fd, const void* buf, size_t count)
{
if (!openfiles[fd].write) {
errno = EACCES;
return -1;
}
- return readwrite(fd, buf, count, true);
+ return readwrite(fd, (void *)buf, count, true);
}
-int read(int fd, void* buf, int count)
+ssize_t read(int fd, void* buf, size_t count)
{
return readwrite(fd, buf, count, false);
}
-int lseek(int fd, int offset, int whence)
+off_t lseek(int fd, off_t offset, int whence)
{
int pos;
int newsector;
diff --git a/firmware/include/file.h b/firmware/include/file.h
index 2ea74c2f5b..8159a7bc84 100644
--- a/firmware/include/file.h
+++ b/firmware/include/file.h
@@ -42,8 +42,32 @@
#define O_TRUNC 0x10
#endif
+#if !defined(__ssize_t_defined) && !defined(_SSIZE_T_)
+#define __ssize_t_defined
+#define _SSIZE_T_
+typedef signed long ssize_t;
+#endif
+
+#if !defined(__off_t_defined) && !defined(_OFF_T_)
+#define __off_t_defined
+#define _OFF_T_
+typedef signed long off_t;
+#endif
+
+#if !defined(__mode_t_defined) && !defined(_MODE_T_)
+#define __mode_t_defined
+#define _MODE_T_
+typedef unsigned int mode_t;
+#endif
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned int size_t;
+#endif
+
+
#if defined(__MINGW32__) && defined(SIMULATOR)
-extern int open(const char*, int, ...);
+extern int open(const char*, int flags, ...);
extern int close(int fd);
extern int read(int, void*, unsigned int);
extern long lseek(int, long, int);
@@ -57,13 +81,13 @@ extern int remove(const char*);
extern int open(const char* pathname, int flags);
extern int close(int fd);
extern int fsync(int fd);
-extern int read(int fd, void* buf, int count);
-extern int lseek(int fd, int offset, int whence);
-extern int creat(const char *pathname, int mode);
-extern int write(int fd, void* buf, int count);
+extern ssize_t read(int fd, void *buf, size_t count);
+extern off_t lseek(int fildes, off_t offset, int whence);
+extern int creat(const char *pathname, mode_t mode);
+extern ssize_t write(int fd, const void *buf, size_t count);
extern int remove(const char* pathname);
extern int rename(const char* path, const char* newname);
-extern int ftruncate(int fd, unsigned int size);
+extern int ftruncate(int fd, off_t length);
extern int filesize(int fd);
#endif /* SIMULATOR */
#endif /* __MINGW32__ */
diff --git a/uisimulator/x11/file.h b/uisimulator/x11/file.h
index 7212692907..b30167ecbd 100644
--- a/uisimulator/x11/file.h
+++ b/uisimulator/x11/file.h
@@ -26,7 +26,7 @@
int x11_open(const char *name, int opts);
int x11_close(int fd);
int x11_filesize(int fd);
-int x11_creat(char *name, int mode);
+int x11_creat(const char *name, mode_t mode);
int x11_remove(char *name);
int x11_rename(char *oldpath, char *newpath);
diff --git a/uisimulator/x11/io.c b/uisimulator/x11/io.c
index 6fc82cc6f7..14d2bfa2c0 100644
--- a/uisimulator/x11/io.c
+++ b/uisimulator/x11/io.c
@@ -120,7 +120,7 @@ int x11_close(int fd)
return (close)(fd);
}
-int x11_creat(char *name, int mode)
+int x11_creat(const char *name, mode_t mode)
{
char buffer[256]; /* sufficiently big */
(void)mode;