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
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 6305edc..054bfd4 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -2068,7 +2068,7 @@
#if (CONFIG_STORAGE & STORAGE_ATA)
static bool dbg_identify_info(void)
{
- int fd = creat("/identify_info.bin");
+ int fd = creat("/identify_info.bin", 0666);
if(fd >= 0)
{
#ifdef ROCKBOX_LITTLE_ENDIAN
@@ -2202,14 +2202,14 @@
int fd;
int oldmode = system_memory_guard(MEMGUARD_NONE);
- fd = creat("/internal_rom_0000-FFFF.bin");
+ fd = creat("/internal_rom_0000-FFFF.bin", 0666);
if(fd >= 0)
{
write(fd, (void *)0, 0x10000);
close(fd);
}
- fd = creat("/internal_rom_2000000-203FFFF.bin");
+ fd = creat("/internal_rom_2000000-203FFFF.bin", 0666);
if(fd >= 0)
{
write(fd, (void *)0x2000000, 0x40000);
@@ -2226,13 +2226,13 @@
int oldmode = system_memory_guard(MEMGUARD_NONE);
#if defined(IRIVER_H100_SERIES)
- fd = creat("/internal_rom_000000-1FFFFF.bin");
+ fd = creat("/internal_rom_000000-1FFFFF.bin", 0666);
#elif defined(IRIVER_H300_SERIES)
- fd = creat("/internal_rom_000000-3FFFFF.bin");
+ fd = creat("/internal_rom_000000-3FFFFF.bin", 0666);
#elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
- fd = creat("/internal_rom_000000-3FFFFF.bin");
+ fd = creat("/internal_rom_000000-3FFFFF.bin", 0666);
#elif defined(MPIO_HD200)
- fd = creat("/internal_rom_000000-1FFFFF.bin");
+ fd = creat("/internal_rom_000000-1FFFFF.bin", 0666);
#endif
if(fd >= 0)
{
@@ -2242,7 +2242,7 @@
system_memory_guard(oldmode);
#ifdef HAVE_EEPROM
- fd = creat("/internal_eeprom.bin");
+ fd = creat("/internal_eeprom.bin", 0666);
if (fd >= 0)
{
int old_irq_level;
@@ -2273,7 +2273,7 @@
{
int fd;
- fd = creat("/internal_rom_000000-0FFFFF.bin");
+ fd = creat("/internal_rom_000000-0FFFFF.bin", 0666);
if(fd >= 0)
{
write(fd, (void *)0x20000000, FLASH_SIZE);
@@ -2287,7 +2287,7 @@
{
int fd;
- fd = creat("/flash_rom_A0000000-A01FFFFF.bin");
+ fd = creat("/flash_rom_A0000000-A01FFFFF.bin", 0666);
if (fd >= 0)
{
write(fd, (void*)0xa0000000, FLASH_SIZE);
@@ -2301,7 +2301,7 @@
{
int fd;
- fd = creat("/eeprom_E0000000-E0001FFF.bin");
+ fd = creat("/eeprom_E0000000-E0001FFF.bin", 0666);
if (fd >= 0)
{
write(fd, (void*)0xe0000000, 0x2000);
diff --git a/apps/onplay.c b/apps/onplay.c
index e2037ad..617f523 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -666,7 +666,7 @@
src_fd = open(src, O_RDONLY);
if (src_fd >= 0) {
- target_fd = creat(target);
+ target_fd = creat(target, 0666);
if (target_fd >= 0) {
result = true;
diff --git a/apps/plugin.c b/apps/plugin.c
index 2f54c0d..28d4433 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -97,7 +97,7 @@
/* Some wrappers used to monitor open and close and detect leaks*/
static int open_wrapper(const char* pathname, int flags);
static int close_wrapper(int fd);
-static int creat_wrapper(const char *pathname);
+static int creat_wrapper(const char *pathname, mode_t mode);
#endif
static const struct plugin_api rockbox_api = {
@@ -1002,9 +1002,9 @@
return PREFIX(close)(fd);
}
-static int creat_wrapper(const char *pathname)
+static int creat_wrapper(const char *pathname, mode_t mode)
{
- int fd = PREFIX(creat)(pathname);
+ int fd = PREFIX(creat)(pathname, mode);
if(fd >= 0)
open_files |= (1<<fd);
diff --git a/apps/plugin.h b/apps/plugin.h
index 31c8743..aa6108a 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -401,7 +401,7 @@
int (*close)(int fd);
ssize_t (*read)(int fd, void* buf, size_t count);
off_t (*lseek)(int fd, off_t offset, int whence);
- int (*creat)(const char *pathname);
+ int (*creat)(const char *pathname, mode_t mode);
ssize_t (*write)(int fd, const void* buf, size_t count);
int (*remove)(const char* pathname);
int (*rename)(const char* path, const char* newname);
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index d6a1a9a..3589998 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -612,7 +612,7 @@
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);
- fq = rb->creat(TEMP_FILE);
+ fq = rb->creat(TEMP_FILE, 0666);
if ( (fq > -1) && (fp > -1) )
{
int i;
diff --git a/apps/plugins/clock/clock_settings.c b/apps/plugins/clock/clock_settings.c
index 8464ab0..a407ebe 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_save(struct clock_settings* settings,
char* filename){
- int fd = rb->creat(filename);
+ int fd = rb->creat(filename, 0666);
if(fd >= 0){ /* does file exist? */
rb->write (fd, settings, sizeof(*settings));
rb->close(fd);
diff --git a/apps/plugins/disktidy.c b/apps/plugins/disktidy.c
index 3d2685f..8d8515e 100644
--- a/apps/plugins/disktidy.c
+++ b/apps/plugins/disktidy.c
@@ -536,7 +536,7 @@
status = tidy_lcd_menu();
if (tidy_loaded_and_changed)
{
- int fd = rb->creat(CUSTOM_FILES);
+ int fd = rb->creat(CUSTOM_FILES, 0666);
int i;
if (fd >= 0)
{
diff --git a/apps/plugins/goban/util.c b/apps/plugins/goban/util.c
index 0e83173..bb78316 100644
--- a/apps/plugins/goban/util.c
+++ b/apps/plugins/goban/util.c
@@ -221,7 +221,7 @@
if (!rb->file_exists (filename))
{
- fd = rb->creat (filename);
+ fd = rb->creat(filename, 0666);
}
else
{
diff --git a/apps/plugins/iriverify.c b/apps/plugins/iriverify.c
index 546601b..4e8ca5b 100644
--- a/apps/plugins/iriverify.c
+++ b/apps/plugins/iriverify.c
@@ -67,7 +67,7 @@
rb->snprintf(tmpfilename, MAX_PATH+1, "%s.tmp", filename);
- fd = rb->creat(tmpfilename);
+ fd = rb->creat(tmpfilename, 0666);
if(fd < 0)
return 10 * fd - 1;
diff --git a/apps/plugins/lib/configfile.c b/apps/plugins/lib/configfile.c
index 21b66a3..0fb01c6 100644
--- a/apps/plugins/lib/configfile.c
+++ b/apps/plugins/lib/configfile.c
@@ -46,7 +46,7 @@
char buf[MAX_PATH];
get_cfg_filename(buf, MAX_PATH, filename);
- fd = rb->creat(buf);
+ fd = rb->creat(buf, 0666);
if(fd < 0)
return fd*10 - 1;
diff --git a/apps/plugins/lib/pluginlib_bmp.c b/apps/plugins/lib/pluginlib_bmp.c
index 8520a8b..148aa8e 100644
--- a/apps/plugins/lib/pluginlib_bmp.c
+++ b/apps/plugins/lib/pluginlib_bmp.c
@@ -60,7 +60,7 @@
int fh;
int x,y;
if( bm->format != FORMAT_NATIVE ) return -1;
- fh = rb->creat( filename );
+ fh = rb->creat( filename , 0666);
if( fh < 0 ) return -1;
rb->write( fh, header, sizeof( header ) );
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c
index b12c8e8..463f86c 100644
--- a/apps/plugins/pictureflow/pictureflow.c
+++ b/apps/plugins/pictureflow/pictureflow.c
@@ -1161,7 +1161,7 @@
struct pfraw_header bmph;
bmph.width = bm->width;
bmph.height = bm->height;
- int fh = rb->creat( filename );
+ int fh = rb->creat( filename , 0666);
if( fh < 0 ) return false;
rb->write( fh, &bmph, sizeof( struct pfraw_header ) );
int y;
diff --git a/apps/plugins/pitch_detector.c b/apps/plugins/pitch_detector.c
index 10125c1..de0aff9 100644
--- a/apps/plugins/pitch_detector.c
+++ b/apps/plugins/pitch_detector.c
@@ -381,7 +381,7 @@
enum settings_file_status tuner_settings_save(struct tuner_settings* settings,
char* filename)
{
- int fd = rb->creat(filename);
+ int fd = rb->creat(filename, 0666);
if(fd >= 0){ /* does file exist? */
rb->write (fd, settings, sizeof(*settings));
rb->close(fd);
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c
index 5f83798..6a62fee 100644
--- a/apps/plugins/random_folder_advance_config.c
+++ b/apps/plugins/random_folder_advance_config.c
@@ -263,7 +263,7 @@
int save_list(void)
{
- int myfd = rb->creat(RFA_FILE);
+ int myfd = rb->creat(RFA_FILE, 0666);
if (myfd < 0)
{
rb->splash(HZ, "Could Not Open " RFA_FILE);
@@ -388,7 +388,7 @@
}
/* create and open the file */
- int myfd = rb->creat(RFA_FILE_TEXT);
+ int myfd = rb->creat(RFA_FILE_TEXT, 0666);
if (myfd < 0)
{
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 68817d3..dee1657 100644
--- a/apps/plugins/shortcuts/shortcuts_common.c
+++ b/apps/plugins/shortcuts/shortcuts_common.c
@@ -85,7 +85,7 @@
/* The file didn't exist on disk */
if (!must_exist) {
DEBUGF("Trying to create link file '%s'...\n", filename);
- fd = rb->creat(filename);
+ fd = rb->creat(filename, 0666);
if (fd < 0){
/* For some reason we couldn't create the file,
* so return an error message and exit */
diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c
index 03c2daa..f3b826e 100644
--- a/apps/plugins/test_codec.c
+++ b/apps/plugins/test_codec.c
@@ -167,7 +167,7 @@
{
wavinfo.totalsamples = 0;
- wavinfo.fd = rb->creat(filename);
+ wavinfo.fd = rb->creat(filename, 0666);
if (wavinfo.fd >= 0)
{
diff --git a/apps/plugins/test_disk.c b/apps/plugins/test_disk.c
index 9d186e0..396e03c 100644
--- a/apps/plugins/test_disk.c
+++ b/apps/plugins/test_disk.c
@@ -123,7 +123,7 @@
rb->snprintf(text_buf, sizeof text_buf, "Data size: %dKB", (TEST_SIZE>>10));
log_text(text_buf, true);
- fd = rb->creat(TEST_FILE);
+ fd = rb->creat(TEST_FILE, 0666);
if (fd < 0)
{
rb->splash(HZ, "creat() failed.");
@@ -211,7 +211,7 @@
log_text("--------------------", true);
/* File creation write speed */
- fd = rb->creat(TEST_FILE);
+ fd = rb->creat(TEST_FILE, 0666);
if (fd < 0)
{
rb->splash(HZ, "creat() failed.");
@@ -311,7 +311,7 @@
for (i = 0; TIME_BEFORE(*rb->current_tick, time); i++)
{
rb->snprintf(text_buf, sizeof(text_buf), TESTBASEDIR "/%08x.tmp", i);
- fd = rb->creat(text_buf);
+ fd = rb->creat(text_buf, 0666);
if (fd < 0)
{
last_file = i;
diff --git a/apps/plugins/vbrfix.c b/apps/plugins/vbrfix.c
index 3e152be..2ca0176 100644
--- a/apps/plugins/vbrfix.c
+++ b/apps/plugins/vbrfix.c
@@ -49,7 +49,7 @@
return 10*orig_fd - 1;
}
- fd = rb->creat(tmpname);
+ fd = rb->creat(tmpname, 0666);
if(fd < 0) {
rb->close(orig_fd);
return 10*fd - 2;
diff --git a/apps/plugins/vu_meter.c b/apps/plugins/vu_meter.c
index 7cf5a5f..fc04bc7 100644
--- a/apps/plugins/vu_meter.c
+++ b/apps/plugins/vu_meter.c
@@ -457,7 +457,7 @@
}
void save_settings(void) {
- int fp = rb->creat(PLUGIN_DEMOS_DIR "/.vu_meter");
+ int fp = rb->creat(PLUGIN_DEMOS_DIR "/.vu_meter", 0666);
if(fp >= 0) {
rb->write (fp, &vumeter_settings, sizeof(struct saved_settings));
rb->close(fp);
diff --git a/apps/plugins/wav2wv.c b/apps/plugins/wav2wv.c
index 1102d13..0390088 100644
--- a/apps/plugins/wav2wv.c
+++ b/apps/plugins/wav2wv.c
@@ -169,7 +169,7 @@
outextension = outfile + rb->strlen(outfile) - 3;
outextension[1] = outextension[2];
outextension[2] = 0;
- out_fd = rb->creat(outfile);
+ out_fd = rb->creat(outfile, 0666);
if (out_fd < 0) {
rb->splash(HZ*2, "could not create file!");
diff --git a/apps/plugins/zxbox/snapshot.c b/apps/plugins/zxbox/snapshot.c
index 6efb29f..0b80b64 100644
--- a/apps/plugins/zxbox/snapshot.c
+++ b/apps/plugins/zxbox/snapshot.c
@@ -584,7 +584,7 @@
int snsh;
snsh = rb->open(name, O_WRONLY);
if(snsh < 0) {
- snsh = rb->creat(name);
+ snsh = rb->creat(name, 0666);
if(snsh < 0) {
put_msg("Could not create snapshot file");
return;
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 0523f1e..7cf91d6 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -1135,7 +1135,7 @@
int fd;
int i;
- fd = creat(filepreset);
+ fd = creat(filepreset, 0666);
if(fd >= 0)
{
for(i = 0;i < num_presets;i++)
diff --git a/bootloader/gigabeat-s.c b/bootloader/gigabeat-s.c
index 8258e27..9e6edbb 100644
--- a/bootloader/gigabeat-s.c
+++ b/bootloader/gigabeat-s.c
@@ -196,7 +196,7 @@
{
int wc;
- fd = creat(path);
+ fd = creat(path, 0666);
if (fd < 0)
{
printf("failed to create file (%d)", fd);
diff --git a/firmware/common/file.c b/firmware/common/file.c
index 7ec712a..05612cd 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -55,7 +55,7 @@
static int flush_cache(int fd);
-int creat(const char *pathname)
+int file_creat(const char *pathname)
{
return open(pathname, O_WRONLY|O_CREAT|O_TRUNC);
}
diff --git a/firmware/drivers/tuner/lv24020lp.c b/firmware/drivers/tuner/lv24020lp.c
index d70eef8..5f23338 100644
--- a/firmware/drivers/tuner/lv24020lp.c
+++ b/firmware/drivers/tuner/lv24020lp.c
@@ -46,7 +46,7 @@
static int fd_log = -1;
#define TUNER_LOG_OPEN() if (fd_log < 0) \
- fd_log = creat("/tuner_dump.txt")
+ fd_log = creat("/tuner_dump.txt", 0666)
/* syncing required because close() is never called */
#define TUNER_LOG_SYNC() fsync(fd_log)
#define TUNER_LOG(s...) fdprintf(fd_log, s)
diff --git a/firmware/font.c b/firmware/font.c
index 804d389..6877d7e 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -609,7 +609,7 @@
#ifdef WPSEDITOR
cache_fd = open(GLYPH_CACHE_FILE, O_WRONLY|O_CREAT|O_TRUNC);
#else
- cache_fd = creat(GLYPH_CACHE_FILE);
+ cache_fd = creat(GLYPH_CACHE_FILE, 0666);
#endif
if (cache_fd < 0) return;
diff --git a/firmware/include/file.h b/firmware/include/file.h
index 9a9548f..b60c744 100644
--- a/firmware/include/file.h
+++ b/firmware/include/file.h
@@ -48,9 +48,9 @@
#define O_TRUNC 0x10
#endif
-#if defined(SIMULATOR) && !defined(PLUGIN) && !defined(CODEC)
+#if defined(SIMULATOR) && !defined(PLUGIN) && !defined(CODEC)
#define open(x,y) sim_open(x,y)
-#define creat(x) sim_creat(x)
+#define creat(x,m) sim_creat(x,m)
#define remove(x) sim_remove(x)
#define rename(x,y) sim_rename(x,y)
#define filesize(x) sim_filesize(x)
@@ -60,11 +60,12 @@
#define read(x,y,z) sim_read(x,y,z)
#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);
#endif
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);
+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 *));
@@ -74,7 +75,15 @@
extern int fsync(int fd);
extern ssize_t read(int fd, void *buf, size_t count);
extern off_t lseek(int fildes, off_t offset, int whence);
-extern int creat(const char *pathname);
+extern int file_creat(const char *pathname);
+#ifndef SIMULATOR
+/* posix compatibility function */
+static inline int creat(const char *pathname, mode_t mode)
+{
+ (void)mode;
+ return file_creat(pathname);
+}
+#endif
extern ssize_t write(int fd, const void *buf, size_t count);
extern int remove(const char* pathname);
extern int rename(const char* path, const char* newname);
diff --git a/firmware/screendump.c b/firmware/screendump.c
index e84afb9..1876df8 100644
--- a/firmware/screendump.c
+++ b/firmware/screendump.c
@@ -140,7 +140,7 @@
IF_CNFN_NUM_(, NULL));
#endif
- fd = creat(filename);
+ fd = creat(filename, 0666);
if (fd < 0)
return;
@@ -317,7 +317,7 @@
IF_CNFN_NUM_(, NULL));
#endif
- fd = creat(filename);
+ fd = creat(filename, 0666);
if (fd < 0)
return;
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 20f5a36..f794d5f 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -352,9 +352,9 @@
return ret;
}
-int sim_creat(const char *name)
+int sim_creat(const char *name, mode_t mode)
{
- return OPEN(get_sim_pathname(name), O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, 0666);
+ return OPEN(get_sim_pathname(name), O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, mode);
}
ssize_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 5a06af5..05513ab 100644
--- a/uisimulator/sdl/lcd-charcells.c
+++ b/uisimulator/sdl/lcd-charcells.c
@@ -38,7 +38,7 @@
#endif
/* extern functions, needed for screendump() */
-extern int sim_creat(const char *name);
+extern int sim_creat(const char *name, mode_t mode);
SDL_Surface* lcd_surface;
@@ -162,7 +162,7 @@
IF_CNFN_NUM_(, NULL));
DEBUGF("screen_dump\n");
- fd = sim_creat(filename);
+ fd = sim_creat(filename, 0666);
if (fd < 0)
return;