From ae4008c4f2fef65a8507b0ac9af83e52a2859e3c Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Tue, 28 Dec 2021 16:38:31 -0600 Subject: database: refactor cache remounting --- src/database.c | 20 +++++++++++++++----- 1 file 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); -- cgit v1.2.3-70-g09d2