@@ -1158,8 +1158,7 @@ void sim_fs_cache_image(struct sim_fs *fs, const char *image, int id)
return;
write_file((const unsigned char *) image, strlen(image),
- SIM_CACHE_MODE, SIM_IMAGE_CACHE_PATH, imsi,
- phase, id);
+ SIM_IMAGE_CACHE_PATH, imsi, phase, id);
}
char *sim_fs_get_cached_image(struct sim_fs *fs, int id)
@@ -1262,7 +1261,7 @@ void sim_fs_check_version(struct sim_fs *fs)
sim_fs_cache_flush(fs);
version = SIM_FS_VERSION;
- write_file(&version, 1, SIM_CACHE_MODE, SIM_CACHE_VERSION, imsi, phase);
+ write_file(&version, 1, SIM_CACHE_VERSION, imsi, phase);
}
void sim_fs_cache_flush(struct sim_fs *fs)
@@ -42,7 +42,6 @@
#define uninitialized_var(x) x = x
-#define SMS_BACKUP_MODE 0600
#define SMS_BACKUP_PATH STORAGEDIR "/%s/sms_assembly"
#define SMS_BACKUP_PATH_DIR SMS_BACKUP_PATH "/%s-%i-%i"
#define SMS_BACKUP_PATH_FILE SMS_BACKUP_PATH_DIR "/%03i"
@@ -2505,8 +2504,7 @@ static gboolean sms_assembly_store(struct sms_assembly *assembly,
len = sms_serialize(buf, sms);
- if (write_file(buf, len, SMS_BACKUP_MODE,
- SMS_BACKUP_PATH_FILE, assembly->imsi, straddr,
+ if (write_file(buf, len, SMS_BACKUP_PATH_FILE, assembly->imsi, straddr,
node->ref, node->max_fragments, seq) != len)
return FALSE;
@@ -2889,7 +2887,7 @@ static gboolean sr_assembly_add_fragment_backup(const char *imsi,
return FALSE;
/* storagedir/%s/sms_sr/%s-%s */
- if (write_file((unsigned char *) node, len, SMS_BACKUP_MODE,
+ if (write_file((unsigned char *) node, len,
SMS_SR_BACKUP_PATH_FILE, imsi,
straddr, msgid_str) != len)
return FALSE;
@@ -3370,7 +3368,7 @@ gboolean sms_tx_backup_store(const char *imsi, unsigned long id,
/*
* file name is: imsi/tx_queue/order-flags-uuid/pdu
*/
- if (write_file(buf, len, SMS_BACKUP_MODE, SMS_TX_BACKUP_PATH_FILE,
+ if (write_file(buf, len, SMS_TX_BACKUP_PATH_FILE,
imsi, id, flags, uuid, seq) != len)
return FALSE;
@@ -120,13 +120,14 @@ ssize_t read_file(unsigned char *buffer, size_t len,
* file with a temporary name and when closed, it is renamed to the
* specified name (@path_fmt+args).
*/
-ssize_t write_file(const unsigned char *buffer, size_t len, mode_t mode,
+ssize_t write_file(const unsigned char *buffer, size_t len,
const char *path_fmt, ...)
{
va_list ap;
char *tmp_path, *path;
ssize_t r;
int fd;
+ static const mode_t mode = 0600;
va_start(ap, path_fmt);
path = l_strdup_vprintf(path_fmt, ap);
@@ -28,9 +28,9 @@ ssize_t read_file(unsigned char *buffer, size_t len,
const char *path_fmt, ...)
__attribute__((format(printf, 3, 4)));
-ssize_t write_file(const unsigned char *buffer, size_t len, mode_t mode,
+ssize_t write_file(const unsigned char *buffer, size_t len,
const char *path_fmt, ...)
- __attribute__((format(printf, 4, 5)));
+ __attribute__((format(printf, 3, 4)));
char *storage_get_file_path(const char *imsi, const char *store);
GKeyFile *storage_open(const char *imsi, const char *store);