From 0a1d7c28b7e9da555d26d489cde2da26e2cc9ca0 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Thu, 6 May 2010 17:35:13 +0000 Subject: 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 --- apps/plugins/battery_bench.c | 6 +++--- apps/plugins/blackjack.c | 2 +- apps/plugins/brickmania.c | 2 +- apps/plugins/bubbles.c | 4 ++-- apps/plugins/calendar.c | 2 +- apps/plugins/chessbox/chessbox.c | 2 +- apps/plugins/chessbox/chessbox_pgn.c | 4 ++-- apps/plugins/crypt_firmware.c | 4 ++-- apps/plugins/doom/rockdoom.c | 13 ++++++++++--- apps/plugins/doom/rockmacros.h | 6 +++--- apps/plugins/frotz/fastmem.c | 4 ++-- apps/plugins/frotz/files.c | 4 ++-- apps/plugins/jewels.c | 2 +- apps/plugins/keybox.c | 2 +- apps/plugins/lib/highscore.c | 2 +- apps/plugins/lua/liolib.c | 2 +- apps/plugins/md5sum.c | 2 +- apps/plugins/mp3_encoder.c | 2 +- apps/plugins/pdbox/PDa/intern/sfwrite~.c | 4 ---- apps/plugins/pdbox/PDa/src/g_array.c | 4 ++-- apps/plugins/random_folder_advance_config.c | 2 +- apps/plugins/rockblox.c | 2 +- apps/plugins/rockboy/cpu.c | 2 +- apps/plugins/rockboy/dynarec.c | 4 ++-- apps/plugins/rockboy/loader.c | 4 ++-- apps/plugins/rockboy/menu.c | 2 +- apps/plugins/rockboy/rockboy.c | 2 +- apps/plugins/rockboy/rockmacros.h | 4 +++- apps/plugins/search.c | 2 +- apps/plugins/searchengine/searchengine.c | 2 +- apps/plugins/settings_dumper.c | 2 +- apps/plugins/sokoban.c | 2 +- apps/plugins/solitaire.c | 2 +- apps/plugins/sort.c | 2 +- apps/plugins/splitedit.c | 4 ++-- apps/plugins/stopwatch.c | 2 +- apps/plugins/sudoku/sudoku.c | 2 +- apps/plugins/superdom.c | 2 +- apps/plugins/test_codec.c | 2 +- apps/plugins/test_disk.c | 2 +- apps/plugins/test_gfx.c | 2 +- apps/plugins/test_grey.c | 2 +- apps/plugins/text_editor.c | 2 +- apps/plugins/theme_remove.c | 2 +- apps/plugins/viewer.c | 6 +++--- apps/plugins/wavrecord.c | 2 +- apps/plugins/zxbox/spsound.c | 4 ++-- 47 files changed, 73 insertions(+), 68 deletions(-) (limited to 'apps/plugins') diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index 5c04892d61..165ce54634 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c @@ -336,7 +336,7 @@ static void flush_buffer(void* data) if (in_usb_mode || (buf_idx == 0)) return; - fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT | O_APPEND); + fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT | O_APPEND, 0666); if (fd < 0) return; @@ -446,7 +446,7 @@ void thread(void) rb->unregister_storage_idle_func(flush_buffer, true); /* log end of bench and exit reason */ - fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT | O_APPEND); + fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT | O_APPEND, 0666); if (fd >= 0) { rb->fdprintf(fd, "--Battery bench ended, reason: %s--\n", exit_reason); @@ -525,7 +525,7 @@ int main(void) fd = rb->open(BATTERY_LOG, O_RDONLY); if (fd < 0) { - fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT); + fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT, 0666); if (fd >= 0) { rb->fdprintf(fd, diff --git a/apps/plugins/blackjack.c b/apps/plugins/blackjack.c index 1af26f290f..7b3dbef805 100644 --- a/apps/plugins/blackjack.c +++ b/apps/plugins/blackjack.c @@ -871,7 +871,7 @@ static void blackjack_savegame(struct game_context* bj) { if(!resume) return; /* write out the game state to the save file */ - fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT); + fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT, 0666); if(fd < 0) return; rb->write(fd, bj, sizeof(struct game_context)); diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c index 60e8f3820b..98de3d439f 100644 --- a/apps/plugins/brickmania.c +++ b/apps/plugins/brickmania.c @@ -1265,7 +1265,7 @@ static void brickmania_savegame(void) int fd; /* write out the game state to the save file */ - fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT); + fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT, 0666); if(fd < 0) return; if ((rb->write(fd, &pad_pos_x, sizeof(pad_pos_x)) <= 0) || diff --git a/apps/plugins/bubbles.c b/apps/plugins/bubbles.c index a3de9d2511..514621224a 100644 --- a/apps/plugins/bubbles.c +++ b/apps/plugins/bubbles.c @@ -2212,7 +2212,7 @@ static void bubbles_savedata(void) { if (last_highlevel >= highlevel) /* no need to save */ return; - fd = rb->open(DATA_FILE, O_WRONLY|O_CREAT); + fd = rb->open(DATA_FILE, O_WRONLY|O_CREAT, 0666); if (fd < 0) return; rb->write(fd, &highlevel, sizeof(highlevel)); @@ -2252,7 +2252,7 @@ static void bubbles_savegame(struct game_context* bb) { if (!resume) /* nothing to save */ return; /* write out the game state to the save file */ - fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT); + fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT, 0666); if (fd < 0) { rb->splash(HZ/2, "Failed to save game"); diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c index 3589998e47..13abdfc29a 100644 --- a/apps/plugins/calendar.c +++ b/apps/plugins/calendar.c @@ -611,7 +611,7 @@ static bool save_memo(int changed, bool new_mod, struct shown *shown) { int fp, fq; /* use O_RDWR|O_CREAT so that file is created if it doesn't exist. */ - fp = rb->open(MEMO_FILE, O_RDWR|O_CREAT); + fp = rb->open(MEMO_FILE, O_RDWR|O_CREAT, 0666); fq = rb->creat(TEMP_FILE, 0666); if ( (fq > -1) && (fp > -1) ) { diff --git a/apps/plugins/chessbox/chessbox.c b/apps/plugins/chessbox/chessbox.c index 72a8b238a8..45f052d30a 100644 --- a/apps/plugins/chessbox/chessbox.c +++ b/apps/plugins/chessbox/chessbox.c @@ -275,7 +275,7 @@ void cb_saveposition ( void ) { rb->splash ( 0 , "Saving position" ); - fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT); + fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT, 0666); computer++; rb->write(fd, &(computer), sizeof(computer)); computer--; opponent++; rb->write(fd, &(opponent), sizeof(opponent)); opponent--; diff --git a/apps/plugins/chessbox/chessbox_pgn.c b/apps/plugins/chessbox/chessbox_pgn.c index a165e3ee8c..3d699a7c9e 100644 --- a/apps/plugins/chessbox/chessbox_pgn.c +++ b/apps/plugins/chessbox/chessbox_pgn.c @@ -670,7 +670,7 @@ void pgn_parse_game(const char* filename, rb->read_line(fhandler, line_buffer, sizeof line_buffer); } - loghandler = rb->open(LOG_FILE, O_WRONLY | O_CREAT); + loghandler = rb->open(LOG_FILE, O_WRONLY | O_CREAT, 0666); GNUChess_Initialize(); @@ -829,7 +829,7 @@ void pgn_store_game(struct pgn_game_node* game){ ply_count++; } - fhandler = rb->open(PGN_FILE, O_WRONLY|O_CREAT|O_APPEND); + fhandler = rb->open(PGN_FILE, O_WRONLY|O_CREAT|O_APPEND, 0666); /* the first 7 tags are mandatory according to the PGN specification so we diff --git a/apps/plugins/crypt_firmware.c b/apps/plugins/crypt_firmware.c index 36689b7e8c..051a3d1bd9 100644 --- a/apps/plugins/crypt_firmware.c +++ b/apps/plugins/crypt_firmware.c @@ -246,7 +246,7 @@ enum plugin_status plugin_start(const void* parameter) memcpy(buf + 1, "nn2x", 4); /* 4 - Write to disk */ - fd = rb->open(outputfilename,O_WRONLY|O_CREAT|O_TRUNC); + fd = rb->open(outputfilename,O_WRONLY|O_CREAT|O_TRUNC, 0666); if (fd < 0) { rb->splash(HZ*2, "Could not open output file"); @@ -307,7 +307,7 @@ enum plugin_status plugin_start(const void* parameter) memcpy(buf + 1, "nn2g", 4); /* 4 - Write to disk */ - fd = rb->open(outputfilename,O_WRONLY|O_CREAT|O_TRUNC); + fd = rb->open(outputfilename,O_WRONLY|O_CREAT|O_TRUNC, 0666); if (fd < 0) { rb->splash(HZ*2, "Could not open output file"); diff --git a/apps/plugins/doom/rockdoom.c b/apps/plugins/doom/rockdoom.c index 21efbc4147..1383a2b520 100644 --- a/apps/plugins/doom/rockdoom.c +++ b/apps/plugins/doom/rockdoom.c @@ -63,13 +63,20 @@ int fileexists(const char * fname) } #ifndef SIMULATOR -int my_open(const char *file, int flags) +int my_open(const char *file, int flags, ...) { if(fpoint==8) return -1; #undef open - filearray[fpoint]=rb->open(file, flags); - + if (flags & O_CREAT) + { + va_list ap; + va_start(ap, flags); + filearray[fpoint]=rb->open(file, flags, va_arg(ap, mode_t)); + va_end(ap); + } + else + filearray[fpoint]=rb->open(file, flags); if(filearray[fpoint]<0) return filearray[fpoint]; diff --git a/apps/plugins/doom/rockmacros.h b/apps/plugins/doom/rockmacros.h index 98f908dc1d..e066fe861c 100644 --- a/apps/plugins/doom/rockmacros.h +++ b/apps/plugins/doom/rockmacros.h @@ -39,12 +39,12 @@ char *my_strtok( char * s, const char * delim ); #define read_line(a,b,c) rb->read_line((a),(b),(c)) #ifdef SIMULATOR -#define open(a,b) rb->open((a),(b)) +#define open(a, ...) rb->open((a), __VA_ARGS__) #define close(a) rb->close((a)) #else -int my_open(const char *file, int flags); +int my_open(const char *file, int flags, ...); int my_close(int id); -#define open(a,b) my_open((a),(b)) +#define open(a, ...) my_open((a), __VA_ARGS__) #define close(a) my_close((a)) #endif diff --git a/apps/plugins/frotz/fastmem.c b/apps/plugins/frotz/fastmem.c index ba0c95f5ce..ce424af1f2 100644 --- a/apps/plugins/frotz/fastmem.c +++ b/apps/plugins/frotz/fastmem.c @@ -837,7 +837,7 @@ void z_save (void) /* Open auxilary file */ - if ((gfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC)) < 0) + if ((gfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) goto finished; /* Write auxilary file */ @@ -859,7 +859,7 @@ void z_save (void) /* Open game file */ - if ((gfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC)) < 0) + if ((gfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) goto finished; success = save_quetzal (gfp, story_fp); diff --git a/apps/plugins/frotz/files.c b/apps/plugins/frotz/files.c index 1baaa4073f..7ca916186c 100644 --- a/apps/plugins/frotz/files.c +++ b/apps/plugins/frotz/files.c @@ -74,7 +74,7 @@ void script_open (void) /* Opening in "at" mode doesn't work for script_erase_input... */ - if ((sfp = rb->open (script_name, O_RDWR|O_CREAT)) != -1) { + if ((sfp = rb->open (script_name, O_RDWR|O_CREAT, 0666)) != -1) { fseek (sfp, 0, SEEK_END); @@ -290,7 +290,7 @@ void record_open (void) strcpy (command_name, new_name); - if ((rfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC)) != -1) + if ((rfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC, 0666)) != -1) ostream_record = TRUE; else print_string ("Cannot open file\n"); diff --git a/apps/plugins/jewels.c b/apps/plugins/jewels.c index 6bed9bf827..c2340aa557 100644 --- a/apps/plugins/jewels.c +++ b/apps/plugins/jewels.c @@ -498,7 +498,7 @@ static void jewels_savegame(struct game_context* bj) { int fd; /* write out the game state to the save file */ - fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT); + fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT, 0666); if(fd < 0) return; rb->write(fd, &bj->tmp_type, sizeof(bj->tmp_type)); diff --git a/apps/plugins/keybox.c b/apps/plugins/keybox.c index f8da40f08e..c6b060c7fd 100644 --- a/apps/plugins/keybox.c +++ b/apps/plugins/keybox.c @@ -584,7 +584,7 @@ static int keybox(void) if (data_changed) { - fd = rb->open(KEYBOX_FILE, O_WRONLY | O_CREAT | O_TRUNC); + fd = rb->open(KEYBOX_FILE, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (fd < 0) return FILE_OPEN_ERROR; write_output(fd); diff --git a/apps/plugins/lib/highscore.c b/apps/plugins/lib/highscore.c index 9ada06e8fe..185930202a 100644 --- a/apps/plugins/lib/highscore.c +++ b/apps/plugins/lib/highscore.c @@ -33,7 +33,7 @@ int highscore_save(char *filename, struct highscore *scores, int num_scores) if(!highscore_updated) return 1; - fd = rb->open(filename, O_WRONLY|O_CREAT); + fd = rb->open(filename, O_WRONLY|O_CREAT, 0666); if(fd < 0) return -1; diff --git a/apps/plugins/lua/liolib.c b/apps/plugins/lua/liolib.c index e50524ae89..7a43915f20 100644 --- a/apps/plugins/lua/liolib.c +++ b/apps/plugins/lua/liolib.c @@ -158,7 +158,7 @@ static int io_open (lua_State *L) { } if((*mode == 'w' || *mode == 'a') && !rb->file_exists(filename)) flags |= O_CREAT; - *pf = rb->open(filename, flags); + *pf = rb->open(filename, flags, 0666); return (*pf < 0) ? pushresult(L, 0, filename) : 1; } diff --git a/apps/plugins/md5sum.c b/apps/plugins/md5sum.c index 973ffb3237..9dd8f5a8a7 100644 --- a/apps/plugins/md5sum.c +++ b/apps/plugins/md5sum.c @@ -246,7 +246,7 @@ enum plugin_status plugin_start(const void* parameter) done = 0; action( out, arg ); - out = rb->open( filename, O_WRONLY|O_CREAT|O_TRUNC ); + out = rb->open( filename, O_WRONLY|O_CREAT|O_TRUNC , 0666); if( out < 0 ) return PLUGIN_ERROR; action( out, arg ); rb->close( out ); diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c index 50aa99b2ae..fe417ce180 100644 --- a/apps/plugins/mp3_encoder.c +++ b/apps/plugins/mp3_encoder.c @@ -2598,7 +2598,7 @@ enum plugin_status plugin_start(const void* parameter) { init_mp3_encoder_engine(true, brate[srat], cfg.samplerate); get_mp3_filename(wav_filename); - mp3file = rb->open(mp3_name , O_WRONLY|O_CREAT|O_TRUNC); + mp3file = rb->open(mp3_name , O_WRONLY|O_CREAT|O_TRUNC, 0666); frames = 0; tim = *rb->current_tick; diff --git a/apps/plugins/pdbox/PDa/intern/sfwrite~.c b/apps/plugins/pdbox/PDa/intern/sfwrite~.c index ba63322380..49df0b7eeb 100644 --- a/apps/plugins/pdbox/PDa/intern/sfwrite~.c +++ b/apps/plugins/pdbox/PDa/intern/sfwrite~.c @@ -91,11 +91,7 @@ static void sfwrite_open(t_sfwrite *x,t_symbol *filename) sfwrite_close(x); -#ifdef ROCKBOX - if ((x->x_file = open(fname, O_RDWR | O_CREAT)) < 0) -#else if ((x->x_file = open(fname,O_RDWR | O_CREAT,0664)) < 0) -#endif { error("can't create %s",fname); return; diff --git a/apps/plugins/pdbox/PDa/src/g_array.c b/apps/plugins/pdbox/PDa/src/g_array.c index 431cfeb31d..f0359e465a 100644 --- a/apps/plugins/pdbox/PDa/src/g_array.c +++ b/apps/plugins/pdbox/PDa/src/g_array.c @@ -1306,7 +1306,7 @@ static void garray_write(t_garray *x, t_symbol *filename) buf, MAXPDSTRING); sys_bashfilename(buf, buf); #ifdef ROCKBOX - if(!(fd = open(buf, O_WRONLY|O_CREAT|O_TRUNC))) + if(!(fd = open(buf, O_WRONLY|O_CREAT|O_TRUNC, 0666))) #else if (!(fd = fopen(buf, "w"))) #endif @@ -1388,7 +1388,7 @@ static void garray_write16(t_garray *x, t_symbol *filename, t_symbol *format) buf2, MAXPDSTRING); sys_bashfilename(buf2, buf2); #ifdef ROCKBOX - if(!(fd = open(buf2, O_WRONLY|O_CREAT|O_TRUNC))) + if(!(fd = open(buf2, O_WRONLY|O_CREAT|O_TRUNC, 0666))) #else if (!(fd = fopen(buf2, BINWRITEMODE))) #endif diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c index 6a62fee8ff..d5e7a10cdc 100644 --- a/apps/plugins/random_folder_advance_config.c +++ b/apps/plugins/random_folder_advance_config.c @@ -214,7 +214,7 @@ void generate(void) { dirs_count = 0; abort = false; - fd = rb->open(RFA_FILE,O_CREAT|O_WRONLY); + fd = rb->open(RFA_FILE,O_CREAT|O_WRONLY, 0666); rb->write(fd,&dirs_count,sizeof(int)); if (fd < 0) { diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c index f1ad8399fb..4e261e4547 100644 --- a/apps/plugins/rockblox.c +++ b/apps/plugins/rockblox.c @@ -877,7 +877,7 @@ static void dump_resume(void) { int fd; - fd = rb->open(RESUME_FILE, O_WRONLY|O_CREAT); + fd = rb->open(RESUME_FILE, O_WRONLY|O_CREAT, 0666); if (fd < 0) goto fail; diff --git a/apps/plugins/rockboy/cpu.c b/apps/plugins/rockboy/cpu.c index 2fc7411411..e1d1324c4b 100644 --- a/apps/plugins/rockboy/cpu.c +++ b/apps/plugins/rockboy/cpu.c @@ -947,7 +947,7 @@ next: int fd; blockcount++; snprintf(meow,499,"/dyna_0x%x_run.rb",PC); - fd=open(meow,O_WRONLY|O_CREAT|O_TRUNC); + fd=open(meow,O_WRONLY|O_CREAT|O_TRUNC, 0666); if(fd>=0) { fdprintf(fd,"Block 0x%x Blockcount: %d\n",PC,blockcount); diff --git a/apps/plugins/rockboy/dynarec.c b/apps/plugins/rockboy/dynarec.c index afe6caaf1a..3c71115654 100644 --- a/apps/plugins/rockboy/dynarec.c +++ b/apps/plugins/rockboy/dynarec.c @@ -425,7 +425,7 @@ void dynamic_recompile (struct dynarec_block *newblock) newblock->block=dynapointer; #ifdef DYNA_DEBUG snprintf(meow,499,"/dyna_0x%x_asm.rb",PC); - fd=open(meow,O_WRONLY|O_CREAT|O_TRUNC); + fd=open(meow,O_WRONLY|O_CREAT|O_TRUNC, 0666); if(fd<0) { die("couldn't open dyna debug file"); @@ -1907,7 +1907,7 @@ void dynamic_recompile (struct dynarec_block *newblock) newblock->length=dynapointer-newblock->block; IF_COP(rb->cpucache_invalidate()); snprintf(meow,499,"/dyna_0x%x_code.rb",PC); - fd=open(meow,O_WRONLY|O_CREAT|O_TRUNC); + fd=open(meow,O_WRONLY|O_CREAT|O_TRUNC, 0666); if(fd>=0) { write(fd,newblock->block,newblock->length); diff --git a/apps/plugins/rockboy/loader.c b/apps/plugins/rockboy/loader.c index 71ab4e78d7..e92b7d0a7e 100644 --- a/apps/plugins/rockboy/loader.c +++ b/apps/plugins/rockboy/loader.c @@ -249,7 +249,7 @@ static int sram_save(void) /* If we crash before we ever loaded sram, DO NOT SAVE! */ if (!mbc.batt || !ram.loaded || !mbc.ramsize) return -1; - fd = open(sramfile, O_WRONLY|O_CREAT|O_TRUNC); + fd = open(sramfile, O_WRONLY|O_CREAT|O_TRUNC, 0666); if (fd<0) return -1; snprintf(meow,499,"Saving savedata to %s",sramfile); rb->splash(HZ*2, meow); @@ -263,7 +263,7 @@ static void rtc_save(void) { int fd; if (!rtc.batt) return; - if ((fd = open(rtcfile, O_WRONLY|O_CREAT|O_TRUNC))<0) return; + if ((fd = open(rtcfile, O_WRONLY|O_CREAT|O_TRUNC, 0666))<0) return; rtc_save_internal(fd); close(fd); } diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c index 710a47646a..2f6c3102ff 100644 --- a/apps/plugins/rockboy/menu.c +++ b/apps/plugins/rockboy/menu.c @@ -178,7 +178,7 @@ static bool do_file(char *path, char *desc, bool is_load) { file_mode = is_load ? O_RDONLY : (O_WRONLY | O_CREAT); /* attempt to open file descriptor here */ - if ((fd = open(path, file_mode)) < 0) + if ((fd = open(path, file_mode, 0666)) < 0) return false; /* load/save state */ diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c index ba60b14f72..ec224a20db 100644 --- a/apps/plugins/rockboy/rockboy.c +++ b/apps/plugins/rockboy/rockboy.c @@ -325,7 +325,7 @@ static void savesettings(void) { options.dirty=0; snprintf(optionsave, sizeof(optionsave), "%s/%s", savedir, optionname); - fd = open(optionsave, O_WRONLY|O_CREAT|O_TRUNC); + fd = open(optionsave, O_WRONLY|O_CREAT|O_TRUNC, 0666); write(fd,&options, sizeof(options)); close(fd); } diff --git a/apps/plugins/rockboy/rockmacros.h b/apps/plugins/rockboy/rockmacros.h index 0fd13f6ef9..e7f79a53d3 100644 --- a/apps/plugins/rockboy/rockmacros.h +++ b/apps/plugins/rockboy/rockmacros.h @@ -59,7 +59,9 @@ void dynamic_recompile (struct dynarec_block *newblock); #define isalpha(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && ((c) <= 'Z'))) #define isalnum(c) (isdigit(c) || (isalpha(c))) -#define open(a,b) rb->open((a),(b)) +/* only 1 fixed argument for open, since variadic macros don't except empty + * variable parameters */ +#define open(a, ...) rb->open((a), __VA_ARGS__) #define lseek(a,b,c) rb->lseek((a),(b),(c)) #define close(a) rb->close((a)) #define read(a,b,c) rb->read((a),(b),(c)) diff --git a/apps/plugins/search.c b/apps/plugins/search.c index 4f60c82d08..ba16b8821b 100644 --- a/apps/plugins/search.c +++ b/apps/plugins/search.c @@ -123,7 +123,7 @@ static bool search_init(const char* file){ if (bomsize) fdw = rb->open_utf8(resultfile, O_WRONLY|O_CREAT|O_TRUNC); else - fdw = rb->open(resultfile, O_WRONLY|O_CREAT|O_TRUNC); + fdw = rb->open(resultfile, O_WRONLY|O_CREAT|O_TRUNC, 0666); if (fdw < 0) { #ifdef HAVE_LCD_BITMAP diff --git a/apps/plugins/searchengine/searchengine.c b/apps/plugins/searchengine/searchengine.c index ddcd0ead0d..f737a27621 100644 --- a/apps/plugins/searchengine/searchengine.c +++ b/apps/plugins/searchengine/searchengine.c @@ -78,7 +78,7 @@ enum plugin_status plugin_start(const void* parameter) rb->close(parsefd); hits=0; if(result!=0) { - int fd=rb->open("/search.m3u", O_WRONLY|O_CREAT|O_TRUNC); + int fd=rb->open("/search.m3u", O_WRONLY|O_CREAT|O_TRUNC, 0666); int i; for(i=0;itagdbheader->filecount;i++) if(result[i]) { diff --git a/apps/plugins/settings_dumper.c b/apps/plugins/settings_dumper.c index 68c2433ce6..ea69353e17 100644 --- a/apps/plugins/settings_dumper.c +++ b/apps/plugins/settings_dumper.c @@ -124,7 +124,7 @@ enum plugin_status plugin_start( int fd; (void)parameter; - fd = rb->open(FILENAME, O_CREAT|O_TRUNC|O_WRONLY); + fd = rb->open(FILENAME, O_CREAT|O_TRUNC|O_WRONLY, 0666); if (fd < 0) return PLUGIN_ERROR; list = rb->get_settings_list(&setting_count); diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c index 838b4de5b0..3a853c81aa 100644 --- a/apps/plugins/sokoban.c +++ b/apps/plugins/sokoban.c @@ -1117,7 +1117,7 @@ static bool save(char *filename, bool solution) } if (filename[0] == '\0' || - (fd = rb->open(filename, O_WRONLY|O_CREAT|O_TRUNC)) < 0) { + (fd = rb->open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) { rb->splashf(HZ*2, "Unable to open %s", filename); return false; } diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c index cf4e6475b0..1c7aefb1c3 100644 --- a/apps/plugins/solitaire.c +++ b/apps/plugins/solitaire.c @@ -1272,7 +1272,7 @@ int open_save_file( int flags ) { char buf[MAX_PATH]; get_save_filename( buf ); - return rb->open( buf, flags ); + return rb->open( buf, flags, 0666); } void delete_save_file( void ) diff --git a/apps/plugins/sort.c b/apps/plugins/sort.c index 2ae788ebbd..05c45cce1e 100644 --- a/apps/plugins/sort.c +++ b/apps/plugins/sort.c @@ -147,7 +147,7 @@ static int write_file(void) if (bomsize) fd = rb->open_utf8(tmpfilename, O_WRONLY|O_CREAT|O_TRUNC); else - fd = rb->open(tmpfilename, O_WRONLY|O_CREAT|O_TRUNC); + fd = rb->open(tmpfilename, O_WRONLY|O_CREAT|O_TRUNC, 0666); if(fd < 0) return 10 * fd - 1; diff --git a/apps/plugins/splitedit.c b/apps/plugins/splitedit.c index a07769c390..3e5161b67f 100644 --- a/apps/plugins/splitedit.c +++ b/apps/plugins/splitedit.c @@ -687,7 +687,7 @@ static int save( /* write the file 1 */ if (file_name1 != NULL) { - file1 = rb->open (file_name1, O_WRONLY | O_CREAT); + file1 = rb->open (file_name1, O_WRONLY | O_CREAT, 0666); if (file1 >= 0) { int rc = copy_file(file1, src_file, end, y*2 + 1, y -1); @@ -727,7 +727,7 @@ static int save( if (file_name2 != NULL) { /* write file 2 */ - file2 = rb->open (file_name2, O_WRONLY | O_CREAT); + file2 = rb->open (file_name2, O_WRONLY | O_CREAT, 0666); if (file2 >= 0) { end = mp3->filesize - end; diff --git a/apps/plugins/stopwatch.c b/apps/plugins/stopwatch.c index cb85e360db..b09dcdb030 100644 --- a/apps/plugins/stopwatch.c +++ b/apps/plugins/stopwatch.c @@ -358,7 +358,7 @@ void save_stopwatch(void) { int fd; - fd = rb->open(STOPWATCH_FILE, O_CREAT|O_WRONLY|O_TRUNC); + fd = rb->open(STOPWATCH_FILE, O_CREAT|O_WRONLY|O_TRUNC, 0666); if (fd < 0) { diff --git a/apps/plugins/sudoku/sudoku.c b/apps/plugins/sudoku/sudoku.c index 9e7e969eee..4a7fbd93a8 100644 --- a/apps/plugins/sudoku/sudoku.c +++ b/apps/plugins/sudoku/sudoku.c @@ -808,7 +808,7 @@ bool save_sudoku(struct sudoku_state_t* state) return false; } - fd=rb->open(state->filename, O_WRONLY|O_CREAT); + fd=rb->open(state->filename, O_WRONLY|O_CREAT, 0666); if (fd >= 0) { for (r=0;r<9;r++) { i=0; diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c index d26e98803e..d5d08fb162 100644 --- a/apps/plugins/superdom.c +++ b/apps/plugins/superdom.c @@ -626,7 +626,7 @@ int save_game(void) { return -1; } - fd = rb->open(savepath, O_WRONLY|O_CREAT); + fd = rb->open(savepath, O_WRONLY|O_CREAT, 0666); DEBUGF("savepath: %s\n", savepath); if(fd < 0) { DEBUGF("Couldn't create/open file\n"); diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index f3b826e04e..1ecf225529 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c @@ -59,7 +59,7 @@ static bool log_init(bool use_logfile) if (use_logfile) { rb->create_numbered_filename(logfilename, "/", "test_codec_log_", ".txt", 2 IF_CNFN_NUM_(, NULL)); - log_fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC); + log_fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC, 0666); return log_fd >= 0; } diff --git a/apps/plugins/test_disk.c b/apps/plugins/test_disk.c index 396e03c818..c83fb7e1d2 100644 --- a/apps/plugins/test_disk.c +++ b/apps/plugins/test_disk.c @@ -85,7 +85,7 @@ static bool log_init(void) rb->create_numbered_filename(logfilename, "/", "test_disk_log_", ".txt", 2 IF_CNFN_NUM_(, NULL)); - log_fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC); + log_fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC, 0666); return log_fd >= 0; } diff --git a/apps/plugins/test_gfx.c b/apps/plugins/test_gfx.c index 728eb5600e..0a2e02e43f 100644 --- a/apps/plugins/test_gfx.c +++ b/apps/plugins/test_gfx.c @@ -47,7 +47,7 @@ static int log_init(void) rb->create_numbered_filename(logfilename, "/", "test_gfx_log_", ".txt", 2 IF_CNFN_NUM_(, NULL)); - fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC); + fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC, 0666); return fd; } diff --git a/apps/plugins/test_grey.c b/apps/plugins/test_grey.c index c2adaf06b5..be28bedfb3 100644 --- a/apps/plugins/test_grey.c +++ b/apps/plugins/test_grey.c @@ -237,7 +237,7 @@ enum plugin_status plugin_start(const void* parameter) case GREY_OK: rb->create_numbered_filename(filename, "/", "test_grey_", ".txt", 2 IF_CNFN_NUM_(, NULL)); - fd = rb->open(filename, O_RDWR|O_CREAT|O_TRUNC); + fd = rb->open(filename, O_RDWR|O_CREAT|O_TRUNC, 0666); if (fd >= 0) { for (i = 0; i <= STEPS; i++) diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c index 4d5812ba2c..e54935265c 100644 --- a/apps/plugins/text_editor.c +++ b/apps/plugins/text_editor.c @@ -180,7 +180,7 @@ bool save_changes(int overwrite) } } - fd = rb->open(filename,O_WRONLY|O_CREAT|O_TRUNC); + fd = rb->open(filename,O_WRONLY|O_CREAT|O_TRUNC, 0666); if (fd < 0) { newfile = true; diff --git a/apps/plugins/theme_remove.c b/apps/plugins/theme_remove.c index 3bb41929f3..f818ac4afe 100644 --- a/apps/plugins/theme_remove.c +++ b/apps/plugins/theme_remove.c @@ -686,7 +686,7 @@ enum plugin_status plugin_start(const void* parameter) case 0: if(create_log) { - log_fd = rb->open(LOG_FILENAME, O_WRONLY|O_CREAT|O_APPEND); + log_fd = rb->open(LOG_FILENAME, O_WRONLY|O_CREAT|O_APPEND, 0666); if(log_fd >= 0) rb->fdprintf(log_fd, "---- %s ----\n", title); else diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c index ed84d26f28..ffed414f68 100644 --- a/apps/plugins/viewer.c +++ b/apps/plugins/viewer.c @@ -2138,7 +2138,7 @@ static bool viewer_load_global_settings(void) static bool viewer_save_global_settings(void) { - int sfd = rb->open(GLOBAL_SETTINGS_TMP_FILE, O_WRONLY|O_CREAT|O_TRUNC); + int sfd = rb->open(GLOBAL_SETTINGS_TMP_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0666); unsigned char buf[GLOBAL_SETTINGS_H_SIZE]; if (sfd < 0) @@ -2219,7 +2219,7 @@ static bool viewer_convert_settings_file(void) if ((sfd = rb->open(SETTINGS_FILE, O_RDONLY)) < 0) return false; - if ((tfd = rb->open(SETTINGS_TMP_FILE, O_WRONLY|O_CREAT|O_TRUNC)) < 0) + if ((tfd = rb->open(SETTINGS_TMP_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) { rb->close(sfd); return false; @@ -2441,7 +2441,7 @@ static bool viewer_save_settings(void) bookmarks[bookmark_count-1].flag = BOOKMARK_LAST; } - tfd = rb->open(SETTINGS_TMP_FILE, O_WRONLY|O_CREAT|O_TRUNC); + tfd = rb->open(SETTINGS_TMP_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0666); if (tfd < 0) return false; diff --git a/apps/plugins/wavrecord.c b/apps/plugins/wavrecord.c index 732a7b7645..a8aab92113 100644 --- a/apps/plugins/wavrecord.c +++ b/apps/plugins/wavrecord.c @@ -3492,7 +3492,7 @@ static int record_file(char *filename) {8, 32000}, {9, 44100}, {10, 48000} }; - fd = rb->open(filename, O_RDWR|O_CREAT|O_TRUNC); + fd = rb->open(filename, O_RDWR|O_CREAT|O_TRUNC, 0666); if (fd < 0) { rb->splash(2*HZ, "Couldn't create WAV file"); diff --git a/apps/plugins/zxbox/spsound.c b/apps/plugins/zxbox/spsound.c index aae4ad9c8d..6a550e2033 100644 --- a/apps/plugins/zxbox/spsound.c +++ b/apps/plugins/zxbox/spsound.c @@ -223,12 +223,12 @@ void write_buf(void){ #if 0 /* can use to save and later analyze what we produce */ - i = rb->open ( "/sound.raw" , O_WRONLY | O_APPEND | O_CREAT ); + i = rb->open ( "/sound.raw" , O_WRONLY | O_APPEND | O_CREAT, 0666); rb->write ( i , sp_sound_buf , TMNUM ); rb->close (i); - i = rb->open ( "/sound2.raw" , O_WRONLY | O_APPEND |O_CREAT); + i = rb->open ( "/sound2.raw" , O_WRONLY | O_APPEND |O_CREAT, 0666); rb->write ( i , (unsigned char *)my_buf , TMNUM*4*3 ); rb->close (i); #endif -- cgit v1.2.3