summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAriadne Conill <ariadne@dereferenced.org>2021-12-28 16:38:31 -0600
committerTimo Teräs <timo.teras@iki.fi>2021-12-29 20:37:28 +0200
commitae4008c4f2fef65a8507b0ac9af83e52a2859e3c (patch)
tree0be1462f2ca3bb2c1618f326f970153f7b369380
parent4fa6a9fd73bfcbf4e2a76e2a6b23c35eebbab5a7 (diff)
downloadapk-tools-ae4008c4f2fef65a8507b0ac9af83e52a2859e3c.tar.gz
apk-tools-ae4008c4f2fef65a8507b0ac9af83e52a2859e3c.tar.bz2
apk-tools-ae4008c4f2fef65a8507b0ac9af83e52a2859e3c.tar.xz
apk-tools-ae4008c4f2fef65a8507b0ac9af83e52a2859e3c.zip
database: refactor cache remounting
-rw-r--r--src/database.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/database.c b/src/database.c
index 691603a..8998f6a 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1535,6 +1535,15 @@ static int setup_cache(struct apk_database *db, struct apk_ctx *ac)
return 0;
}
+
+static void remount_cache(struct apk_database *db)
+{
+ if (db->cache_remount_dir) {
+ mount(0, db->cache_remount_dir, 0, MS_REMOUNT | db->cache_remount_flags, 0);
+ free(db->cache_remount_dir);
+ db->cache_remount_dir = NULL;
+ }
+}
#else
static int detect_tmpfs_root(struct apk_database *db)
{
@@ -1546,6 +1555,11 @@ static int setup_cache(struct apk_database *db, struct apk_ctx *ac)
{
return setup_static_cache(db, ac);
}
+
+static void remount_cache(struct apk_database *db)
+{
+ (void) db;
+}
#endif
void apk_db_init(struct apk_database *db)
@@ -1819,11 +1833,7 @@ void apk_db_close(struct apk_database *db)
db->root_proc_dir = NULL;
}
- if (db->cache_remount_dir) {
- mount(0, db->cache_remount_dir, 0, MS_REMOUNT | db->cache_remount_flags, 0);
- free(db->cache_remount_dir);
- db->cache_remount_dir = NULL;
- }
+ remount_cache(db);
if (db->cache_fd > 0) close(db->cache_fd);
if (db->lock_fd > 0) close(db->lock_fd);