summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-05-06 17:35:04 +0000
committerThomas Martitz <kugel@rockbox.org>2010-05-06 17:35:04 +0000
commitc61e89c0eda126c2c1a4a3983520c35fe30db156 (patch)
tree1285f8cbde5485f93f8653f31ea0454587dd741e
parent684c70bac5f27e8dec49e113563cf6e496da854d (diff)
downloadrockbox-c61e89c0eda126c2c1a4a3983520c35fe30db156.tar.gz
rockbox-c61e89c0eda126c2c1a4a3983520c35fe30db156.zip
Make creat() posix compliant API-wise. Shouldn't affect the core as it's wrapped via a static inline.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25843 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/debug_menu.c22
-rw-r--r--apps/onplay.c2
-rw-r--r--apps/plugin.c6
-rw-r--r--apps/plugin.h2
-rw-r--r--apps/plugins/calendar.c2
-rw-r--r--apps/plugins/clock/clock_settings.c2
-rw-r--r--apps/plugins/disktidy.c2
-rw-r--r--apps/plugins/goban/util.c2
-rw-r--r--apps/plugins/iriverify.c2
-rw-r--r--apps/plugins/lib/configfile.c2
-rw-r--r--apps/plugins/lib/pluginlib_bmp.c2
-rw-r--r--apps/plugins/pictureflow/pictureflow.c2
-rw-r--r--apps/plugins/pitch_detector.c2
-rw-r--r--apps/plugins/random_folder_advance_config.c4
-rw-r--r--apps/plugins/shortcuts/shortcuts_common.c2
-rw-r--r--apps/plugins/test_codec.c2
-rw-r--r--apps/plugins/test_disk.c6
-rw-r--r--apps/plugins/vbrfix.c2
-rw-r--r--apps/plugins/vu_meter.c2
-rw-r--r--apps/plugins/wav2wv.c2
-rw-r--r--apps/plugins/zxbox/snapshot.c2
-rw-r--r--apps/recorder/radio.c2
-rw-r--r--bootloader/gigabeat-s.c2
-rw-r--r--firmware/common/file.c2
-rw-r--r--firmware/drivers/tuner/lv24020lp.c2
-rw-r--r--firmware/font.c2
-rw-r--r--firmware/include/file.h17
-rw-r--r--firmware/screendump.c4
-rw-r--r--uisimulator/common/io.c4
-rw-r--r--uisimulator/sdl/lcd-charcells.c4
30 files changed, 60 insertions, 51 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 6305edcbd3..054bfd4c99 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -2068,7 +2068,7 @@ static int disk_callback(int btn, struct gui_synclist *lists)
2068#if (CONFIG_STORAGE & STORAGE_ATA) 2068#if (CONFIG_STORAGE & STORAGE_ATA)
2069static bool dbg_identify_info(void) 2069static bool dbg_identify_info(void)
2070{ 2070{
2071 int fd = creat("/identify_info.bin"); 2071 int fd = creat("/identify_info.bin", 0666);
2072 if(fd >= 0) 2072 if(fd >= 0)
2073 { 2073 {
2074#ifdef ROCKBOX_LITTLE_ENDIAN 2074#ifdef ROCKBOX_LITTLE_ENDIAN
@@ -2202,14 +2202,14 @@ static bool dbg_save_roms(void)
2202 int fd; 2202 int fd;
2203 int oldmode = system_memory_guard(MEMGUARD_NONE); 2203 int oldmode = system_memory_guard(MEMGUARD_NONE);
2204 2204
2205 fd = creat("/internal_rom_0000-FFFF.bin"); 2205 fd = creat("/internal_rom_0000-FFFF.bin", 0666);
2206 if(fd >= 0) 2206 if(fd >= 0)
2207 { 2207 {
2208 write(fd, (void *)0, 0x10000); 2208 write(fd, (void *)0, 0x10000);
2209 close(fd); 2209 close(fd);
2210 } 2210 }
2211 2211
2212 fd = creat("/internal_rom_2000000-203FFFF.bin"); 2212 fd = creat("/internal_rom_2000000-203FFFF.bin", 0666);
2213 if(fd >= 0) 2213 if(fd >= 0)
2214 { 2214 {
2215 write(fd, (void *)0x2000000, 0x40000); 2215 write(fd, (void *)0x2000000, 0x40000);
@@ -2226,13 +2226,13 @@ static bool dbg_save_roms(void)
2226 int oldmode = system_memory_guard(MEMGUARD_NONE); 2226 int oldmode = system_memory_guard(MEMGUARD_NONE);
2227 2227
2228#if defined(IRIVER_H100_SERIES) 2228#if defined(IRIVER_H100_SERIES)
2229 fd = creat("/internal_rom_000000-1FFFFF.bin"); 2229 fd = creat("/internal_rom_000000-1FFFFF.bin", 0666);
2230#elif defined(IRIVER_H300_SERIES) 2230#elif defined(IRIVER_H300_SERIES)
2231 fd = creat("/internal_rom_000000-3FFFFF.bin"); 2231 fd = creat("/internal_rom_000000-3FFFFF.bin", 0666);
2232#elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3) 2232#elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
2233 fd = creat("/internal_rom_000000-3FFFFF.bin"); 2233 fd = creat("/internal_rom_000000-3FFFFF.bin", 0666);
2234#elif defined(MPIO_HD200) 2234#elif defined(MPIO_HD200)
2235 fd = creat("/internal_rom_000000-1FFFFF.bin"); 2235 fd = creat("/internal_rom_000000-1FFFFF.bin", 0666);
2236#endif 2236#endif
2237 if(fd >= 0) 2237 if(fd >= 0)
2238 { 2238 {
@@ -2242,7 +2242,7 @@ static bool dbg_save_roms(void)
2242 system_memory_guard(oldmode); 2242 system_memory_guard(oldmode);
2243 2243
2244#ifdef HAVE_EEPROM 2244#ifdef HAVE_EEPROM
2245 fd = creat("/internal_eeprom.bin"); 2245 fd = creat("/internal_eeprom.bin", 0666);
2246 if (fd >= 0) 2246 if (fd >= 0)
2247 { 2247 {
2248 int old_irq_level; 2248 int old_irq_level;
@@ -2273,7 +2273,7 @@ static bool dbg_save_roms(void)
2273{ 2273{
2274 int fd; 2274 int fd;
2275 2275
2276 fd = creat("/internal_rom_000000-0FFFFF.bin"); 2276 fd = creat("/internal_rom_000000-0FFFFF.bin", 0666);
2277 if(fd >= 0) 2277 if(fd >= 0)
2278 { 2278 {
2279 write(fd, (void *)0x20000000, FLASH_SIZE); 2279 write(fd, (void *)0x20000000, FLASH_SIZE);
@@ -2287,7 +2287,7 @@ static bool dbg_save_roms(void)
2287{ 2287{
2288 int fd; 2288 int fd;
2289 2289
2290 fd = creat("/flash_rom_A0000000-A01FFFFF.bin"); 2290 fd = creat("/flash_rom_A0000000-A01FFFFF.bin", 0666);
2291 if (fd >= 0) 2291 if (fd >= 0)
2292 { 2292 {
2293 write(fd, (void*)0xa0000000, FLASH_SIZE); 2293 write(fd, (void*)0xa0000000, FLASH_SIZE);
@@ -2301,7 +2301,7 @@ static bool dbg_save_roms(void)
2301{ 2301{
2302 int fd; 2302 int fd;
2303 2303
2304 fd = creat("/eeprom_E0000000-E0001FFF.bin"); 2304 fd = creat("/eeprom_E0000000-E0001FFF.bin", 0666);
2305 if (fd >= 0) 2305 if (fd >= 0)
2306 { 2306 {
2307 write(fd, (void*)0xe0000000, 0x2000); 2307 write(fd, (void*)0xe0000000, 0x2000);
diff --git a/apps/onplay.c b/apps/onplay.c
index e2037ad4fa..617f523879 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -666,7 +666,7 @@ static bool clipboard_pastefile(const char *src, const char *target, bool copy)
666 src_fd = open(src, O_RDONLY); 666 src_fd = open(src, O_RDONLY);
667 667
668 if (src_fd >= 0) { 668 if (src_fd >= 0) {
669 target_fd = creat(target); 669 target_fd = creat(target, 0666);
670 670
671 if (target_fd >= 0) { 671 if (target_fd >= 0) {
672 result = true; 672 result = true;
diff --git a/apps/plugin.c b/apps/plugin.c
index 2f54c0d314..28d443321f 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -97,7 +97,7 @@ char *plugin_get_current_filename(void);
97/* Some wrappers used to monitor open and close and detect leaks*/ 97/* Some wrappers used to monitor open and close and detect leaks*/
98static int open_wrapper(const char* pathname, int flags); 98static int open_wrapper(const char* pathname, int flags);
99static int close_wrapper(int fd); 99static int close_wrapper(int fd);
100static int creat_wrapper(const char *pathname); 100static int creat_wrapper(const char *pathname, mode_t mode);
101#endif 101#endif
102 102
103static const struct plugin_api rockbox_api = { 103static const struct plugin_api rockbox_api = {
@@ -1002,9 +1002,9 @@ static int close_wrapper(int fd)
1002 return PREFIX(close)(fd); 1002 return PREFIX(close)(fd);
1003} 1003}
1004 1004
1005static int creat_wrapper(const char *pathname) 1005static int creat_wrapper(const char *pathname, mode_t mode)
1006{ 1006{
1007 int fd = PREFIX(creat)(pathname); 1007 int fd = PREFIX(creat)(pathname, mode);
1008 1008
1009 if(fd >= 0) 1009 if(fd >= 0)
1010 open_files |= (1<<fd); 1010 open_files |= (1<<fd);
diff --git a/apps/plugin.h b/apps/plugin.h
index 31c87433e7..aa6108a8ab 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -401,7 +401,7 @@ struct plugin_api {
401 int (*close)(int fd); 401 int (*close)(int fd);
402 ssize_t (*read)(int fd, void* buf, size_t count); 402 ssize_t (*read)(int fd, void* buf, size_t count);
403 off_t (*lseek)(int fd, off_t offset, int whence); 403 off_t (*lseek)(int fd, off_t offset, int whence);
404 int (*creat)(const char *pathname); 404 int (*creat)(const char *pathname, mode_t mode);
405 ssize_t (*write)(int fd, const void* buf, size_t count); 405 ssize_t (*write)(int fd, const void* buf, size_t count);
406 int (*remove)(const char* pathname); 406 int (*remove)(const char* pathname);
407 int (*rename)(const char* path, const char* newname); 407 int (*rename)(const char* path, const char* newname);
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index d6a1a9a4ac..3589998e47 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -612,7 +612,7 @@ static bool save_memo(int changed, bool new_mod, struct shown *shown)
612 int fp, fq; 612 int fp, fq;
613 /* use O_RDWR|O_CREAT so that file is created if it doesn't exist. */ 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);
615 fq = rb->creat(TEMP_FILE); 615 fq = rb->creat(TEMP_FILE, 0666);
616 if ( (fq > -1) && (fp > -1) ) 616 if ( (fq > -1) && (fp > -1) )
617 { 617 {
618 int i; 618 int i;
diff --git a/apps/plugins/clock/clock_settings.c b/apps/plugins/clock/clock_settings.c
index 8464ab0ed1..a407ebe65f 100644
--- a/apps/plugins/clock/clock_settings.c
+++ b/apps/plugins/clock/clock_settings.c
@@ -119,7 +119,7 @@ enum settings_file_status clock_settings_load(struct clock_settings* settings,
119 119
120enum settings_file_status clock_settings_save(struct clock_settings* settings, 120enum settings_file_status clock_settings_save(struct clock_settings* settings,
121 char* filename){ 121 char* filename){
122 int fd = rb->creat(filename); 122 int fd = rb->creat(filename, 0666);
123 if(fd >= 0){ /* does file exist? */ 123 if(fd >= 0){ /* does file exist? */
124 rb->write (fd, settings, sizeof(*settings)); 124 rb->write (fd, settings, sizeof(*settings));
125 rb->close(fd); 125 rb->close(fd);
diff --git a/apps/plugins/disktidy.c b/apps/plugins/disktidy.c
index 3d2685f4ad..8d8515e27b 100644
--- a/apps/plugins/disktidy.c
+++ b/apps/plugins/disktidy.c
@@ -536,7 +536,7 @@ enum plugin_status plugin_start(const void* parameter)
536 status = tidy_lcd_menu(); 536 status = tidy_lcd_menu();
537 if (tidy_loaded_and_changed) 537 if (tidy_loaded_and_changed)
538 { 538 {
539 int fd = rb->creat(CUSTOM_FILES); 539 int fd = rb->creat(CUSTOM_FILES, 0666);
540 int i; 540 int i;
541 if (fd >= 0) 541 if (fd >= 0)
542 { 542 {
diff --git a/apps/plugins/goban/util.c b/apps/plugins/goban/util.c
index 0e83173f40..bb78316346 100644
--- a/apps/plugins/goban/util.c
+++ b/apps/plugins/goban/util.c
@@ -221,7 +221,7 @@ create_or_open_file (const char *filename)
221 221
222 if (!rb->file_exists (filename)) 222 if (!rb->file_exists (filename))
223 { 223 {
224 fd = rb->creat (filename); 224 fd = rb->creat(filename, 0666);
225 } 225 }
226 else 226 else
227 { 227 {
diff --git a/apps/plugins/iriverify.c b/apps/plugins/iriverify.c
index 546601baad..4e8ca5b420 100644
--- a/apps/plugins/iriverify.c
+++ b/apps/plugins/iriverify.c
@@ -67,7 +67,7 @@ static int write_file(void)
67 67
68 rb->snprintf(tmpfilename, MAX_PATH+1, "%s.tmp", filename); 68 rb->snprintf(tmpfilename, MAX_PATH+1, "%s.tmp", filename);
69 69
70 fd = rb->creat(tmpfilename); 70 fd = rb->creat(tmpfilename, 0666);
71 if(fd < 0) 71 if(fd < 0)
72 return 10 * fd - 1; 72 return 10 * fd - 1;
73 73
diff --git a/apps/plugins/lib/configfile.c b/apps/plugins/lib/configfile.c
index 21b66a317b..0fb01c6a40 100644
--- a/apps/plugins/lib/configfile.c
+++ b/apps/plugins/lib/configfile.c
@@ -46,7 +46,7 @@ int configfile_save(const char *filename, struct configdata *cfg,
46 char buf[MAX_PATH]; 46 char buf[MAX_PATH];
47 47
48 get_cfg_filename(buf, MAX_PATH, filename); 48 get_cfg_filename(buf, MAX_PATH, filename);
49 fd = rb->creat(buf); 49 fd = rb->creat(buf, 0666);
50 if(fd < 0) 50 if(fd < 0)
51 return fd*10 - 1; 51 return fd*10 - 1;
52 52
diff --git a/apps/plugins/lib/pluginlib_bmp.c b/apps/plugins/lib/pluginlib_bmp.c
index 8520a8b17f..148aa8e1de 100644
--- a/apps/plugins/lib/pluginlib_bmp.c
+++ b/apps/plugins/lib/pluginlib_bmp.c
@@ -60,7 +60,7 @@ int save_bmp_file( char* filename, struct bitmap *bm )
60 int fh; 60 int fh;
61 int x,y; 61 int x,y;
62 if( bm->format != FORMAT_NATIVE ) return -1; 62 if( bm->format != FORMAT_NATIVE ) return -1;
63 fh = rb->creat( filename ); 63 fh = rb->creat( filename , 0666);
64 if( fh < 0 ) return -1; 64 if( fh < 0 ) return -1;
65 65
66 rb->write( fh, header, sizeof( header ) ); 66 rb->write( fh, header, sizeof( header ) );
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c
index b12c8e8e04..463f86c394 100644
--- a/apps/plugins/pictureflow/pictureflow.c
+++ b/apps/plugins/pictureflow/pictureflow.c
@@ -1161,7 +1161,7 @@ bool save_pfraw(char* filename, struct bitmap *bm)
1161 struct pfraw_header bmph; 1161 struct pfraw_header bmph;
1162 bmph.width = bm->width; 1162 bmph.width = bm->width;
1163 bmph.height = bm->height; 1163 bmph.height = bm->height;
1164 int fh = rb->creat( filename ); 1164 int fh = rb->creat( filename , 0666);
1165 if( fh < 0 ) return false; 1165 if( fh < 0 ) return false;
1166 rb->write( fh, &bmph, sizeof( struct pfraw_header ) ); 1166 rb->write( fh, &bmph, sizeof( struct pfraw_header ) );
1167 int y; 1167 int y;
diff --git a/apps/plugins/pitch_detector.c b/apps/plugins/pitch_detector.c
index 10125c1302..de0aff9fef 100644
--- a/apps/plugins/pitch_detector.c
+++ b/apps/plugins/pitch_detector.c
@@ -381,7 +381,7 @@ enum settings_file_status tuner_settings_load(struct tuner_settings* settings,
381enum settings_file_status tuner_settings_save(struct tuner_settings* settings, 381enum settings_file_status tuner_settings_save(struct tuner_settings* settings,
382 char* filename) 382 char* filename)
383{ 383{
384 int fd = rb->creat(filename); 384 int fd = rb->creat(filename, 0666);
385 if(fd >= 0){ /* does file exist? */ 385 if(fd >= 0){ /* does file exist? */
386 rb->write (fd, settings, sizeof(*settings)); 386 rb->write (fd, settings, sizeof(*settings));
387 rb->close(fd); 387 rb->close(fd);
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c
index 5f837980d3..6a62fee8ff 100644
--- a/apps/plugins/random_folder_advance_config.c
+++ b/apps/plugins/random_folder_advance_config.c
@@ -263,7 +263,7 @@ int load_list(void)
263 263
264int save_list(void) 264int save_list(void)
265{ 265{
266 int myfd = rb->creat(RFA_FILE); 266 int myfd = rb->creat(RFA_FILE, 0666);
267 if (myfd < 0) 267 if (myfd < 0)
268 { 268 {
269 rb->splash(HZ, "Could Not Open " RFA_FILE); 269 rb->splash(HZ, "Could Not Open " RFA_FILE);
@@ -388,7 +388,7 @@ int export_list_to_file_text(void)
388 } 388 }
389 389
390 /* create and open the file */ 390 /* create and open the file */
391 int myfd = rb->creat(RFA_FILE_TEXT); 391 int myfd = rb->creat(RFA_FILE_TEXT, 0666);
392 if (myfd < 0) 392 if (myfd < 0)
393 { 393 {
394 rb->splashf(HZ*4, "failed to open: fd = %d, file = %s", 394 rb->splashf(HZ*4, "failed to open: fd = %d, file = %s",
diff --git a/apps/plugins/shortcuts/shortcuts_common.c b/apps/plugins/shortcuts/shortcuts_common.c
index 68817d3081..dee1657afc 100644
--- a/apps/plugins/shortcuts/shortcuts_common.c
+++ b/apps/plugins/shortcuts/shortcuts_common.c
@@ -85,7 +85,7 @@ bool load_sc_file(sc_file_t *file, char *filename, bool must_exist,
85 /* The file didn't exist on disk */ 85 /* The file didn't exist on disk */
86 if (!must_exist) { 86 if (!must_exist) {
87 DEBUGF("Trying to create link file '%s'...\n", filename); 87 DEBUGF("Trying to create link file '%s'...\n", filename);
88 fd = rb->creat(filename); 88 fd = rb->creat(filename, 0666);
89 if (fd < 0){ 89 if (fd < 0){
90 /* For some reason we couldn't create the file, 90 /* For some reason we couldn't create the file,
91 * so return an error message and exit */ 91 * so return an error message and exit */
diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c
index 03c2daa30b..f3b826e04e 100644
--- a/apps/plugins/test_codec.c
+++ b/apps/plugins/test_codec.c
@@ -167,7 +167,7 @@ void init_wav(char* filename)
167{ 167{
168 wavinfo.totalsamples = 0; 168 wavinfo.totalsamples = 0;
169 169
170 wavinfo.fd = rb->creat(filename); 170 wavinfo.fd = rb->creat(filename, 0666);
171 171
172 if (wavinfo.fd >= 0) 172 if (wavinfo.fd >= 0)
173 { 173 {
diff --git a/apps/plugins/test_disk.c b/apps/plugins/test_disk.c
index 9d186e04f9..396e03c818 100644
--- a/apps/plugins/test_disk.c
+++ b/apps/plugins/test_disk.c
@@ -123,7 +123,7 @@ static bool test_fs(void)
123 rb->snprintf(text_buf, sizeof text_buf, "Data size: %dKB", (TEST_SIZE>>10)); 123 rb->snprintf(text_buf, sizeof text_buf, "Data size: %dKB", (TEST_SIZE>>10));
124 log_text(text_buf, true); 124 log_text(text_buf, true);
125 125
126 fd = rb->creat(TEST_FILE); 126 fd = rb->creat(TEST_FILE, 0666);
127 if (fd < 0) 127 if (fd < 0)
128 { 128 {
129 rb->splash(HZ, "creat() failed."); 129 rb->splash(HZ, "creat() failed.");
@@ -211,7 +211,7 @@ static bool file_speed(int chunksize, bool align)
211 log_text("--------------------", true); 211 log_text("--------------------", true);
212 212
213 /* File creation write speed */ 213 /* File creation write speed */
214 fd = rb->creat(TEST_FILE); 214 fd = rb->creat(TEST_FILE, 0666);
215 if (fd < 0) 215 if (fd < 0)
216 { 216 {
217 rb->splash(HZ, "creat() failed."); 217 rb->splash(HZ, "creat() failed.");
@@ -311,7 +311,7 @@ static bool test_speed(void)
311 for (i = 0; TIME_BEFORE(*rb->current_tick, time); i++) 311 for (i = 0; TIME_BEFORE(*rb->current_tick, time); i++)
312 { 312 {
313 rb->snprintf(text_buf, sizeof(text_buf), TESTBASEDIR "/%08x.tmp", i); 313 rb->snprintf(text_buf, sizeof(text_buf), TESTBASEDIR "/%08x.tmp", i);
314 fd = rb->creat(text_buf); 314 fd = rb->creat(text_buf, 0666);
315 if (fd < 0) 315 if (fd < 0)
316 { 316 {
317 last_file = i; 317 last_file = i;
diff --git a/apps/plugins/vbrfix.c b/apps/plugins/vbrfix.c
index 3e152be3fc..2ca0176084 100644
--- a/apps/plugins/vbrfix.c
+++ b/apps/plugins/vbrfix.c
@@ -49,7 +49,7 @@ static int insert_data_in_file(const char *fname, int fpos, char *buf, int num_b
49 return 10*orig_fd - 1; 49 return 10*orig_fd - 1;
50 } 50 }
51 51
52 fd = rb->creat(tmpname); 52 fd = rb->creat(tmpname, 0666);
53 if(fd < 0) { 53 if(fd < 0) {
54 rb->close(orig_fd); 54 rb->close(orig_fd);
55 return 10*fd - 2; 55 return 10*fd - 2;
diff --git a/apps/plugins/vu_meter.c b/apps/plugins/vu_meter.c
index 7cf5a5f00c..fc04bc7842 100644
--- a/apps/plugins/vu_meter.c
+++ b/apps/plugins/vu_meter.c
@@ -457,7 +457,7 @@ void load_settings(void) {
457} 457}
458 458
459void save_settings(void) { 459void save_settings(void) {
460 int fp = rb->creat(PLUGIN_DEMOS_DIR "/.vu_meter"); 460 int fp = rb->creat(PLUGIN_DEMOS_DIR "/.vu_meter", 0666);
461 if(fp >= 0) { 461 if(fp >= 0) {
462 rb->write (fp, &vumeter_settings, sizeof(struct saved_settings)); 462 rb->write (fp, &vumeter_settings, sizeof(struct saved_settings));
463 rb->close(fp); 463 rb->close(fp);
diff --git a/apps/plugins/wav2wv.c b/apps/plugins/wav2wv.c
index 1102d13718..03900884f9 100644
--- a/apps/plugins/wav2wv.c
+++ b/apps/plugins/wav2wv.c
@@ -169,7 +169,7 @@ static int wav2wv(const char *infile)
169 outextension = outfile + rb->strlen(outfile) - 3; 169 outextension = outfile + rb->strlen(outfile) - 3;
170 outextension[1] = outextension[2]; 170 outextension[1] = outextension[2];
171 outextension[2] = 0; 171 outextension[2] = 0;
172 out_fd = rb->creat(outfile); 172 out_fd = rb->creat(outfile, 0666);
173 173
174 if (out_fd < 0) { 174 if (out_fd < 0) {
175 rb->splash(HZ*2, "could not create file!"); 175 rb->splash(HZ*2, "could not create file!");
diff --git a/apps/plugins/zxbox/snapshot.c b/apps/plugins/zxbox/snapshot.c
index 6efb29f91b..0b80b64497 100644
--- a/apps/plugins/zxbox/snapshot.c
+++ b/apps/plugins/zxbox/snapshot.c
@@ -584,7 +584,7 @@ static void save_snapshot_file_type(char *name, int type)
584 int snsh; 584 int snsh;
585 snsh = rb->open(name, O_WRONLY); 585 snsh = rb->open(name, O_WRONLY);
586 if(snsh < 0) { 586 if(snsh < 0) {
587 snsh = rb->creat(name); 587 snsh = rb->creat(name, 0666);
588 if(snsh < 0) { 588 if(snsh < 0) {
589 put_msg("Could not create snapshot file"); 589 put_msg("Could not create snapshot file");
590 return; 590 return;
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 0523f1ecac..7cf91d62f7 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -1135,7 +1135,7 @@ static void radio_save_presets(void)
1135 int fd; 1135 int fd;
1136 int i; 1136 int i;
1137 1137
1138 fd = creat(filepreset); 1138 fd = creat(filepreset, 0666);
1139 if(fd >= 0) 1139 if(fd >= 0)
1140 { 1140 {
1141 for(i = 0;i < num_presets;i++) 1141 for(i = 0;i < num_presets;i++)
diff --git a/bootloader/gigabeat-s.c b/bootloader/gigabeat-s.c
index 8258e276c3..9e6edbbcbb 100644
--- a/bootloader/gigabeat-s.c
+++ b/bootloader/gigabeat-s.c
@@ -196,7 +196,7 @@ static void untar(int tar_fd)
196 { 196 {
197 int wc; 197 int wc;
198 198
199 fd = creat(path); 199 fd = creat(path, 0666);
200 if (fd < 0) 200 if (fd < 0)
201 { 201 {
202 printf("failed to create file (%d)", fd); 202 printf("failed to create file (%d)", fd);
diff --git a/firmware/common/file.c b/firmware/common/file.c
index 7ec712a244..05612cd75e 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -55,7 +55,7 @@ static struct filedesc openfiles[MAX_OPEN_FILES];
55 55
56static int flush_cache(int fd); 56static int flush_cache(int fd);
57 57
58int creat(const char *pathname) 58int 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);
61} 61}
diff --git a/firmware/drivers/tuner/lv24020lp.c b/firmware/drivers/tuner/lv24020lp.c
index d70eef8eea..5f23338eee 100644
--- a/firmware/drivers/tuner/lv24020lp.c
+++ b/firmware/drivers/tuner/lv24020lp.c
@@ -46,7 +46,7 @@ static struct mutex tuner_mtx;
46static int fd_log = -1; 46static int fd_log = -1;
47 47
48#define TUNER_LOG_OPEN() if (fd_log < 0) \ 48#define TUNER_LOG_OPEN() if (fd_log < 0) \
49 fd_log = creat("/tuner_dump.txt") 49 fd_log = creat("/tuner_dump.txt", 0666)
50/* syncing required because close() is never called */ 50/* syncing required because close() is never called */
51#define TUNER_LOG_SYNC() fsync(fd_log) 51#define TUNER_LOG_SYNC() fsync(fd_log)
52#define TUNER_LOG(s...) fdprintf(fd_log, s) 52#define TUNER_LOG(s...) fdprintf(fd_log, s)
diff --git a/firmware/font.c b/firmware/font.c
index 804d3895b1..6877d7e1ff 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -609,7 +609,7 @@ void glyph_cache_save(struct font* pf)
609#ifdef WPSEDITOR 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);
611#else 611#else
612 cache_fd = creat(GLYPH_CACHE_FILE); 612 cache_fd = creat(GLYPH_CACHE_FILE, 0666);
613#endif 613#endif
614 if (cache_fd < 0) return; 614 if (cache_fd < 0) return;
615 615
diff --git a/firmware/include/file.h b/firmware/include/file.h
index 9a9548f8f6..b60c744549 100644
--- a/firmware/include/file.h
+++ b/firmware/include/file.h
@@ -48,9 +48,9 @@
48#define O_TRUNC 0x10 48#define O_TRUNC 0x10
49#endif 49#endif
50 50
51#if defined(SIMULATOR) && !defined(PLUGIN) && !defined(CODEC) 51#if defined(SIMULATOR) && !defined(PLUGIN) && !defined(CODEC)
52#define open(x,y) sim_open(x,y) 52#define open(x,y) sim_open(x,y)
53#define creat(x) sim_creat(x) 53#define creat(x,m) sim_creat(x,m)
54#define remove(x) sim_remove(x) 54#define remove(x) sim_remove(x)
55#define rename(x,y) sim_rename(x,y) 55#define rename(x,y) sim_rename(x,y)
56#define filesize(x) sim_filesize(x) 56#define filesize(x) sim_filesize(x)
@@ -60,11 +60,12 @@
60#define read(x,y,z) sim_read(x,y,z) 60#define read(x,y,z) sim_read(x,y,z)
61#define write(x,y,z) sim_write(x,y,z) 61#define write(x,y,z) sim_write(x,y,z)
62#define close(x) sim_close(x) 62#define close(x) sim_close(x)
63extern int sim_creat(const char *pathname, mode_t mode);
63#endif 64#endif
64 65
65typedef int (*open_func)(const char* pathname, int flags); 66typedef int (*open_func)(const char* pathname, int flags);
66typedef ssize_t (*read_func)(int fd, void *buf, size_t count); 67typedef ssize_t (*read_func)(int fd, void *buf, size_t count);
67typedef int (*creat_func)(const char *pathname); 68typedef int (*creat_func)(const char *pathname, mode_t mode);
68typedef ssize_t (*write_func)(int fd, const void *buf, size_t count); 69typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
69typedef void (*qsort_func)(void *base, size_t nmemb, size_t size, 70typedef void (*qsort_func)(void *base, size_t nmemb, size_t size,
70 int(*_compar)(const void *, const void *)); 71 int(*_compar)(const void *, const void *));
@@ -74,7 +75,15 @@ extern int close(int fd);
74extern int fsync(int fd); 75extern int fsync(int fd);
75extern ssize_t read(int fd, void *buf, size_t count); 76extern ssize_t read(int fd, void *buf, size_t count);
76extern off_t lseek(int fildes, off_t offset, int whence); 77extern off_t lseek(int fildes, off_t offset, int whence);
77extern int creat(const char *pathname); 78extern int file_creat(const char *pathname);
79#ifndef SIMULATOR
80/* posix compatibility function */
81static inline int creat(const char *pathname, mode_t mode)
82{
83 (void)mode;
84 return file_creat(pathname);
85}
86#endif
78extern ssize_t write(int fd, const void *buf, size_t count); 87extern ssize_t write(int fd, const void *buf, size_t count);
79extern int remove(const char* pathname); 88extern int remove(const char* pathname);
80extern int rename(const char* path, const char* newname); 89extern int rename(const char* path, const char* newname);
diff --git a/firmware/screendump.c b/firmware/screendump.c
index e84afb9511..1876df8ac0 100644
--- a/firmware/screendump.c
+++ b/firmware/screendump.c
@@ -140,7 +140,7 @@ void screen_dump(void)
140 IF_CNFN_NUM_(, NULL)); 140 IF_CNFN_NUM_(, NULL));
141#endif 141#endif
142 142
143 fd = creat(filename); 143 fd = creat(filename, 0666);
144 if (fd < 0) 144 if (fd < 0)
145 return; 145 return;
146 146
@@ -317,7 +317,7 @@ void remote_screen_dump(void)
317 IF_CNFN_NUM_(, NULL)); 317 IF_CNFN_NUM_(, NULL));
318#endif 318#endif
319 319
320 fd = creat(filename); 320 fd = creat(filename, 0666);
321 if (fd < 0) 321 if (fd < 0)
322 return; 322 return;
323 323
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 20f5a368f4..f794d5fbc3 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -352,9 +352,9 @@ int sim_close(int fd)
352 return ret; 352 return ret;
353} 353}
354 354
355int sim_creat(const char *name) 355int sim_creat(const char *name, mode_t mode)
356{ 356{
357 return OPEN(get_sim_pathname(name), O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, 0666); 357 return OPEN(get_sim_pathname(name), O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, mode);
358} 358}
359 359
360ssize_t sim_read(int fd, void *buf, size_t count) 360ssize_t sim_read(int fd, void *buf, size_t count)
diff --git a/uisimulator/sdl/lcd-charcells.c b/uisimulator/sdl/lcd-charcells.c
index 5a06af53ab..05513ab266 100644
--- a/uisimulator/sdl/lcd-charcells.c
+++ b/uisimulator/sdl/lcd-charcells.c
@@ -38,7 +38,7 @@
38#endif 38#endif
39 39
40/* extern functions, needed for screendump() */ 40/* extern functions, needed for screendump() */
41extern int sim_creat(const char *name); 41extern int sim_creat(const char *name, mode_t mode);
42 42
43SDL_Surface* lcd_surface; 43SDL_Surface* lcd_surface;
44 44
@@ -162,7 +162,7 @@ void screen_dump(void)
162 IF_CNFN_NUM_(, NULL)); 162 IF_CNFN_NUM_(, NULL));
163 DEBUGF("screen_dump\n"); 163 DEBUGF("screen_dump\n");
164 164
165 fd = sim_creat(filename); 165 fd = sim_creat(filename, 0666);
166 if (fd < 0) 166 if (fd < 0)
167 return; 167 return;
168 168