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 /apps/plugin.c | |
| 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 'apps/plugin.c')
| -rw-r--r-- | apps/plugin.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index 28d4433..baf9b60 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -93,9 +93,9 @@ static char current_plugin[MAX_PATH]; char *plugin_get_current_filename(void); -#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE /* Some wrappers used to monitor open and close and detect leaks*/ -static int open_wrapper(const char* pathname, int flags); +static int open_wrapper(const char* pathname, int flags, ...); +#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE static int close_wrapper(int fd); static int creat_wrapper(const char *pathname, mode_t mode); #endif @@ -299,13 +299,12 @@ static const struct plugin_api rockbox_api = { /* file */ open_utf8, -#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE (open_func)open_wrapper, +#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE close_wrapper, #else - (open_func)PREFIX(open), PREFIX(close), - #endif +#endif (read_func)PREFIX(read), PREFIX(lseek), #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE @@ -979,17 +978,34 @@ char *plugin_get_current_filename(void) return current_plugin; } -#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE -static int open_wrapper(const char* pathname, int flags) +static int open_wrapper(const char* pathname, int flags, ...) { - int fd = PREFIX(open)(pathname,flags); +/* we don't have an 'open' function. it's a define. and we need + * the real file_open, hence PREFIX() doesn't work here */ + int fd; +#ifdef SIMULATOR + if (flags & O_CREAT) + { + va_list ap; + va_start(ap, flags); + int fd; + fd = sim_open(pathname, flags, va_arg(ap, mode_t)); + va_end(ap); + } + else + fd = sim_open(pathname, flags); +#else + fd = file_open(pathname,flags); +#endif +#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE if(fd >= 0) open_files |= 1<<fd; - +#endif return fd; } +#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE static int close_wrapper(int fd) { if((~open_files) & (1<<fd)) |