summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2011-04-22 11:24:02 +0300
committerTimo Teräs <timo.teras@iki.fi>2011-04-22 11:24:33 +0300
commit99010588913344cf037aa163a47acd469fff5594 (patch)
treeadcaefd1c7a0ee4cbad37965438c606dd4e40f4c /src/database.c
parent595c66595c549b7d595463cdfb932afe8d3c3540 (diff)
downloadapk-tools-99010588913344cf037aa163a47acd469fff5594.tar.gz
apk-tools-99010588913344cf037aa163a47acd469fff5594.tar.bz2
apk-tools-99010588913344cf037aa163a47acd469fff5594.tar.xz
apk-tools-99010588913344cf037aa163a47acd469fff5594.zip
db: remount ro cache to rw earlier for update to work
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/database.c b/src/database.c
index 45960d2..bc17ff2 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1263,6 +1263,22 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
}
}
}
+
+ if ((dbopts->open_flags & (APK_OPENF_WRITE | APK_OPENF_CACHE_WRITE)) &&
+ db->ro_cache) {
+ /* remount cache read-write */
+ db->cache_remount_dir = find_mountpoint(db->root_fd, db->cache_dir);
+ if (db->cache_remount_dir == NULL) {
+ apk_warning("Unable to find cache directory mount point");
+ } else if (do_remount(db->cache_remount_dir, "rw") != 0) {
+ free(db->cache_remount_dir);
+ db->cache_remount_dir = NULL;
+ apk_error("Unable to remount cache read-write");
+ r = EROFS;
+ goto ret_r;
+ }
+ }
+
if (!(dbopts->open_flags & APK_OPENF_NO_SYS_REPOS)) {
list_for_each_entry(repo, &dbopts->repository_list, list) {
r = apk_db_add_repository(db, APK_BLOB_STR(repo->url));
@@ -1293,21 +1309,6 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
"might not function properly");
}
- if ((dbopts->open_flags & (APK_OPENF_WRITE | APK_OPENF_CACHE_WRITE)) &&
- db->ro_cache) {
- /* remount cache read-write */
- db->cache_remount_dir = find_mountpoint(db->root_fd, db->cache_dir);
- if (db->cache_remount_dir == NULL) {
- apk_warning("Unable to find cache directory mount point");
- } else if (do_remount(db->cache_remount_dir, "rw") != 0) {
- free(db->cache_remount_dir);
- db->cache_remount_dir = NULL;
- apk_error("Unable to remount cache read-write");
- r = EROFS;
- goto ret_r;
- }
- }
-
return rr;
ret_errno: