A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

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

+179 -122
+2 -2
apps/bookmark.c
··· 259 259 snprintf(global_temp_buffer, sizeof(global_temp_buffer), 260 260 "%s.tmp", bookmark_file_name); 261 261 temp_bookmark_file = open(global_temp_buffer, 262 - O_WRONLY | O_CREAT | O_TRUNC); 262 + O_WRONLY | O_CREAT | O_TRUNC, 0666); 263 263 if (temp_bookmark_file < 0) 264 264 return false; /* can't open the temp file */ 265 265 ··· 814 814 snprintf(global_temp_buffer, sizeof(global_temp_buffer), 815 815 "%s.tmp", bookmark_file_name); 816 816 temp_bookmark_file = open(global_temp_buffer, 817 - O_WRONLY | O_CREAT | O_TRUNC); 817 + O_WRONLY | O_CREAT | O_TRUNC, 0666); 818 818 819 819 if (temp_bookmark_file < 0) 820 820 return false; /* can't open the temp file */
+20
apps/codecs.c
··· 73 73 74 74 extern void* plugin_get_audio_buffer(size_t *buffer_size); 75 75 76 + #undef open 77 + static int open(const char* pathname, int flags, ...) 78 + { 79 + #ifdef SIMULATOR 80 + int fd; 81 + if (flags & O_CREAT) 82 + { 83 + va_list ap; 84 + va_start(ap, flags); 85 + fd = sim_open(pathname, flags, va_arg(ap, mode_t)); 86 + va_end(ap); 87 + } 88 + else 89 + fd = sim_open(pathname, flags); 90 + 91 + return fd; 92 + #else 93 + return file_open(pathname, flags); 94 + #endif 95 + } 76 96 struct codec_api ci = { 77 97 78 98 0, /* filesize */
+1 -1
apps/codecs.h
··· 222 222 size_t (*enc_unget_pcm_data)(size_t size); 223 223 224 224 /* file */ 225 - int (*open)(const char* pathname, int flags); 225 + int (*open)(const char* pathname, int flags, ...); 226 226 int (*close)(int fd); 227 227 ssize_t (*read)(int fd, void* buf, size_t count); 228 228 off_t (*lseek)(int fd, off_t offset, int whence);
+1 -1
apps/codecs/aiff_enc.c
··· 136 136 if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0') 137 137 return false; 138 138 139 - data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC); 139 + data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666); 140 140 141 141 if (data->rec_file < 0) 142 142 return false;
+1 -1
apps/codecs/libcook/main.c
··· 171 171 /* output raw audio frames that are sent to the decoder into separate files */ 172 172 #ifdef DUMP_RAW_FRAMES 173 173 snprintf(filename,sizeof(filename),"dump%d.raw",++x); 174 - fd_out = open(filename,O_WRONLY|O_CREAT|O_APPEND); 174 + fd_out = open(filename,O_WRONLY|O_CREAT|O_APPEND, 0666); 175 175 write(fd_out,pkt.frames[i],sps); 176 176 close(fd_out); 177 177 #endif
+1 -1
apps/codecs/libffmpegFLAC/main.c
··· 62 62 int open_wav(char* filename) { 63 63 int fd; 64 64 65 - fd=open(filename,O_CREAT|O_WRONLY|O_TRUNC,S_IRUSR|S_IWUSR); 65 + fd=open(filename,O_CREAT|O_WRONLY|O_TRUNC, S_IRUSR|S_IWUSR); 66 66 if (fd >= 0) { 67 67 if (write(fd,wav_header,sizeof(wav_header)) < sizeof(wav_header)) { 68 68 fprintf(stderr,"[ERR} Failed to write wav header\n");
+1 -1
apps/codecs/libspc/spc_profiler.c
··· 45 45 46 46 void print_timers(char * path) 47 47 { 48 - int logfd = ci->open("/spclog.txt",O_WRONLY|O_CREAT|O_APPEND); 48 + int logfd = ci->open("/spclog.txt",O_WRONLY|O_CREAT|O_APPEND, 0666); 49 49 ci->fdprintf(logfd,"%s:\t",path); 50 50 ci->fdprintf(logfd,"%10ld total\t",READ_TIMER(total)); 51 51 PRINT_TIMER_PCT(render,total,"render");
+1 -1
apps/codecs/mp3_enc.c
··· 2434 2434 if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0') 2435 2435 return false; 2436 2436 2437 - data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC); 2437 + data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666); 2438 2438 2439 2439 if (data->rec_file < 0) 2440 2440 return false;
+1 -1
apps/codecs/nsf.c
··· 98 98 int logfd=-1; 99 99 100 100 void print_timers(char * path, int track) { 101 - logfd = ci->open("/nsflog.txt",O_WRONLY|O_CREAT|O_APPEND); 101 + logfd = ci->open("/nsflog.txt",O_WRONLY|O_CREAT|O_APPEND, 0666); 102 102 ci->fdprintf(logfd,"%s[%d]:\t",path,track); 103 103 ci->fdprintf(logfd,"%10ld total\t",READ_TIMER(total)); 104 104 PRINT_TIMER_PCT(cpu,total,"CPU");
+1 -1
apps/codecs/wav_enc.c
··· 122 122 if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0') 123 123 return false; 124 124 125 - data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC); 125 + data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666); 126 126 127 127 if (data->rec_file < 0) 128 128 return false;
+1 -1
apps/codecs/wavpack_enc.c
··· 227 227 if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0') 228 228 return false; 229 229 230 - data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC); 230 + data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666); 231 231 232 232 if (data->rec_file < 0) 233 233 return false;
+1 -1
apps/logfdisp.c
··· 233 233 /* nothing is logged just yet */ 234 234 return false; 235 235 236 - fd = open(ROCKBOX_DIR "/logf.txt", O_CREAT|O_WRONLY|O_TRUNC); 236 + fd = open(ROCKBOX_DIR "/logf.txt", O_CREAT|O_WRONLY|O_TRUNC, 0666); 237 237 if(-1 != fd) { 238 238 int i; 239 239
+1 -1
apps/mpeg.c
··· 1923 1923 1924 1924 if (mpeg_file < 0) /* delayed file open */ 1925 1925 { 1926 - mpeg_file = open(delayed_filename, O_WRONLY|O_CREAT); 1926 + mpeg_file = open(delayed_filename, O_WRONLY|O_CREAT, 0666); 1927 1927 1928 1928 if (mpeg_file < 0) 1929 1929 panicf("recfile: %d", mpeg_file);
+3 -3
apps/playlist.c
··· 336 336 static void create_control(struct playlist_info* playlist) 337 337 { 338 338 playlist->control_fd = open(playlist->control_filename, 339 - O_CREAT|O_RDWR|O_TRUNC); 339 + O_CREAT|O_RDWR|O_TRUNC, 0666); 340 340 if (playlist->control_fd < 0) 341 341 { 342 342 if (check_rockboxdir()) ··· 414 414 return -1; 415 415 416 416 playlist->control_fd = open(playlist->control_filename, 417 - O_CREAT|O_RDWR|O_TRUNC); 417 + O_CREAT|O_RDWR|O_TRUNC, 0666); 418 418 if (playlist->control_fd < 0) 419 419 return -1; 420 420 ··· 3375 3375 else 3376 3376 { 3377 3377 /* some applications require a BOM to read the file properly */ 3378 - fd = open(path, O_CREAT|O_WRONLY|O_TRUNC); 3378 + fd = open(path, O_CREAT|O_WRONLY|O_TRUNC, 0666); 3379 3379 } 3380 3380 if (fd < 0) 3381 3381 {
+1 -1
apps/playlist_catalog.c
··· 349 349 if (new_playlist) 350 350 fd = open_utf8(playlist, O_CREAT|O_WRONLY|O_TRUNC); 351 351 else 352 - fd = open(playlist, O_CREAT|O_WRONLY|O_APPEND); 352 + fd = open(playlist, O_CREAT|O_WRONLY|O_APPEND, 0666); 353 353 354 354 if(fd < 0) 355 355 return result;
+25 -9
apps/plugin.c
··· 93 93 94 94 char *plugin_get_current_filename(void); 95 95 96 - #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE 97 96 /* Some wrappers used to monitor open and close and detect leaks*/ 98 - static int open_wrapper(const char* pathname, int flags); 97 + static int open_wrapper(const char* pathname, int flags, ...); 98 + #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE 99 99 static int close_wrapper(int fd); 100 100 static int creat_wrapper(const char *pathname, mode_t mode); 101 101 #endif ··· 299 299 300 300 /* file */ 301 301 open_utf8, 302 - #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE 303 302 (open_func)open_wrapper, 303 + #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE 304 304 close_wrapper, 305 305 #else 306 - (open_func)PREFIX(open), 307 306 PREFIX(close), 308 - #endif 307 + #endif 309 308 (read_func)PREFIX(read), 310 309 PREFIX(lseek), 311 310 #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE ··· 979 978 return current_plugin; 980 979 } 981 980 982 - #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE 983 - static int open_wrapper(const char* pathname, int flags) 981 + static int open_wrapper(const char* pathname, int flags, ...) 984 982 { 985 - int fd = PREFIX(open)(pathname,flags); 983 + /* we don't have an 'open' function. it's a define. and we need 984 + * the real file_open, hence PREFIX() doesn't work here */ 985 + int fd; 986 + #ifdef SIMULATOR 987 + if (flags & O_CREAT) 988 + { 989 + va_list ap; 990 + va_start(ap, flags); 991 + int fd; 992 + fd = sim_open(pathname, flags, va_arg(ap, mode_t)); 993 + va_end(ap); 994 + } 995 + else 996 + fd = sim_open(pathname, flags); 997 + #else 998 + fd = file_open(pathname,flags); 999 + #endif 986 1000 1001 + #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE 987 1002 if(fd >= 0) 988 1003 open_files |= 1<<fd; 989 - 1004 + #endif 990 1005 return fd; 991 1006 } 992 1007 1008 + #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE 993 1009 static int close_wrapper(int fd) 994 1010 { 995 1011 if((~open_files) & (1<<fd))
+1 -1
apps/plugin.h
··· 397 397 398 398 /* file */ 399 399 int (*open_utf8)(const char* pathname, int flags); 400 - int (*open)(const char* pathname, int flags); 400 + int (*open)(const char* pathname, int flags, ...); 401 401 int (*close)(int fd); 402 402 ssize_t (*read)(int fd, void* buf, size_t count); 403 403 off_t (*lseek)(int fd, off_t offset, int whence);
+3 -3
apps/plugins/battery_bench.c
··· 336 336 if (in_usb_mode || (buf_idx == 0)) 337 337 return; 338 338 339 - fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT | O_APPEND); 339 + fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT | O_APPEND, 0666); 340 340 if (fd < 0) 341 341 return; 342 342 ··· 446 446 rb->unregister_storage_idle_func(flush_buffer, true); 447 447 448 448 /* log end of bench and exit reason */ 449 - fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT | O_APPEND); 449 + fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT | O_APPEND, 0666); 450 450 if (fd >= 0) 451 451 { 452 452 rb->fdprintf(fd, "--Battery bench ended, reason: %s--\n", exit_reason); ··· 525 525 fd = rb->open(BATTERY_LOG, O_RDONLY); 526 526 if (fd < 0) 527 527 { 528 - fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT); 528 + fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT, 0666); 529 529 if (fd >= 0) 530 530 { 531 531 rb->fdprintf(fd,
+1 -1
apps/plugins/blackjack.c
··· 871 871 if(!resume) 872 872 return; 873 873 /* write out the game state to the save file */ 874 - fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT); 874 + fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT, 0666); 875 875 if(fd < 0) 876 876 return; 877 877 rb->write(fd, bj, sizeof(struct game_context));
+1 -1
apps/plugins/brickmania.c
··· 1265 1265 int fd; 1266 1266 1267 1267 /* write out the game state to the save file */ 1268 - fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT); 1268 + fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT, 0666); 1269 1269 if(fd < 0) return; 1270 1270 1271 1271 if ((rb->write(fd, &pad_pos_x, sizeof(pad_pos_x)) <= 0) ||
+2 -2
apps/plugins/bubbles.c
··· 2212 2212 if (last_highlevel >= highlevel) /* no need to save */ 2213 2213 return; 2214 2214 2215 - fd = rb->open(DATA_FILE, O_WRONLY|O_CREAT); 2215 + fd = rb->open(DATA_FILE, O_WRONLY|O_CREAT, 0666); 2216 2216 if (fd < 0) return; 2217 2217 2218 2218 rb->write(fd, &highlevel, sizeof(highlevel)); ··· 2252 2252 if (!resume) /* nothing to save */ 2253 2253 return; 2254 2254 /* write out the game state to the save file */ 2255 - fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT); 2255 + fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT, 0666); 2256 2256 if (fd < 0) 2257 2257 { 2258 2258 rb->splash(HZ/2, "Failed to save game");
+1 -1
apps/plugins/calendar.c
··· 611 611 { 612 612 int fp, fq; 613 613 /* use O_RDWR|O_CREAT so that file is created if it doesn't exist. */ 614 - fp = rb->open(MEMO_FILE, O_RDWR|O_CREAT); 614 + fp = rb->open(MEMO_FILE, O_RDWR|O_CREAT, 0666); 615 615 fq = rb->creat(TEMP_FILE, 0666); 616 616 if ( (fq > -1) && (fp > -1) ) 617 617 {
+1 -1
apps/plugins/chessbox/chessbox.c
··· 275 275 276 276 rb->splash ( 0 , "Saving position" ); 277 277 278 - fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT); 278 + fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT, 0666); 279 279 280 280 computer++; rb->write(fd, &(computer), sizeof(computer)); computer--; 281 281 opponent++; rb->write(fd, &(opponent), sizeof(opponent)); opponent--;
+2 -2
apps/plugins/chessbox/chessbox_pgn.c
··· 670 670 rb->read_line(fhandler, line_buffer, sizeof line_buffer); 671 671 } 672 672 673 - loghandler = rb->open(LOG_FILE, O_WRONLY | O_CREAT); 673 + loghandler = rb->open(LOG_FILE, O_WRONLY | O_CREAT, 0666); 674 674 675 675 GNUChess_Initialize(); 676 676 ··· 829 829 ply_count++; 830 830 } 831 831 832 - fhandler = rb->open(PGN_FILE, O_WRONLY|O_CREAT|O_APPEND); 832 + fhandler = rb->open(PGN_FILE, O_WRONLY|O_CREAT|O_APPEND, 0666); 833 833 834 834 835 835 /* the first 7 tags are mandatory according to the PGN specification so we
+2 -2
apps/plugins/crypt_firmware.c
··· 246 246 memcpy(buf + 1, "nn2x", 4); 247 247 248 248 /* 4 - Write to disk */ 249 - fd = rb->open(outputfilename,O_WRONLY|O_CREAT|O_TRUNC); 249 + fd = rb->open(outputfilename,O_WRONLY|O_CREAT|O_TRUNC, 0666); 250 250 251 251 if (fd < 0) { 252 252 rb->splash(HZ*2, "Could not open output file"); ··· 307 307 memcpy(buf + 1, "nn2g", 4); 308 308 309 309 /* 4 - Write to disk */ 310 - fd = rb->open(outputfilename,O_WRONLY|O_CREAT|O_TRUNC); 310 + fd = rb->open(outputfilename,O_WRONLY|O_CREAT|O_TRUNC, 0666); 311 311 312 312 if (fd < 0) { 313 313 rb->splash(HZ*2, "Could not open output file");
+10 -3
apps/plugins/doom/rockdoom.c
··· 63 63 } 64 64 65 65 #ifndef SIMULATOR 66 - int my_open(const char *file, int flags) 66 + int my_open(const char *file, int flags, ...) 67 67 { 68 68 if(fpoint==8) 69 69 return -1; 70 70 #undef open 71 - filearray[fpoint]=rb->open(file, flags); 72 - 71 + if (flags & O_CREAT) 72 + { 73 + va_list ap; 74 + va_start(ap, flags); 75 + filearray[fpoint]=rb->open(file, flags, va_arg(ap, mode_t)); 76 + va_end(ap); 77 + } 78 + else 79 + filearray[fpoint]=rb->open(file, flags); 73 80 if(filearray[fpoint]<0) 74 81 return filearray[fpoint]; 75 82
+3 -3
apps/plugins/doom/rockmacros.h
··· 39 39 #define read_line(a,b,c) rb->read_line((a),(b),(c)) 40 40 41 41 #ifdef SIMULATOR 42 - #define open(a,b) rb->open((a),(b)) 42 + #define open(a, ...) rb->open((a), __VA_ARGS__) 43 43 #define close(a) rb->close((a)) 44 44 #else 45 - int my_open(const char *file, int flags); 45 + int my_open(const char *file, int flags, ...); 46 46 int my_close(int id); 47 - #define open(a,b) my_open((a),(b)) 47 + #define open(a, ...) my_open((a), __VA_ARGS__) 48 48 #define close(a) my_close((a)) 49 49 #endif 50 50
+2 -2
apps/plugins/frotz/fastmem.c
··· 837 837 838 838 /* Open auxilary file */ 839 839 840 - if ((gfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC)) < 0) 840 + if ((gfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) 841 841 goto finished; 842 842 843 843 /* Write auxilary file */ ··· 859 859 860 860 /* Open game file */ 861 861 862 - if ((gfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC)) < 0) 862 + if ((gfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) 863 863 goto finished; 864 864 865 865 success = save_quetzal (gfp, story_fp);
+2 -2
apps/plugins/frotz/files.c
··· 74 74 75 75 /* Opening in "at" mode doesn't work for script_erase_input... */ 76 76 77 - if ((sfp = rb->open (script_name, O_RDWR|O_CREAT)) != -1) { 77 + if ((sfp = rb->open (script_name, O_RDWR|O_CREAT, 0666)) != -1) { 78 78 79 79 fseek (sfp, 0, SEEK_END); 80 80 ··· 290 290 291 291 strcpy (command_name, new_name); 292 292 293 - if ((rfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC)) != -1) 293 + if ((rfp = rb->open (new_name, O_WRONLY|O_CREAT|O_TRUNC, 0666)) != -1) 294 294 ostream_record = TRUE; 295 295 else 296 296 print_string ("Cannot open file\n");
+1 -1
apps/plugins/jewels.c
··· 498 498 { 499 499 int fd; 500 500 /* write out the game state to the save file */ 501 - fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT); 501 + fd = rb->open(SAVE_FILE, O_WRONLY|O_CREAT, 0666); 502 502 if(fd < 0) return; 503 503 504 504 rb->write(fd, &bj->tmp_type, sizeof(bj->tmp_type));
+1 -1
apps/plugins/keybox.c
··· 584 584 585 585 if (data_changed) 586 586 { 587 - fd = rb->open(KEYBOX_FILE, O_WRONLY | O_CREAT | O_TRUNC); 587 + fd = rb->open(KEYBOX_FILE, O_WRONLY | O_CREAT | O_TRUNC, 0666); 588 588 if (fd < 0) 589 589 return FILE_OPEN_ERROR; 590 590 write_output(fd);
+1 -1
apps/plugins/lib/highscore.c
··· 33 33 if(!highscore_updated) 34 34 return 1; 35 35 36 - fd = rb->open(filename, O_WRONLY|O_CREAT); 36 + fd = rb->open(filename, O_WRONLY|O_CREAT, 0666); 37 37 if(fd < 0) 38 38 return -1; 39 39
+1 -1
apps/plugins/lua/liolib.c
··· 158 158 } 159 159 if((*mode == 'w' || *mode == 'a') && !rb->file_exists(filename)) 160 160 flags |= O_CREAT; 161 - *pf = rb->open(filename, flags); 161 + *pf = rb->open(filename, flags, 0666); 162 162 return (*pf < 0) ? pushresult(L, 0, filename) : 1; 163 163 } 164 164
+1 -1
apps/plugins/md5sum.c
··· 246 246 done = 0; 247 247 action( out, arg ); 248 248 249 - out = rb->open( filename, O_WRONLY|O_CREAT|O_TRUNC ); 249 + out = rb->open( filename, O_WRONLY|O_CREAT|O_TRUNC , 0666); 250 250 if( out < 0 ) return PLUGIN_ERROR; 251 251 action( out, arg ); 252 252 rb->close( out );
+1 -1
apps/plugins/mp3_encoder.c
··· 2598 2598 { 2599 2599 init_mp3_encoder_engine(true, brate[srat], cfg.samplerate); 2600 2600 get_mp3_filename(wav_filename); 2601 - mp3file = rb->open(mp3_name , O_WRONLY|O_CREAT|O_TRUNC); 2601 + mp3file = rb->open(mp3_name , O_WRONLY|O_CREAT|O_TRUNC, 0666); 2602 2602 frames = 0; 2603 2603 2604 2604 tim = *rb->current_tick;
-4
apps/plugins/pdbox/PDa/intern/sfwrite~.c
··· 91 91 92 92 sfwrite_close(x); 93 93 94 - #ifdef ROCKBOX 95 - if ((x->x_file = open(fname, O_RDWR | O_CREAT)) < 0) 96 - #else 97 94 if ((x->x_file = open(fname,O_RDWR | O_CREAT,0664)) < 0) 98 - #endif 99 95 { 100 96 error("can't create %s",fname); 101 97 return;
+2 -2
apps/plugins/pdbox/PDa/src/g_array.c
··· 1306 1306 buf, MAXPDSTRING); 1307 1307 sys_bashfilename(buf, buf); 1308 1308 #ifdef ROCKBOX 1309 - if(!(fd = open(buf, O_WRONLY|O_CREAT|O_TRUNC))) 1309 + if(!(fd = open(buf, O_WRONLY|O_CREAT|O_TRUNC, 0666))) 1310 1310 #else 1311 1311 if (!(fd = fopen(buf, "w"))) 1312 1312 #endif ··· 1388 1388 buf2, MAXPDSTRING); 1389 1389 sys_bashfilename(buf2, buf2); 1390 1390 #ifdef ROCKBOX 1391 - if(!(fd = open(buf2, O_WRONLY|O_CREAT|O_TRUNC))) 1391 + if(!(fd = open(buf2, O_WRONLY|O_CREAT|O_TRUNC, 0666))) 1392 1392 #else 1393 1393 if (!(fd = fopen(buf2, BINWRITEMODE))) 1394 1394 #endif
+1 -1
apps/plugins/random_folder_advance_config.c
··· 214 214 { 215 215 dirs_count = 0; 216 216 abort = false; 217 - fd = rb->open(RFA_FILE,O_CREAT|O_WRONLY); 217 + fd = rb->open(RFA_FILE,O_CREAT|O_WRONLY, 0666); 218 218 rb->write(fd,&dirs_count,sizeof(int)); 219 219 if (fd < 0) 220 220 {
+1 -1
apps/plugins/rockblox.c
··· 877 877 { 878 878 int fd; 879 879 880 - fd = rb->open(RESUME_FILE, O_WRONLY|O_CREAT); 880 + fd = rb->open(RESUME_FILE, O_WRONLY|O_CREAT, 0666); 881 881 if (fd < 0) 882 882 goto fail; 883 883
+1 -1
apps/plugins/rockboy/cpu.c
··· 947 947 int fd; 948 948 blockcount++; 949 949 snprintf(meow,499,"/dyna_0x%x_run.rb",PC); 950 - fd=open(meow,O_WRONLY|O_CREAT|O_TRUNC); 950 + fd=open(meow,O_WRONLY|O_CREAT|O_TRUNC, 0666); 951 951 if(fd>=0) 952 952 { 953 953 fdprintf(fd,"Block 0x%x Blockcount: %d\n",PC,blockcount);
+2 -2
apps/plugins/rockboy/dynarec.c
··· 425 425 newblock->block=dynapointer; 426 426 #ifdef DYNA_DEBUG 427 427 snprintf(meow,499,"/dyna_0x%x_asm.rb",PC); 428 - fd=open(meow,O_WRONLY|O_CREAT|O_TRUNC); 428 + fd=open(meow,O_WRONLY|O_CREAT|O_TRUNC, 0666); 429 429 if(fd<0) 430 430 { 431 431 die("couldn't open dyna debug file"); ··· 1907 1907 newblock->length=dynapointer-newblock->block; 1908 1908 IF_COP(rb->cpucache_invalidate()); 1909 1909 snprintf(meow,499,"/dyna_0x%x_code.rb",PC); 1910 - fd=open(meow,O_WRONLY|O_CREAT|O_TRUNC); 1910 + fd=open(meow,O_WRONLY|O_CREAT|O_TRUNC, 0666); 1911 1911 if(fd>=0) 1912 1912 { 1913 1913 write(fd,newblock->block,newblock->length);
+2 -2
apps/plugins/rockboy/loader.c
··· 249 249 /* If we crash before we ever loaded sram, DO NOT SAVE! */ 250 250 if (!mbc.batt || !ram.loaded || !mbc.ramsize) 251 251 return -1; 252 - fd = open(sramfile, O_WRONLY|O_CREAT|O_TRUNC); 252 + fd = open(sramfile, O_WRONLY|O_CREAT|O_TRUNC, 0666); 253 253 if (fd<0) return -1; 254 254 snprintf(meow,499,"Saving savedata to %s",sramfile); 255 255 rb->splash(HZ*2, meow); ··· 263 263 { 264 264 int fd; 265 265 if (!rtc.batt) return; 266 - if ((fd = open(rtcfile, O_WRONLY|O_CREAT|O_TRUNC))<0) return; 266 + if ((fd = open(rtcfile, O_WRONLY|O_CREAT|O_TRUNC, 0666))<0) return; 267 267 rtc_save_internal(fd); 268 268 close(fd); 269 269 }
+1 -1
apps/plugins/rockboy/menu.c
··· 178 178 file_mode = is_load ? O_RDONLY : (O_WRONLY | O_CREAT); 179 179 180 180 /* attempt to open file descriptor here */ 181 - if ((fd = open(path, file_mode)) < 0) 181 + if ((fd = open(path, file_mode, 0666)) < 0) 182 182 return false; 183 183 184 184 /* load/save state */
+1 -1
apps/plugins/rockboy/rockboy.c
··· 325 325 { 326 326 options.dirty=0; 327 327 snprintf(optionsave, sizeof(optionsave), "%s/%s", savedir, optionname); 328 - fd = open(optionsave, O_WRONLY|O_CREAT|O_TRUNC); 328 + fd = open(optionsave, O_WRONLY|O_CREAT|O_TRUNC, 0666); 329 329 write(fd,&options, sizeof(options)); 330 330 close(fd); 331 331 }
+3 -1
apps/plugins/rockboy/rockmacros.h
··· 59 59 #define isalpha(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && ((c) <= 'Z'))) 60 60 #define isalnum(c) (isdigit(c) || (isalpha(c))) 61 61 62 - #define open(a,b) rb->open((a),(b)) 62 + /* only 1 fixed argument for open, since variadic macros don't except empty 63 + * variable parameters */ 64 + #define open(a, ...) rb->open((a), __VA_ARGS__) 63 65 #define lseek(a,b,c) rb->lseek((a),(b),(c)) 64 66 #define close(a) rb->close((a)) 65 67 #define read(a,b,c) rb->read((a),(b),(c))
+1 -1
apps/plugins/search.c
··· 123 123 if (bomsize) 124 124 fdw = rb->open_utf8(resultfile, O_WRONLY|O_CREAT|O_TRUNC); 125 125 else 126 - fdw = rb->open(resultfile, O_WRONLY|O_CREAT|O_TRUNC); 126 + fdw = rb->open(resultfile, O_WRONLY|O_CREAT|O_TRUNC, 0666); 127 127 128 128 if (fdw < 0) { 129 129 #ifdef HAVE_LCD_BITMAP
+1 -1
apps/plugins/searchengine/searchengine.c
··· 78 78 rb->close(parsefd); 79 79 hits=0; 80 80 if(result!=0) { 81 - int fd=rb->open("/search.m3u", O_WRONLY|O_CREAT|O_TRUNC); 81 + int fd=rb->open("/search.m3u", O_WRONLY|O_CREAT|O_TRUNC, 0666); 82 82 int i; 83 83 for(i=0;i<rb->tagdbheader->filecount;i++) 84 84 if(result[i]) {
+1 -1
apps/plugins/settings_dumper.c
··· 124 124 int fd; 125 125 (void)parameter; 126 126 127 - fd = rb->open(FILENAME, O_CREAT|O_TRUNC|O_WRONLY); 127 + fd = rb->open(FILENAME, O_CREAT|O_TRUNC|O_WRONLY, 0666); 128 128 if (fd < 0) 129 129 return PLUGIN_ERROR; 130 130 list = rb->get_settings_list(&setting_count);
+1 -1
apps/plugins/sokoban.c
··· 1117 1117 } 1118 1118 1119 1119 if (filename[0] == '\0' || 1120 - (fd = rb->open(filename, O_WRONLY|O_CREAT|O_TRUNC)) < 0) { 1120 + (fd = rb->open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) { 1121 1121 rb->splashf(HZ*2, "Unable to open %s", filename); 1122 1122 return false; 1123 1123 }
+1 -1
apps/plugins/solitaire.c
··· 1272 1272 { 1273 1273 char buf[MAX_PATH]; 1274 1274 get_save_filename( buf ); 1275 - return rb->open( buf, flags ); 1275 + return rb->open( buf, flags, 0666); 1276 1276 } 1277 1277 1278 1278 void delete_save_file( void )
+1 -1
apps/plugins/sort.c
··· 147 147 if (bomsize) 148 148 fd = rb->open_utf8(tmpfilename, O_WRONLY|O_CREAT|O_TRUNC); 149 149 else 150 - fd = rb->open(tmpfilename, O_WRONLY|O_CREAT|O_TRUNC); 150 + fd = rb->open(tmpfilename, O_WRONLY|O_CREAT|O_TRUNC, 0666); 151 151 152 152 if(fd < 0) 153 153 return 10 * fd - 1;
+2 -2
apps/plugins/splitedit.c
··· 687 687 /* write the file 1 */ 688 688 if (file_name1 != NULL) 689 689 { 690 - file1 = rb->open (file_name1, O_WRONLY | O_CREAT); 690 + file1 = rb->open (file_name1, O_WRONLY | O_CREAT, 0666); 691 691 if (file1 >= 0) 692 692 { 693 693 int rc = copy_file(file1, src_file, end, y*2 + 1, y -1); ··· 727 727 if (file_name2 != NULL) 728 728 { 729 729 /* write file 2 */ 730 - file2 = rb->open (file_name2, O_WRONLY | O_CREAT); 730 + file2 = rb->open (file_name2, O_WRONLY | O_CREAT, 0666); 731 731 if (file2 >= 0) 732 732 { 733 733 end = mp3->filesize - end;
+1 -1
apps/plugins/stopwatch.c
··· 358 358 { 359 359 int fd; 360 360 361 - fd = rb->open(STOPWATCH_FILE, O_CREAT|O_WRONLY|O_TRUNC); 361 + fd = rb->open(STOPWATCH_FILE, O_CREAT|O_WRONLY|O_TRUNC, 0666); 362 362 363 363 if (fd < 0) 364 364 {
+1 -1
apps/plugins/sudoku/sudoku.c
··· 808 808 return false; 809 809 } 810 810 811 - fd=rb->open(state->filename, O_WRONLY|O_CREAT); 811 + fd=rb->open(state->filename, O_WRONLY|O_CREAT, 0666); 812 812 if (fd >= 0) { 813 813 for (r=0;r<9;r++) { 814 814 i=0;
+1 -1
apps/plugins/superdom.c
··· 626 626 return -1; 627 627 } 628 628 629 - fd = rb->open(savepath, O_WRONLY|O_CREAT); 629 + fd = rb->open(savepath, O_WRONLY|O_CREAT, 0666); 630 630 DEBUGF("savepath: %s\n", savepath); 631 631 if(fd < 0) { 632 632 DEBUGF("Couldn't create/open file\n");
+1 -1
apps/plugins/test_codec.c
··· 59 59 if (use_logfile) { 60 60 rb->create_numbered_filename(logfilename, "/", "test_codec_log_", ".txt", 61 61 2 IF_CNFN_NUM_(, NULL)); 62 - log_fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC); 62 + log_fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC, 0666); 63 63 return log_fd >= 0; 64 64 } 65 65
+1 -1
apps/plugins/test_disk.c
··· 85 85 86 86 rb->create_numbered_filename(logfilename, "/", "test_disk_log_", ".txt", 87 87 2 IF_CNFN_NUM_(, NULL)); 88 - log_fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC); 88 + log_fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC, 0666); 89 89 return log_fd >= 0; 90 90 } 91 91
+1 -1
apps/plugins/test_gfx.c
··· 47 47 48 48 rb->create_numbered_filename(logfilename, "/", "test_gfx_log_", ".txt", 49 49 2 IF_CNFN_NUM_(, NULL)); 50 - fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC); 50 + fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC, 0666); 51 51 return fd; 52 52 } 53 53
+1 -1
apps/plugins/test_grey.c
··· 237 237 case GREY_OK: 238 238 rb->create_numbered_filename(filename, "/", "test_grey_", 239 239 ".txt", 2 IF_CNFN_NUM_(, NULL)); 240 - fd = rb->open(filename, O_RDWR|O_CREAT|O_TRUNC); 240 + fd = rb->open(filename, O_RDWR|O_CREAT|O_TRUNC, 0666); 241 241 if (fd >= 0) 242 242 { 243 243 for (i = 0; i <= STEPS; i++)
+1 -1
apps/plugins/text_editor.c
··· 180 180 } 181 181 } 182 182 183 - fd = rb->open(filename,O_WRONLY|O_CREAT|O_TRUNC); 183 + fd = rb->open(filename,O_WRONLY|O_CREAT|O_TRUNC, 0666); 184 184 if (fd < 0) 185 185 { 186 186 newfile = true;
+1 -1
apps/plugins/theme_remove.c
··· 686 686 case 0: 687 687 if(create_log) 688 688 { 689 - log_fd = rb->open(LOG_FILENAME, O_WRONLY|O_CREAT|O_APPEND); 689 + log_fd = rb->open(LOG_FILENAME, O_WRONLY|O_CREAT|O_APPEND, 0666); 690 690 if(log_fd >= 0) 691 691 rb->fdprintf(log_fd, "---- %s ----\n", title); 692 692 else
+3 -3
apps/plugins/viewer.c
··· 2138 2138 2139 2139 static bool viewer_save_global_settings(void) 2140 2140 { 2141 - int sfd = rb->open(GLOBAL_SETTINGS_TMP_FILE, O_WRONLY|O_CREAT|O_TRUNC); 2141 + int sfd = rb->open(GLOBAL_SETTINGS_TMP_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0666); 2142 2142 unsigned char buf[GLOBAL_SETTINGS_H_SIZE]; 2143 2143 2144 2144 if (sfd < 0) ··· 2219 2219 if ((sfd = rb->open(SETTINGS_FILE, O_RDONLY)) < 0) 2220 2220 return false; 2221 2221 2222 - if ((tfd = rb->open(SETTINGS_TMP_FILE, O_WRONLY|O_CREAT|O_TRUNC)) < 0) 2222 + if ((tfd = rb->open(SETTINGS_TMP_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) 2223 2223 { 2224 2224 rb->close(sfd); 2225 2225 return false; ··· 2441 2441 bookmarks[bookmark_count-1].flag = BOOKMARK_LAST; 2442 2442 } 2443 2443 2444 - tfd = rb->open(SETTINGS_TMP_FILE, O_WRONLY|O_CREAT|O_TRUNC); 2444 + tfd = rb->open(SETTINGS_TMP_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0666); 2445 2445 if (tfd < 0) 2446 2446 return false; 2447 2447
+1 -1
apps/plugins/wavrecord.c
··· 3492 3492 {8, 32000}, {9, 44100}, {10, 48000} 3493 3493 }; 3494 3494 3495 - fd = rb->open(filename, O_RDWR|O_CREAT|O_TRUNC); 3495 + fd = rb->open(filename, O_RDWR|O_CREAT|O_TRUNC, 0666); 3496 3496 if (fd < 0) 3497 3497 { 3498 3498 rb->splash(2*HZ, "Couldn't create WAV file");
+2 -2
apps/plugins/zxbox/spsound.c
··· 223 223 224 224 #if 0 225 225 /* can use to save and later analyze what we produce */ 226 - i = rb->open ( "/sound.raw" , O_WRONLY | O_APPEND | O_CREAT ); 226 + i = rb->open ( "/sound.raw" , O_WRONLY | O_APPEND | O_CREAT, 0666); 227 227 rb->write ( i , sp_sound_buf , TMNUM ); 228 228 rb->close (i); 229 229 230 230 231 - i = rb->open ( "/sound2.raw" , O_WRONLY | O_APPEND |O_CREAT); 231 + i = rb->open ( "/sound2.raw" , O_WRONLY | O_APPEND |O_CREAT, 0666); 232 232 rb->write ( i , (unsigned char *)my_buf , TMNUM*4*3 ); 233 233 rb->close (i); 234 234 #endif
+1 -1
apps/scrobbler.c
··· 86 86 Check at each write since file may be deleted at any time */ 87 87 if(!file_exists(SCROBBLER_FILE)) 88 88 { 89 - fd = open(SCROBBLER_FILE, O_RDWR | O_CREAT); 89 + fd = open(SCROBBLER_FILE, O_RDWR | O_CREAT, 0666); 90 90 if(fd >= 0) 91 91 { 92 92 fdprintf(fd, "#AUDIOSCROBBLER/" SCROBBLER_VERSION "\n"
+2 -2
apps/settings.c
··· 193 193 max_len-NVRAM_DATA_START-1,0xffffffff); 194 194 memcpy(&buf[4],&crc32,4); 195 195 #ifndef HAVE_RTC_RAM 196 - fd = open(NVRAM_FILE,O_CREAT|O_TRUNC|O_WRONLY); 196 + fd = open(NVRAM_FILE,O_CREAT|O_TRUNC|O_WRONLY, 0666); 197 197 if (fd >= 0) 198 198 { 199 199 int len = write(fd,buf,max_len); ··· 532 532 int i; 533 533 int fd; 534 534 char value[MAX_PATH]; 535 - fd = open(filename,O_CREAT|O_TRUNC|O_WRONLY); 535 + fd = open(filename,O_CREAT|O_TRUNC|O_WRONLY, 0666); 536 536 if (fd < 0) 537 537 return false; 538 538 fdprintf(fd, "# .cfg file created by rockbox %s - "
+6 -6
apps/tagcache.c
··· 1705 1705 #ifdef SIMULATOR 1706 1706 /* Crude logging for the sim - to aid in debugging */ 1707 1707 int logfd = open(ROCKBOX_DIR "/database.log", 1708 - O_WRONLY | O_APPEND | O_CREAT); 1708 + O_WRONLY | O_APPEND | O_CREAT, 0666); 1709 1709 if (logfd >= 0) { 1710 1710 write(logfd, path, strlen(path)); 1711 1711 write(logfd, "\n", 1); ··· 2494 2494 * anything whether the index type is sorted or not. 2495 2495 */ 2496 2496 snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, index_type); 2497 - fd = open(buf, O_WRONLY | O_CREAT | O_TRUNC); 2497 + fd = open(buf, O_WRONLY | O_CREAT | O_TRUNC, 0666); 2498 2498 if (fd < 0) 2499 2499 { 2500 2500 logf("%s open fail", buf); ··· 2521 2521 if (masterfd < 0) 2522 2522 { 2523 2523 logf("Creating new DB"); 2524 - masterfd = open(TAGCACHE_FILE_MASTER, O_WRONLY | O_CREAT | O_TRUNC); 2524 + masterfd = open(TAGCACHE_FILE_MASTER, O_WRONLY | O_CREAT | O_TRUNC, 0666); 2525 2525 2526 2526 if (masterfd < 0) 2527 2527 { ··· 3447 3447 return false; 3448 3448 3449 3449 /* Initialize the changelog */ 3450 - clfd = open(TAGCACHE_FILE_CHANGELOG, O_WRONLY | O_CREAT | O_TRUNC); 3450 + clfd = open(TAGCACHE_FILE_CHANGELOG, O_WRONLY | O_CREAT | O_TRUNC, 0666); 3451 3451 if (clfd < 0) 3452 3452 { 3453 3453 logf("failure to open changelog"); ··· 3820 3820 if (!tc_stat.ramcache) 3821 3821 return false; 3822 3822 3823 - fd = open(TAGCACHE_STATEFILE, O_WRONLY | O_CREAT | O_TRUNC); 3823 + fd = open(TAGCACHE_STATEFILE, O_WRONLY | O_CREAT | O_TRUNC, 0666); 3824 3824 if (fd < 0) 3825 3825 { 3826 3826 logf("failed to create a statedump"); ··· 4252 4252 return ; 4253 4253 } 4254 4254 4255 - cachefd = open(TAGCACHE_FILE_TEMP, O_RDWR | O_CREAT | O_TRUNC); 4255 + cachefd = open(TAGCACHE_FILE_TEMP, O_RDWR | O_CREAT | O_TRUNC, 0666); 4256 4256 if (cachefd < 0) 4257 4257 { 4258 4258 logf("master file open failed: %s", TAGCACHE_FILE_TEMP);
+3 -3
bootloader/tpj1022.c
··· 63 63 64 64 #if 0 65 65 /* Dump the flash */ 66 - fd=open("/flash.bin",O_CREAT|O_RDWR); 66 + fd=open("/flash.bin",O_CREAT|O_RDWR, 0666); 67 67 write(fd,(char*)0,1024*1024); 68 68 close(fd); 69 69 #endif 70 70 71 71 #if 1 72 72 /* Dump what may be the framebuffer */ 73 - fd=open("/framebuffer.bin",O_CREAT|O_RDWR|O_TRUNC); 73 + fd=open("/framebuffer.bin",O_CREAT|O_RDWR|O_TRUNC, 0666); 74 74 write(fd,framebuffer,220*176*4); 75 75 close(fd); 76 76 #endif 77 77 78 78 79 - fd=open("/gpio.txt",O_CREAT|O_RDWR|O_TRUNC); 79 + fd=open("/gpio.txt",O_CREAT|O_RDWR|O_TRUNC, 0666); 80 80 unsigned int gpio_a = GPIOA_INPUT_VAL; 81 81 unsigned int gpio_b = GPIOB_INPUT_VAL; 82 82 unsigned int gpio_c = GPIOC_INPUT_VAL;
+1 -1
firmware/common/dircache.c
··· 557 557 return -1; 558 558 559 559 logf("Saving directory cache"); 560 - fd = open(DIRCACHE_FILE, O_WRONLY | O_CREAT | O_TRUNC); 560 + fd = open(DIRCACHE_FILE, O_WRONLY | O_CREAT | O_TRUNC, 0666); 561 561 562 562 maindata.magic = DIRCACHE_MAGIC; 563 563 maindata.size = dircache_size;
+2 -2
firmware/common/file.c
··· 57 57 58 58 int file_creat(const char *pathname) 59 59 { 60 - return open(pathname, O_WRONLY|O_CREAT|O_TRUNC); 60 + return open(pathname, O_WRONLY|O_CREAT|O_TRUNC, 0666); 61 61 } 62 62 63 63 static int open_internal(const char* pathname, int flags, bool use_cache) ··· 228 228 return fd; 229 229 } 230 230 231 - int open(const char* pathname, int flags) 231 + int file_open(const char* pathname, int flags) 232 232 { 233 233 /* By default, use the dircache if available. */ 234 234 return open_internal(pathname, flags, true);
+1 -1
firmware/font.c
··· 607 607 if (pf->fd >= 0 && pf == &font_ui) 608 608 { 609 609 #ifdef WPSEDITOR 610 - cache_fd = open(GLYPH_CACHE_FILE, O_WRONLY|O_CREAT|O_TRUNC); 610 + cache_fd = open(GLYPH_CACHE_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0666); 611 611 #else 612 612 cache_fd = creat(GLYPH_CACHE_FILE, 0666); 613 613 #endif
+7 -3
firmware/include/file.h
··· 49 49 #endif 50 50 51 51 #if defined(SIMULATOR) && !defined(PLUGIN) && !defined(CODEC) 52 - #define open(x,y) sim_open(x,y) 52 + #define open(x, ...) sim_open(x, __VA_ARGS__) 53 53 #define creat(x,m) sim_creat(x,m) 54 54 #define remove(x) sim_remove(x) 55 55 #define rename(x,y) sim_rename(x,y) ··· 61 61 #define write(x,y,z) sim_write(x,y,z) 62 62 #define close(x) sim_close(x) 63 63 extern int sim_creat(const char *pathname, mode_t mode); 64 + extern int sim_open(const char *pathname, int flags, ...); 64 65 #endif 65 66 66 - typedef int (*open_func)(const char* pathname, int flags); 67 + typedef int (*open_func)(const char* pathname, int flags, ...); 67 68 typedef ssize_t (*read_func)(int fd, void *buf, size_t count); 68 69 typedef int (*creat_func)(const char *pathname, mode_t mode); 69 70 typedef ssize_t (*write_func)(int fd, const void *buf, size_t count); 70 71 typedef void (*qsort_func)(void *base, size_t nmemb, size_t size, 71 72 int(*_compar)(const void *, const void *)); 72 73 73 - extern int open(const char* pathname, int flags); 74 + extern int file_open(const char* pathname, int flags); 74 75 extern int close(int fd); 75 76 extern int fsync(int fd); 76 77 extern ssize_t read(int fd, void *buf, size_t count); ··· 83 84 (void)mode; 84 85 return file_creat(pathname); 85 86 } 87 + #if !defined(CODEC) && !defined(PLUGIN) 88 + #define open(x, y, ...) file_open(x,y) 89 + #endif 86 90 #endif 87 91 extern ssize_t write(int fd, const void *buf, size_t count); 88 92 extern int remove(const char* pathname);
+1 -1
firmware/profile.c
··· 189 189 unsigned short current_index; 190 190 timer_unregister(); 191 191 profiling = PROF_OFF; 192 - fd = open("/profile.out", O_WRONLY|O_CREAT|O_TRUNC); 192 + fd = open("/profile.out", O_WRONLY|O_CREAT|O_TRUNC, 0666); 193 193 if (profiling_exit == PROF_ERROR) { 194 194 fdprintf(fd,"Profiling exited with an error.\n"); 195 195 fdprintf(fd,"Overflow or timer stolen most likely.\n");
+1 -1
firmware/target/sh/archos/recorder/powermgmt-recorder.c
··· 125 125 debug_file_close(); 126 126 } 127 127 else if (fd < 0) { 128 - fd = open(DEBUG_FILE_NAME, O_WRONLY | O_APPEND | O_CREAT); 128 + fd = open(DEBUG_FILE_NAME, O_WRONLY | O_APPEND | O_CREAT, 0666); 129 129 130 130 if (fd >= 0) { 131 131 snprintf(debug_message, DEBUG_MESSAGE_LEN,
+1 -1
firmware/test/fat/main.c
··· 356 356 for (j=0; j<5; j++) { 357 357 int num = 40960; 358 358 359 - fd = open(name,O_WRONLY|O_CREAT|O_APPEND); 359 + fd = open(name,O_WRONLY|O_CREAT|O_APPEND, 0666); 360 360 if (fd<0) { 361 361 DEBUGF("Failed opening file\n"); 362 362 return -1;
+17 -5
uisimulator/common/io.c
··· 106 106 #define READDIR(a) (_wreaddir)(a) 107 107 #define CLOSEDIR(a) (_wclosedir)(a) 108 108 #define STAT(a,b) (_wstat)(UTF8_TO_OS(a),b) 109 - #define OPEN(a,b,c) (_wopen)(UTF8_TO_OS(a),b,c) 109 + /* empty variable parameter list doesn't work for variadic macros, 110 + * so pretend the second parameter is variable too */ 111 + #define OPEN(a,...) (_wopen)(UTF8_TO_OS(a), __VA_ARGS__) 110 112 #define CLOSE(a) (close)(a) 111 113 #define REMOVE(a) (_wremove)(UTF8_TO_OS(a)) 112 114 #define RENAME(a,b) (_wrename)(UTF8_TO_OS(a),utf8_to_ucs2(b,convbuf2)) ··· 124 126 #define READDIR(a) (readdir)(a) 125 127 #define CLOSEDIR(a) (closedir)(a) 126 128 #define STAT(a,b) (stat)(a,b) 127 - #define OPEN(a,b,c) (open)(a,b,c) 129 + /* empty variable parameter list doesn't work for variadic macros, 130 + * so pretend the second parameter is variable too */ 131 + #define OPEN(a, ...) (open)(a, __VA_ARGS__) 128 132 #define CLOSE(x) (close)(x) 129 133 #define REMOVE(a) (remove)(a) 130 134 #define RENAME(a,b) (rename)(a,b) ··· 329 333 free(dir); 330 334 } 331 335 332 - int sim_open(const char *name, int o) 336 + int sim_open(const char *name, int o, ...) 333 337 { 334 338 int opts = rockbox2sim(o); 335 339 int ret; 336 - 337 340 if (num_openfiles >= MAX_OPEN_FILES) 338 341 return -2; 339 342 340 - ret = OPEN(get_sim_pathname(name), opts, 0666); 343 + if (o & O_CREAT) 344 + { 345 + va_list ap; 346 + va_start(ap, o); 347 + ret = OPEN(get_sim_pathname(name), opts, va_arg(ap, mode_t)); 348 + va_end(ap); 349 + } 350 + else 351 + ret = OPEN(get_sim_pathname(name), opts); 352 + 341 353 if (ret >= 0) 342 354 num_openfiles++; 343 355 return ret;