From: Denis Kenzior <denkenz@gmail.com>
To: ofono@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH v2 10/18] storage: Remove mode parameter
Date: Fri, 2 Feb 2024 16:53:42 -0600 [thread overview]
Message-ID: <20240202225405.993792-10-denkenz@gmail.com> (raw)
In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com>
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 --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);
--
2.43.0
next prev parent reply other threads:[~2024-02-02 22:55 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-02 22:53 [PATCH v2 01/18] umlrunner: Also mount /var/lib as tmpfs Denis Kenzior
2024-02-02 22:53 ` [PATCH v2 02/18] build: Only enable backtrace(3) in maintainer mode Denis Kenzior
2024-02-02 22:53 ` [PATCH v2 03/18] build: Bring in more ell classes Denis Kenzior
2024-02-02 22:53 ` [PATCH v2 04/18] build: Enable _auto_ syntax Denis Kenzior
2024-02-02 22:53 ` [PATCH v2 05/18] provisiondb: Remove some duplicate MCCMNC entries Denis Kenzior
2024-02-02 22:53 ` [PATCH v2 06/18] storage: Introduce storage_get_file_path() Denis Kenzior
2024-02-02 22:53 ` [PATCH v2 07/18] storage: Convert g_strdup_* use to l_strdup_* Denis Kenzior
2024-02-02 22:53 ` [PATCH v2 08/18] common: Drop GLib use from gprs_auth_proto_to_string Denis Kenzior
2024-02-02 22:53 ` [PATCH v2 09/18] common: Drop GLib use from gprs_proto_to_string Denis Kenzior
2024-02-02 22:53 ` Denis Kenzior [this message]
2024-02-02 22:53 ` [PATCH v2 11/18] storage: Use l_malloc Denis Kenzior
2024-02-02 22:53 ` [PATCH v2 12/18] storage: Remove mode argument Denis Kenzior
2024-02-02 22:53 ` [PATCH v2 13/18] storage: Use void * instead of unsigned char * Denis Kenzior
2024-02-02 22:53 ` [PATCH v2 14/18] storage: use l_file_set_contents Denis Kenzior
2024-02-02 22:53 ` [PATCH v2 15/18] lte: Refactor lte settings management Denis Kenzior
2024-02-02 22:53 ` [PATCH v2 16/18] lte: Add provisioning support Denis Kenzior
2024-02-02 22:53 ` [PATCH v2 17/18] phonesim: Add lte atom Denis Kenzior
2024-02-02 22:53 ` [PATCH v2 18/18] lte: Write provisioned info to disk Denis Kenzior
2024-02-02 23:30 ` [PATCH v2 01/18] umlrunner: Also mount /var/lib as tmpfs patchwork-bot+ofono
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240202225405.993792-10-denkenz@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox