summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-05-06 17:35:13 +0000
committerThomas Martitz <kugel@rockbox.org>2010-05-06 17:35:13 +0000
commit0a1d7c28b7e9da555d26d489cde2da26e2cc9ca0 (patch)
treea21521e6e4b8fe0131c4d9e8bae6d8cc78125fe9 /apps/plugins
parentc61e89c0eda126c2c1a4a3983520c35fe30db156 (diff)
downloadrockbox-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 '')
-rw-r--r--apps/plugins/battery_bench.c6
-rw-r--r--apps/plugins/blackjack.c2
-rw-r--r--apps/plugins/brickmania.c2
-rw-r--r--apps/plugins/bubbles.c4
-rw-r--r--apps/plugins/calendar.c2
-rw-r--r--apps/plugins/chessbox/chessbox.c2
-rw-r--r--apps/plugins/chessbox/chessbox_pgn.c4
-rw-r--r--apps/plugins/crypt_firmware.c4
-rw-r--r--apps/plugins/doom/rockdoom.c13
-rw-r--r--apps/plugins/doom/rockmacros.h6
-rw-r--r--apps/plugins/frotz/fastmem.c4
-rw-r--r--apps/plugins/frotz/files.c4
-rw-r--r--apps/plugins/jewels.c2
-rw-r--r--apps/plugins/keybox.c2
-rw-r--r--apps/plugins/lib/highscore.c2
-rw-r--r--apps/plugins/lua/liolib.c2
-rw-r--r--apps/plugins/md5sum.c2
-rw-r--r--apps/plugins/mp3_encoder.c2
-rw-r--r--apps/plugins/pdbox/PDa/intern/sfwrite~.c4
-rw-r--r--apps/plugins/pdbox/PDa/src/g_array.c4
-rw-r--r--apps/plugins/random_folder_advance_config.c2
-rw-r--r--apps/plugins/rockblox.c2
-rw-r--r--apps/plugins/rockboy/cpu.c2
-rw-r--r--apps/plugins/rockboy/dynarec.c4
-rw-r--r--apps/plugins/rockboy/loader.c4
-rw-r--r--apps/plugins/rockboy/menu.c2
-rw-r--r--apps/plugins/rockboy/rockboy.c2
-rw-r--r--apps/plugins/rockboy/rockmacros.h4
-rw-r--r--apps/plugins/search.c2
-rw-r--r--apps/plugins/searchengine/searchengine.c2
-rw-r--r--apps/plugins/settings_dumper.c2
-rw-r--r--apps/plugins/sokoban.c2
-rw-r--r--apps/plugins/solitaire.c2
-rw-r--r--apps/plugins/sort.c2
-rw-r--r--apps/plugins/splitedit.c4
-rw-r--r--apps/plugins/stopwatch.c2
-rw-r--r--apps/plugins/sudoku/sudoku.c2
-rw-r--r--apps/plugins/superdom.c2
-rw-r--r--apps/plugins/test_codec.c2
-rw-r--r--apps/plugins/test_disk.c2
-rw-r--r--apps/plugins/test_gfx.c2
-rw-r--r--apps/plugins/test_grey.c2
-rw-r--r--apps/plugins/text_editor.c2
-rw-r--r--apps/plugins/theme_remove.c2
-rw-r--r--apps/plugins/viewer.c6
-rw-r--r--apps/plugins/wavrecord.c2
-rw-r--r--apps/plugins/zxbox/spsound.c4
47 files changed, 73 insertions, 68 deletions
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index 5c04892..165ce54 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 1af26f2..7b3dbef 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 60e8f38..98de3d4 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 a3de9d2..5146212 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 3589998..13abdfc 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 72a8b23..45f052d 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 a165e3e..3d699a7 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 36689b7..051a3d1 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 21efbc4..1383a2b 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 98f908d..e066fe8 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 ba0c95f..ce424af 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 1baaa40..7ca9161 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 6bed9bf..c2340aa 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 f8da40f..c6b060c 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 9ada06e..1859302 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 e50524a..7a43915 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 973ffb3..9dd8f5a 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 50aa99b..fe417ce 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 ba63322..49df0b7 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 431cfeb..f0359e4 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 6a62fee..d5e7a10 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 f1ad839..4e261e4 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 2fc7411..e1d1324 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 afe6caa..3c71115 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 71ab4e7..e92b7d0 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 710a476..2f6c310 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 ba60b14..ec224a2 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 0fd13f6..e7f79a5 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 4f60c82..ba16b88 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 ddcd0ea..f737a27 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;i<rb->tagdbheader->filecount;i++)
if(result[i]) {
diff --git a/apps/plugins/settings_dumper.c b/apps/plugins/settings_dumper.c
index 68c2433..ea69353 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 838b4de..3a853c8 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 cf4e647..1c7aefb 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 2ae788e..05c45cc 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 a07769c..3e5161b 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 cb85e36..b09dcdb 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 9e7e969..4a7fbd9 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 d26e988..d5d08fb 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 f3b826e..1ecf225 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 396e03c..c83fb7e 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 728eb56..0a2e02e 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 c2adaf0..be28bed 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 4d5812b..e549352 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 3bb4192..f818ac4 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 ed84d26..ffed414 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 732a7b7..a8aab92 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 aae4ad9..6a550e2 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