summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2017-05-25 18:04:41 +0300
committerTimo Teräs <timo.teras@iki.fi>2017-10-06 16:17:24 +0300
commit493a9c03951303a305e2545b9a2dbf8f0176e845 (patch)
treefcbc01eaeff39ca229c927d0bbd1dc6fbabff493
parentcb8ddb0f98f1bc445fef880ab790de0f133e2a96 (diff)
downloadapk-tools-493a9c03951303a305e2545b9a2dbf8f0176e845.tar.gz
apk-tools-493a9c03951303a305e2545b9a2dbf8f0176e845.tar.bz2
apk-tools-493a9c03951303a305e2545b9a2dbf8f0176e845.tar.xz
apk-tools-493a9c03951303a305e2545b9a2dbf8f0176e845.zip
db: fix regression preventing remounting apk cache r/w
Introduced in commit c0f2d88f342f4d185f3991f98b79ab61a03896e4. fstatfs is needed to inspect the mount flags. (cherry picked from commit ede5165833b94051ecbc35e9ac4a359f54cc0116)
-rw-r--r--src/database.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/database.c b/src/database.c
index 9c0c5ae..4d16900 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1603,7 +1603,7 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
/* figure out where to have the cache */
fd = openat(db->root_fd, dbopts->cache_dir, O_RDONLY | O_CLOEXEC);
- if (fd >= 0) {
+ if (fd >= 0 && fstatfs(fd, &stfs) == 0) {
db->cache_dir = dbopts->cache_dir;
db->cache_fd = fd;
db->cache_remount_flags = map_statfs_flags(stfs.f_flags);
@@ -1622,6 +1622,7 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
}
}
} else {
+ if (fd >= 0) close(fd);
db->cache_dir = apk_static_cache_dir;
db->cache_fd = openat(db->root_fd, db->cache_dir, O_RDONLY | O_CLOEXEC);
}