diff options
| author | Thomas Martitz <kugel@rockbox.org> | 2010-05-06 17:35:13 +0000 |
|---|---|---|
| committer | Thomas Martitz <kugel@rockbox.org> | 2010-05-06 17:35:13 +0000 |
| commit | 0a1d7c28b7e9da555d26d489cde2da26e2cc9ca0 (patch) | |
| tree | a21521e6e4b8fe0131c4d9e8bae6d8cc78125fe9 /firmware | |
| parent | c61e89c0eda126c2c1a4a3983520c35fe30db156 (diff) | |
| download | rockbox-0a1d7c28b7e9da555d26d489cde2da26e2cc9ca0.zip rockbox-0a1d7c28b7e9da555d26d489cde2da26e2cc9ca0.tar.gz rockbox-0a1d7c28b7e9da555d26d489cde2da26e2cc9ca0.tar.bz2 rockbox-0a1d7c28b7e9da555d26d489cde2da26e2cc9ca0.tar.xz | |
Make open() posix compliant api-wise. A few calls (those with O_CREAT) need the additional optional mode parameter so add it. Impact for the core is almost zero, as open() is a wrapper macro for the real open function which doesn't take the variable parameter.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25844 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
| -rw-r--r-- | firmware/common/dircache.c | 2 | ||||
| -rw-r--r-- | firmware/common/file.c | 4 | ||||
| -rw-r--r-- | firmware/font.c | 2 | ||||
| -rw-r--r-- | firmware/include/file.h | 10 | ||||
| -rw-r--r-- | firmware/profile.c | 2 | ||||
| -rw-r--r-- | firmware/target/sh/archos/recorder/powermgmt-recorder.c | 2 | ||||
| -rw-r--r-- | firmware/test/fat/main.c | 2 |
7 files changed, 14 insertions, 10 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index 495366f..225ed1a 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c @@ -557,7 +557,7 @@ int dircache_save(void) return -1; logf("Saving directory cache"); - fd = open(DIRCACHE_FILE, O_WRONLY | O_CREAT | O_TRUNC); + fd = open(DIRCACHE_FILE, O_WRONLY | O_CREAT | O_TRUNC, 0666); maindata.magic = DIRCACHE_MAGIC; maindata.size = dircache_size; diff --git a/firmware/common/file.c b/firmware/common/file.c index 05612cd..438a710 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c @@ -57,7 +57,7 @@ static int flush_cache(int fd); int file_creat(const char *pathname) { - return open(pathname, O_WRONLY|O_CREAT|O_TRUNC); + return open(pathname, O_WRONLY|O_CREAT|O_TRUNC, 0666); } static int open_internal(const char* pathname, int flags, bool use_cache) @@ -228,7 +228,7 @@ static int open_internal(const char* pathname, int flags, bool use_cache) return fd; } -int open(const char* pathname, int flags) +int file_open(const char* pathname, int flags) { /* By default, use the dircache if available. */ return open_internal(pathname, flags, true); diff --git a/firmware/font.c b/firmware/font.c index 6877d7e..f158471 100644 --- a/firmware/font.c +++ b/firmware/font.c @@ -607,7 +607,7 @@ void glyph_cache_save(struct font* pf) if (pf->fd >= 0 && pf == &font_ui) { #ifdef WPSEDITOR - cache_fd = open(GLYPH_CACHE_FILE, O_WRONLY|O_CREAT|O_TRUNC); + cache_fd = open(GLYPH_CACHE_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0666); #else cache_fd = creat(GLYPH_CACHE_FILE, 0666); #endif diff --git a/firmware/include/file.h b/firmware/include/file.h index b60c744..ec0ab87 100644 --- a/firmware/include/file.h +++ b/firmware/include/file.h @@ -49,7 +49,7 @@ #endif #if defined(SIMULATOR) && !defined(PLUGIN) && !defined(CODEC) -#define open(x,y) sim_open(x,y) +#define open(x, ...) sim_open(x, __VA_ARGS__) #define creat(x,m) sim_creat(x,m) #define remove(x) sim_remove(x) #define rename(x,y) sim_rename(x,y) @@ -61,16 +61,17 @@ #define write(x,y,z) sim_write(x,y,z) #define close(x) sim_close(x) extern int sim_creat(const char *pathname, mode_t mode); +extern int sim_open(const char *pathname, int flags, ...); #endif -typedef int (*open_func)(const char* pathname, int flags); +typedef int (*open_func)(const char* pathname, int flags, ...); typedef ssize_t (*read_func)(int fd, void *buf, size_t count); typedef int (*creat_func)(const char *pathname, mode_t mode); typedef ssize_t (*write_func)(int fd, const void *buf, size_t count); typedef void (*qsort_func)(void *base, size_t nmemb, size_t size, int(*_compar)(const void *, const void *)); -extern int open(const char* pathname, int flags); +extern int file_open(const char* pathname, int flags); extern int close(int fd); extern int fsync(int fd); extern ssize_t read(int fd, void *buf, size_t count); @@ -83,6 +84,9 @@ static inline int creat(const char *pathname, mode_t mode) (void)mode; return file_creat(pathname); } +#if !defined(CODEC) && !defined(PLUGIN) +#define open(x, y, ...) file_open(x,y) +#endif #endif extern ssize_t write(int fd, const void *buf, size_t count); extern int remove(const char* pathname); diff --git a/firmware/profile.c b/firmware/profile.c index 6700eca..30a1e9f 100644 --- a/firmware/profile.c +++ b/firmware/profile.c @@ -189,7 +189,7 @@ void profstop() { unsigned short current_index; timer_unregister(); profiling = PROF_OFF; - fd = open("/profile.out", O_WRONLY|O_CREAT|O_TRUNC); + fd = open("/profile.out", O_WRONLY|O_CREAT|O_TRUNC, 0666); if (profiling_exit == PROF_ERROR) { fdprintf(fd,"Profiling exited with an error.\n"); fdprintf(fd,"Overflow or timer stolen most likely.\n"); diff --git a/firmware/target/sh/archos/recorder/powermgmt-recorder.c b/firmware/target/sh/archos/recorder/powermgmt-recorder.c index 7b18420..70373a3 100644 --- a/firmware/target/sh/archos/recorder/powermgmt-recorder.c +++ b/firmware/target/sh/archos/recorder/powermgmt-recorder.c @@ -125,7 +125,7 @@ static void debug_file_log(void) debug_file_close(); } else if (fd < 0) { - fd = open(DEBUG_FILE_NAME, O_WRONLY | O_APPEND | O_CREAT); + fd = open(DEBUG_FILE_NAME, O_WRONLY | O_APPEND | O_CREAT, 0666); if (fd >= 0) { snprintf(debug_message, DEBUG_MESSAGE_LEN, diff --git a/firmware/test/fat/main.c b/firmware/test/fat/main.c index e190d81..1cb53de 100644 --- a/firmware/test/fat/main.c +++ b/firmware/test/fat/main.c @@ -356,7 +356,7 @@ int dbg_test(char* name) for (j=0; j<5; j++) { int num = 40960; - fd = open(name,O_WRONLY|O_CREAT|O_APPEND); + fd = open(name,O_WRONLY|O_CREAT|O_APPEND, 0666); if (fd<0) { DEBUGF("Failed opening file\n"); return -1; |