diff mbox series

[v2,10/18] storage: Remove mode parameter

Message ID 20240202225405.993792-10-denkenz@gmail.com (mailing list archive)
State Accepted
Commit 405039ff9601038d665e0bac18406ae4dd9a6191
Headers show
Series [v2,01/18] umlrunner: Also mount /var/lib as tmpfs | expand

Commit Message

Denis Kenzior Feb. 2, 2024, 10:53 p.m. UTC
Files are always written with owner read and write permissions.  No
other permissions make sense, so remove the mode parameter to simplify
calling code.
---
 src/simfs.c   | 5 ++---
 src/smsutil.c | 8 +++-----
 src/storage.c | 3 ++-
 src/storage.h | 4 ++--
 4 files changed, 9 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/src/simfs.c b/src/simfs.c
index 515f5c97f7a7..38d4852b1886 100644
--- a/src/simfs.c
+++ b/src/simfs.c
@@ -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)
diff --git a/src/smsutil.c b/src/smsutil.c
index f2b6f44c2aa9..d07960190103 100644
--- a/src/smsutil.c
+++ b/src/smsutil.c
@@ -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;
 
diff --git a/src/storage.c b/src/storage.c
index 2313835a49ce..eddb98c79598 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -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);
diff --git a/src/storage.h b/src/storage.h
index 3a1e64493546..76069949e747 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -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);