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
This commit is contained in:
parent
c61e89c0ed
commit
0a1d7c28b7
76 changed files with 179 additions and 122 deletions
|
@ -259,7 +259,7 @@ static bool add_bookmark(const char* bookmark_file_name, const char* bookmark,
|
|||
snprintf(global_temp_buffer, sizeof(global_temp_buffer),
|
||||
"%s.tmp", bookmark_file_name);
|
||||
temp_bookmark_file = open(global_temp_buffer,
|
||||
O_WRONLY | O_CREAT | O_TRUNC);
|
||||
O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (temp_bookmark_file < 0)
|
||||
return false; /* can't open the temp file */
|
||||
|
||||
|
@ -814,7 +814,7 @@ static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id)
|
|||
snprintf(global_temp_buffer, sizeof(global_temp_buffer),
|
||||
"%s.tmp", bookmark_file_name);
|
||||
temp_bookmark_file = open(global_temp_buffer,
|
||||
O_WRONLY | O_CREAT | O_TRUNC);
|
||||
O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
|
||||
if (temp_bookmark_file < 0)
|
||||
return false; /* can't open the temp file */
|
||||
|
|
|
@ -73,6 +73,26 @@ size_t codec_size;
|
|||
|
||||
extern void* plugin_get_audio_buffer(size_t *buffer_size);
|
||||
|
||||
#undef open
|
||||
static int open(const char* pathname, int flags, ...)
|
||||
{
|
||||
#ifdef SIMULATOR
|
||||
int fd;
|
||||
if (flags & O_CREAT)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, flags);
|
||||
fd = sim_open(pathname, flags, va_arg(ap, mode_t));
|
||||
va_end(ap);
|
||||
}
|
||||
else
|
||||
fd = sim_open(pathname, flags);
|
||||
|
||||
return fd;
|
||||
#else
|
||||
return file_open(pathname, flags);
|
||||
#endif
|
||||
}
|
||||
struct codec_api ci = {
|
||||
|
||||
0, /* filesize */
|
||||
|
|
|
@ -222,7 +222,7 @@ struct codec_api {
|
|||
size_t (*enc_unget_pcm_data)(size_t size);
|
||||
|
||||
/* file */
|
||||
int (*open)(const char* pathname, int flags);
|
||||
int (*open)(const char* pathname, int flags, ...);
|
||||
int (*close)(int fd);
|
||||
ssize_t (*read)(int fd, void* buf, size_t count);
|
||||
off_t (*lseek)(int fd, off_t offset, int whence);
|
||||
|
|
|
@ -136,7 +136,7 @@ static bool on_start_file(struct enc_file_event_data *data)
|
|||
if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0')
|
||||
return false;
|
||||
|
||||
data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC);
|
||||
data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666);
|
||||
|
||||
if (data->rec_file < 0)
|
||||
return false;
|
||||
|
|
|
@ -171,7 +171,7 @@ int main(int argc, char *argv[])
|
|||
/* output raw audio frames that are sent to the decoder into separate files */
|
||||
#ifdef DUMP_RAW_FRAMES
|
||||
snprintf(filename,sizeof(filename),"dump%d.raw",++x);
|
||||
fd_out = open(filename,O_WRONLY|O_CREAT|O_APPEND);
|
||||
fd_out = open(filename,O_WRONLY|O_CREAT|O_APPEND, 0666);
|
||||
write(fd_out,pkt.frames[i],sps);
|
||||
close(fd_out);
|
||||
#endif
|
||||
|
|
|
@ -62,7 +62,7 @@ static unsigned char wav_header[44]={
|
|||
int open_wav(char* filename) {
|
||||
int fd;
|
||||
|
||||
fd=open(filename,O_CREAT|O_WRONLY|O_TRUNC,S_IRUSR|S_IWUSR);
|
||||
fd=open(filename,O_CREAT|O_WRONLY|O_TRUNC, S_IRUSR|S_IWUSR);
|
||||
if (fd >= 0) {
|
||||
if (write(fd,wav_header,sizeof(wav_header)) < sizeof(wav_header)) {
|
||||
fprintf(stderr,"[ERR} Failed to write wav header\n");
|
||||
|
|
|
@ -45,7 +45,7 @@ void reset_profile_timers(void)
|
|||
|
||||
void print_timers(char * path)
|
||||
{
|
||||
int logfd = ci->open("/spclog.txt",O_WRONLY|O_CREAT|O_APPEND);
|
||||
int logfd = ci->open("/spclog.txt",O_WRONLY|O_CREAT|O_APPEND, 0666);
|
||||
ci->fdprintf(logfd,"%s:\t",path);
|
||||
ci->fdprintf(logfd,"%10ld total\t",READ_TIMER(total));
|
||||
PRINT_TIMER_PCT(render,total,"render");
|
||||
|
|
|
@ -2434,7 +2434,7 @@ static bool on_start_file(struct enc_file_event_data *data)
|
|||
if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0')
|
||||
return false;
|
||||
|
||||
data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC);
|
||||
data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666);
|
||||
|
||||
if (data->rec_file < 0)
|
||||
return false;
|
||||
|
|
|
@ -98,7 +98,7 @@ void reset_profile_timers(void) {
|
|||
int logfd=-1;
|
||||
|
||||
void print_timers(char * path, int track) {
|
||||
logfd = ci->open("/nsflog.txt",O_WRONLY|O_CREAT|O_APPEND);
|
||||
logfd = ci->open("/nsflog.txt",O_WRONLY|O_CREAT|O_APPEND, 0666);
|
||||
ci->fdprintf(logfd,"%s[%d]:\t",path,track);
|
||||
ci->fdprintf(logfd,"%10ld total\t",READ_TIMER(total));
|
||||
PRINT_TIMER_PCT(cpu,total,"CPU");
|
||||
|
|
|
@ -122,7 +122,7 @@ static bool on_start_file(struct enc_file_event_data *data)
|
|||
if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0')
|
||||
return false;
|
||||
|
||||
data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC);
|
||||
data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666);
|
||||
|
||||
if (data->rec_file < 0)
|
||||
return false;
|
||||
|
|
|
@ -227,7 +227,7 @@ static bool on_start_file(struct enc_file_event_data *data)
|
|||
if ((data->chunk->flags & CHUNKF_ERROR) || *data->filename == '\0')
|
||||
return false;
|
||||
|
||||
data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC);
|
||||
data->rec_file = ci->open(data->filename, O_RDWR|O_CREAT|O_TRUNC, 0666);
|
||||
|
||||
if (data->rec_file < 0)
|
||||
return false;
|
||||
|
|
|
@ -233,7 +233,7 @@ bool logfdump(void)
|
|||
/* nothing is logged just yet */
|
||||
return false;
|
||||
|
||||
fd = open(ROCKBOX_DIR "/logf.txt", O_CREAT|O_WRONLY|O_TRUNC);
|
||||
fd = open(ROCKBOX_DIR "/logf.txt", O_CREAT|O_WRONLY|O_TRUNC, 0666);
|
||||
if(-1 != fd) {
|
||||
int i;
|
||||
|
||||
|
|
|
@ -1923,7 +1923,7 @@ static void mpeg_thread(void)
|
|||
|
||||
if (mpeg_file < 0) /* delayed file open */
|
||||
{
|
||||
mpeg_file = open(delayed_filename, O_WRONLY|O_CREAT);
|
||||
mpeg_file = open(delayed_filename, O_WRONLY|O_CREAT, 0666);
|
||||
|
||||
if (mpeg_file < 0)
|
||||
panicf("recfile: %d", mpeg_file);
|
||||
|
|
|
@ -336,7 +336,7 @@ static void new_playlist(struct playlist_info* playlist, const char *dir,
|
|||
static void create_control(struct playlist_info* playlist)
|
||||
{
|
||||
playlist->control_fd = open(playlist->control_filename,
|
||||
O_CREAT|O_RDWR|O_TRUNC);
|
||||
O_CREAT|O_RDWR|O_TRUNC, 0666);
|
||||
if (playlist->control_fd < 0)
|
||||
{
|
||||
if (check_rockboxdir())
|
||||
|
@ -414,7 +414,7 @@ static int recreate_control(struct playlist_info* playlist)
|
|||
return -1;
|
||||
|
||||
playlist->control_fd = open(playlist->control_filename,
|
||||
O_CREAT|O_RDWR|O_TRUNC);
|
||||
O_CREAT|O_RDWR|O_TRUNC, 0666);
|
||||
if (playlist->control_fd < 0)
|
||||
return -1;
|
||||
|
||||
|
@ -3375,7 +3375,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
|
|||
else
|
||||
{
|
||||
/* some applications require a BOM to read the file properly */
|
||||
fd = open(path, O_CREAT|O_WRONLY|O_TRUNC);
|
||||
fd = open(path, O_CREAT|O_WRONLY|O_TRUNC, 0666);
|
||||
}
|
||||
if (fd < 0)
|
||||
{
|
||||
|
|
|
@ -349,7 +349,7 @@ static int add_to_playlist(const char* playlist, bool new_playlist,
|
|||
if (new_playlist)
|
||||
fd = open_utf8(playlist, O_CREAT|O_WRONLY|O_TRUNC);
|
||||
else
|
||||
fd = open(playlist, O_CREAT|O_WRONLY|O_APPEND);
|
||||
fd = open(playlist, O_CREAT|O_WRONLY|O_APPEND, 0666);
|
||||
|
||||
if(fd < 0)
|
||||
return result;
|
||||
|
|
|
@ -93,9 +93,9 @@ static char current_plugin[MAX_PATH];
|
|||
|
||||
char *plugin_get_current_filename(void);
|
||||
|
||||
#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
|
||||
/* Some wrappers used to monitor open and close and detect leaks*/
|
||||
static int open_wrapper(const char* pathname, int flags);
|
||||
static int open_wrapper(const char* pathname, int flags, ...);
|
||||
#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
|
||||
static int close_wrapper(int fd);
|
||||
static int creat_wrapper(const char *pathname, mode_t mode);
|
||||
#endif
|
||||
|
@ -299,13 +299,12 @@ static const struct plugin_api rockbox_api = {
|
|||
|
||||
/* file */
|
||||
open_utf8,
|
||||
#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
|
||||
(open_func)open_wrapper,
|
||||
#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
|
||||
close_wrapper,
|
||||
#else
|
||||
(open_func)PREFIX(open),
|
||||
PREFIX(close),
|
||||
#endif
|
||||
#endif
|
||||
(read_func)PREFIX(read),
|
||||
PREFIX(lseek),
|
||||
#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
|
||||
|
@ -979,17 +978,34 @@ char *plugin_get_current_filename(void)
|
|||
return current_plugin;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
|
||||
static int open_wrapper(const char* pathname, int flags)
|
||||
static int open_wrapper(const char* pathname, int flags, ...)
|
||||
{
|
||||
int fd = PREFIX(open)(pathname,flags);
|
||||
/* we don't have an 'open' function. it's a define. and we need
|
||||
* the real file_open, hence PREFIX() doesn't work here */
|
||||
int fd;
|
||||
#ifdef SIMULATOR
|
||||
if (flags & O_CREAT)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, flags);
|
||||
int fd;
|
||||
fd = sim_open(pathname, flags, va_arg(ap, mode_t));
|
||||
va_end(ap);
|
||||
}
|
||||
else
|
||||
fd = sim_open(pathname, flags);
|
||||
#else
|
||||
fd = file_open(pathname,flags);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
|
||||
if(fd >= 0)
|
||||
open_files |= 1<<fd;
|
||||
|
||||
#endif
|
||||
return fd;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
|
||||
static int close_wrapper(int fd)
|
||||
{
|
||||
if((~open_files) & (1<<fd))
|
||||
|
|
|
@ -397,7 +397,7 @@ struct plugin_api {
|
|||
|
||||
/* file */
|
||||
int (*open_utf8)(const char* pathname, int flags);
|
||||
int (*open)(const char* pathname, int flags);
|
||||
int (*open)(const char* pathname, int flags, ...);
|
||||
int (*close)(int fd);
|
||||
ssize_t (*read)(int fd, void* buf, size_t count);
|
||||
off_t (*lseek)(int fd, off_t offset, int whence);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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) ||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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) )
|
||||
{
|
||||
|
|
|
@ -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--;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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++)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -86,7 +86,7 @@ static void write_cache(void)
|
|||
Check at each write since file may be deleted at any time */
|
||||
if(!file_exists(SCROBBLER_FILE))
|
||||
{
|
||||
fd = open(SCROBBLER_FILE, O_RDWR | O_CREAT);
|
||||
fd = open(SCROBBLER_FILE, O_RDWR | O_CREAT, 0666);
|
||||
if(fd >= 0)
|
||||
{
|
||||
fdprintf(fd, "#AUDIOSCROBBLER/" SCROBBLER_VERSION "\n"
|
||||
|
|
|
@ -193,7 +193,7 @@ static bool write_nvram_data(char* buf, int max_len)
|
|||
max_len-NVRAM_DATA_START-1,0xffffffff);
|
||||
memcpy(&buf[4],&crc32,4);
|
||||
#ifndef HAVE_RTC_RAM
|
||||
fd = open(NVRAM_FILE,O_CREAT|O_TRUNC|O_WRONLY);
|
||||
fd = open(NVRAM_FILE,O_CREAT|O_TRUNC|O_WRONLY, 0666);
|
||||
if (fd >= 0)
|
||||
{
|
||||
int len = write(fd,buf,max_len);
|
||||
|
@ -532,7 +532,7 @@ static bool settings_write_config(const char* filename, int options)
|
|||
int i;
|
||||
int fd;
|
||||
char value[MAX_PATH];
|
||||
fd = open(filename,O_CREAT|O_TRUNC|O_WRONLY);
|
||||
fd = open(filename,O_CREAT|O_TRUNC|O_WRONLY, 0666);
|
||||
if (fd < 0)
|
||||
return false;
|
||||
fdprintf(fd, "# .cfg file created by rockbox %s - "
|
||||
|
|
|
@ -1705,7 +1705,7 @@ static void __attribute__ ((noinline)) add_tagcache(char *path,
|
|||
#ifdef SIMULATOR
|
||||
/* Crude logging for the sim - to aid in debugging */
|
||||
int logfd = open(ROCKBOX_DIR "/database.log",
|
||||
O_WRONLY | O_APPEND | O_CREAT);
|
||||
O_WRONLY | O_APPEND | O_CREAT, 0666);
|
||||
if (logfd >= 0) {
|
||||
write(logfd, path, strlen(path));
|
||||
write(logfd, "\n", 1);
|
||||
|
@ -2494,7 +2494,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
|
|||
* anything whether the index type is sorted or not.
|
||||
*/
|
||||
snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, index_type);
|
||||
fd = open(buf, O_WRONLY | O_CREAT | O_TRUNC);
|
||||
fd = open(buf, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (fd < 0)
|
||||
{
|
||||
logf("%s open fail", buf);
|
||||
|
@ -2521,7 +2521,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
|
|||
if (masterfd < 0)
|
||||
{
|
||||
logf("Creating new DB");
|
||||
masterfd = open(TAGCACHE_FILE_MASTER, O_WRONLY | O_CREAT | O_TRUNC);
|
||||
masterfd = open(TAGCACHE_FILE_MASTER, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
|
||||
if (masterfd < 0)
|
||||
{
|
||||
|
@ -3447,7 +3447,7 @@ bool tagcache_create_changelog(struct tagcache_search *tcs)
|
|||
return false;
|
||||
|
||||
/* Initialize the changelog */
|
||||
clfd = open(TAGCACHE_FILE_CHANGELOG, O_WRONLY | O_CREAT | O_TRUNC);
|
||||
clfd = open(TAGCACHE_FILE_CHANGELOG, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (clfd < 0)
|
||||
{
|
||||
logf("failure to open changelog");
|
||||
|
@ -3820,7 +3820,7 @@ static bool tagcache_dumpsave(void)
|
|||
if (!tc_stat.ramcache)
|
||||
return false;
|
||||
|
||||
fd = open(TAGCACHE_STATEFILE, O_WRONLY | O_CREAT | O_TRUNC);
|
||||
fd = open(TAGCACHE_STATEFILE, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (fd < 0)
|
||||
{
|
||||
logf("failed to create a statedump");
|
||||
|
@ -4252,7 +4252,7 @@ void tagcache_build(const char *path)
|
|||
return ;
|
||||
}
|
||||
|
||||
cachefd = open(TAGCACHE_FILE_TEMP, O_RDWR | O_CREAT | O_TRUNC);
|
||||
cachefd = open(TAGCACHE_FILE_TEMP, O_RDWR | O_CREAT | O_TRUNC, 0666);
|
||||
if (cachefd < 0)
|
||||
{
|
||||
logf("master file open failed: %s", TAGCACHE_FILE_TEMP);
|
||||
|
|
|
@ -63,20 +63,20 @@ void* main(void)
|
|||
|
||||
#if 0
|
||||
/* Dump the flash */
|
||||
fd=open("/flash.bin",O_CREAT|O_RDWR);
|
||||
fd=open("/flash.bin",O_CREAT|O_RDWR, 0666);
|
||||
write(fd,(char*)0,1024*1024);
|
||||
close(fd);
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
/* Dump what may be the framebuffer */
|
||||
fd=open("/framebuffer.bin",O_CREAT|O_RDWR|O_TRUNC);
|
||||
fd=open("/framebuffer.bin",O_CREAT|O_RDWR|O_TRUNC, 0666);
|
||||
write(fd,framebuffer,220*176*4);
|
||||
close(fd);
|
||||
#endif
|
||||
|
||||
|
||||
fd=open("/gpio.txt",O_CREAT|O_RDWR|O_TRUNC);
|
||||
fd=open("/gpio.txt",O_CREAT|O_RDWR|O_TRUNC, 0666);
|
||||
unsigned int gpio_a = GPIOA_INPUT_VAL;
|
||||
unsigned int gpio_b = GPIOB_INPUT_VAL;
|
||||
unsigned int gpio_c = GPIOC_INPUT_VAL;
|
||||
|
|
|
@ -557,7 +557,7 @@ int dircache_save(void)
|
|||
return -1;
|
||||
|
||||
logf("Saving directory cache");
|
||||
fd = open(DIRCACHE_FILE, O_WRONLY | O_CREAT | O_TRUNC);
|
||||
fd = open(DIRCACHE_FILE, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
|
||||
maindata.magic = DIRCACHE_MAGIC;
|
||||
maindata.size = dircache_size;
|
||||
|
|
|
@ -57,7 +57,7 @@ static int flush_cache(int fd);
|
|||
|
||||
int file_creat(const char *pathname)
|
||||
{
|
||||
return open(pathname, O_WRONLY|O_CREAT|O_TRUNC);
|
||||
return open(pathname, O_WRONLY|O_CREAT|O_TRUNC, 0666);
|
||||
}
|
||||
|
||||
static int open_internal(const char* pathname, int flags, bool use_cache)
|
||||
|
@ -228,7 +228,7 @@ static int open_internal(const char* pathname, int flags, bool use_cache)
|
|||
return fd;
|
||||
}
|
||||
|
||||
int open(const char* pathname, int flags)
|
||||
int file_open(const char* pathname, int flags)
|
||||
{
|
||||
/* By default, use the dircache if available. */
|
||||
return open_internal(pathname, flags, true);
|
||||
|
|
|
@ -607,7 +607,7 @@ void glyph_cache_save(struct font* pf)
|
|||
if (pf->fd >= 0 && pf == &font_ui)
|
||||
{
|
||||
#ifdef WPSEDITOR
|
||||
cache_fd = open(GLYPH_CACHE_FILE, O_WRONLY|O_CREAT|O_TRUNC);
|
||||
cache_fd = open(GLYPH_CACHE_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0666);
|
||||
#else
|
||||
cache_fd = creat(GLYPH_CACHE_FILE, 0666);
|
||||
#endif
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#endif
|
||||
|
||||
#if defined(SIMULATOR) && !defined(PLUGIN) && !defined(CODEC)
|
||||
#define open(x,y) sim_open(x,y)
|
||||
#define open(x, ...) sim_open(x, __VA_ARGS__)
|
||||
#define creat(x,m) sim_creat(x,m)
|
||||
#define remove(x) sim_remove(x)
|
||||
#define rename(x,y) sim_rename(x,y)
|
||||
|
@ -61,16 +61,17 @@
|
|||
#define write(x,y,z) sim_write(x,y,z)
|
||||
#define close(x) sim_close(x)
|
||||
extern int sim_creat(const char *pathname, mode_t mode);
|
||||
extern int sim_open(const char *pathname, int flags, ...);
|
||||
#endif
|
||||
|
||||
typedef int (*open_func)(const char* pathname, int flags);
|
||||
typedef int (*open_func)(const char* pathname, int flags, ...);
|
||||
typedef ssize_t (*read_func)(int fd, void *buf, size_t count);
|
||||
typedef int (*creat_func)(const char *pathname, mode_t mode);
|
||||
typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
|
||||
typedef void (*qsort_func)(void *base, size_t nmemb, size_t size,
|
||||
int(*_compar)(const void *, const void *));
|
||||
|
||||
extern int open(const char* pathname, int flags);
|
||||
extern int file_open(const char* pathname, int flags);
|
||||
extern int close(int fd);
|
||||
extern int fsync(int fd);
|
||||
extern ssize_t read(int fd, void *buf, size_t count);
|
||||
|
@ -83,6 +84,9 @@ static inline int creat(const char *pathname, mode_t mode)
|
|||
(void)mode;
|
||||
return file_creat(pathname);
|
||||
}
|
||||
#if !defined(CODEC) && !defined(PLUGIN)
|
||||
#define open(x, y, ...) file_open(x,y)
|
||||
#endif
|
||||
#endif
|
||||
extern ssize_t write(int fd, const void *buf, size_t count);
|
||||
extern int remove(const char* pathname);
|
||||
|
|
|
@ -189,7 +189,7 @@ void profstop() {
|
|||
unsigned short current_index;
|
||||
timer_unregister();
|
||||
profiling = PROF_OFF;
|
||||
fd = open("/profile.out", O_WRONLY|O_CREAT|O_TRUNC);
|
||||
fd = open("/profile.out", O_WRONLY|O_CREAT|O_TRUNC, 0666);
|
||||
if (profiling_exit == PROF_ERROR) {
|
||||
fdprintf(fd,"Profiling exited with an error.\n");
|
||||
fdprintf(fd,"Overflow or timer stolen most likely.\n");
|
||||
|
|
|
@ -125,7 +125,7 @@ static void debug_file_log(void)
|
|||
debug_file_close();
|
||||
}
|
||||
else if (fd < 0) {
|
||||
fd = open(DEBUG_FILE_NAME, O_WRONLY | O_APPEND | O_CREAT);
|
||||
fd = open(DEBUG_FILE_NAME, O_WRONLY | O_APPEND | O_CREAT, 0666);
|
||||
|
||||
if (fd >= 0) {
|
||||
snprintf(debug_message, DEBUG_MESSAGE_LEN,
|
||||
|
|
|
@ -356,7 +356,7 @@ int dbg_test(char* name)
|
|||
for (j=0; j<5; j++) {
|
||||
int num = 40960;
|
||||
|
||||
fd = open(name,O_WRONLY|O_CREAT|O_APPEND);
|
||||
fd = open(name,O_WRONLY|O_CREAT|O_APPEND, 0666);
|
||||
if (fd<0) {
|
||||
DEBUGF("Failed opening file\n");
|
||||
return -1;
|
||||
|
|
|
@ -106,7 +106,9 @@ extern int _wrmdir(const wchar_t*);
|
|||
#define READDIR(a) (_wreaddir)(a)
|
||||
#define CLOSEDIR(a) (_wclosedir)(a)
|
||||
#define STAT(a,b) (_wstat)(UTF8_TO_OS(a),b)
|
||||
#define OPEN(a,b,c) (_wopen)(UTF8_TO_OS(a),b,c)
|
||||
/* empty variable parameter list doesn't work for variadic macros,
|
||||
* so pretend the second parameter is variable too */
|
||||
#define OPEN(a,...) (_wopen)(UTF8_TO_OS(a), __VA_ARGS__)
|
||||
#define CLOSE(a) (close)(a)
|
||||
#define REMOVE(a) (_wremove)(UTF8_TO_OS(a))
|
||||
#define RENAME(a,b) (_wrename)(UTF8_TO_OS(a),utf8_to_ucs2(b,convbuf2))
|
||||
|
@ -124,7 +126,9 @@ extern int _wrmdir(const wchar_t*);
|
|||
#define READDIR(a) (readdir)(a)
|
||||
#define CLOSEDIR(a) (closedir)(a)
|
||||
#define STAT(a,b) (stat)(a,b)
|
||||
#define OPEN(a,b,c) (open)(a,b,c)
|
||||
/* empty variable parameter list doesn't work for variadic macros,
|
||||
* so pretend the second parameter is variable too */
|
||||
#define OPEN(a, ...) (open)(a, __VA_ARGS__)
|
||||
#define CLOSE(x) (close)(x)
|
||||
#define REMOVE(a) (remove)(a)
|
||||
#define RENAME(a,b) (rename)(a,b)
|
||||
|
@ -329,15 +333,23 @@ void sim_closedir(MYDIR *dir)
|
|||
free(dir);
|
||||
}
|
||||
|
||||
int sim_open(const char *name, int o)
|
||||
int sim_open(const char *name, int o, ...)
|
||||
{
|
||||
int opts = rockbox2sim(o);
|
||||
int ret;
|
||||
|
||||
if (num_openfiles >= MAX_OPEN_FILES)
|
||||
return -2;
|
||||
|
||||
ret = OPEN(get_sim_pathname(name), opts, 0666);
|
||||
if (o & O_CREAT)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, o);
|
||||
ret = OPEN(get_sim_pathname(name), opts, va_arg(ap, mode_t));
|
||||
va_end(ap);
|
||||
}
|
||||
else
|
||||
ret = OPEN(get_sim_pathname(name), opts);
|
||||
|
||||
if (ret >= 0)
|
||||
num_openfiles++;
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue