All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] simfs: Cache flushing functions.
@ 2010-12-10 13:59 Andrzej Zaborowski
  2010-12-10 13:59 ` [PATCH 2/5][RfC] Add SIM filesystem watch api Andrzej Zaborowski
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Andrzej Zaborowski @ 2010-12-10 13:59 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2149 bytes --]

---
 src/simfs.c |   35 +++++++++++++++++++++++++++--------
 src/simfs.h |    2 ++
 2 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/src/simfs.c b/src/simfs.c
index 8e52f7b..2f58d9b 100644
--- a/src/simfs.c
+++ b/src/simfs.c
@@ -903,17 +903,39 @@ void sim_fs_check_version(struct sim_fs *fs)
 	const char *imsi = ofono_sim_get_imsi(fs->sim);
 	enum ofono_sim_phase phase = ofono_sim_get_phase(fs->sim);
 	unsigned char version;
-	struct dirent **entries;
-	int len;
-	char *path;
 
 	if (read_file(&version, 1, SIM_CACHE_VERSION, imsi, phase) == 1)
 		if (version == SIM_FS_VERSION)
 			return;
 
-	path = g_strdup_printf(SIM_CACHE_BASEPATH, imsi, phase);
+	sim_fs_cache_flush(fs,  0);
+
+	version = SIM_FS_VERSION;
+	write_file(&version, 1, SIM_CACHE_MODE, SIM_CACHE_VERSION, imsi, phase);
+}
+
+void sim_fs_cache_flush(struct sim_fs *fs, int id)
+{
+	const char *imsi = ofono_sim_get_imsi(fs->sim);
+	enum ofono_sim_phase phase = ofono_sim_get_phase(fs->sim);
+	int len;
+	char *path;
+	struct dirent **entries;
+
+	/* Id of 0 flushes all cache content */
+	if (id > 0) {
+		path = g_strdup_printf(SIM_CACHE_PATH, imsi, phase, id);
+		remove(path);
+		g_free(path);
+
+		path = g_strdup_printf(SIM_IMAGE_CACHE_PATH, imsi, phase, id);
+		remove(path);
+		g_free(path);
+
+		return;
+	}
 
-	ofono_info("Detected old simfs version in %s, removing", path);
+	path = g_strdup_printf(SIM_CACHE_BASEPATH, imsi, phase);
 	len = scandir(path, &entries, NULL, alphasort);
 	g_free(path);
 
@@ -940,7 +962,4 @@ void sim_fs_check_version(struct sim_fs *fs)
 
 		g_free(entries);
 	}
-
-	version = SIM_FS_VERSION;
-	write_file(&version, 1, SIM_CACHE_MODE, SIM_CACHE_VERSION, imsi, phase);
 }
diff --git a/src/simfs.h b/src/simfs.h
index ef962db..ace25bf 100644
--- a/src/simfs.h
+++ b/src/simfs.h
@@ -47,4 +47,6 @@ char *sim_fs_get_cached_image(struct sim_fs *fs, int id);
 
 void sim_fs_cache_image(struct sim_fs *fs, const char *image, int id);
 
+void sim_fs_cache_flush(struct sim_fs *fs, int id);
+
 void sim_fs_free(struct sim_fs *fs);
-- 
1.7.1.86.g0e460.dirty


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-12-23  2:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-10 13:59 [PATCH 1/5] simfs: Cache flushing functions Andrzej Zaborowski
2010-12-10 13:59 ` [PATCH 2/5][RfC] Add SIM filesystem watch api Andrzej Zaborowski
2010-12-10 13:59 ` [PATCH 3/5][RfC] sim: Implement file watching and basic refresh Andrzej Zaborowski
2010-12-10 13:59 ` [PATCH 4/5][RfC] sim: Watch files we keep in memory Andrzej Zaborowski
2010-12-10 13:59 ` [PATCH 5/5][RfC] stk: Partially handle Refresh command Andrzej Zaborowski
2010-12-23  2:57 ` [PATCH 1/5] simfs: Cache flushing functions Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.