summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2022-02-22 14:03:47 +0200
committerTimo Teräs <timo.teras@iki.fi>2022-02-22 14:03:47 +0200
commit86d75e10f54fb86ed55096674792ccec74a924d0 (patch)
tree52d208ae66923fd20dcdd636bedb50926187b2ea /src
parent3a194ea5d792a1c34ce561c04bf0fa7e575aa949 (diff)
downloadapk-tools-86d75e10f54fb86ed55096674792ccec74a924d0.tar.gz
apk-tools-86d75e10f54fb86ed55096674792ccec74a924d0.tar.bz2
apk-tools-86d75e10f54fb86ed55096674792ccec74a924d0.tar.xz
apk-tools-86d75e10f54fb86ed55096674792ccec74a924d0.zip
db, uvol: commit regular files before uvol volumes
add priority to order fsdir commit sequence
Diffstat (limited to 'src')
-rw-r--r--src/apk_fs.h9
-rw-r--r--src/database.c23
-rw-r--r--src/fs_fsys.c1
-rw-r--r--src/fs_uvol.c1
4 files changed, 30 insertions, 4 deletions
diff --git a/src/apk_fs.h b/src/apk_fs.h
index 6a2a285..1b4a4e2 100644
--- a/src/apk_fs.h
+++ b/src/apk_fs.h
@@ -13,6 +13,9 @@
#include "apk_io.h"
#include "apk_pathbuilder.h"
+#define APK_FS_PRIO_DISK 0
+#define APK_FS_PRIO_UVOL 1
+
#define APK_FS_CTRL_COMMIT 1
#define APK_FS_CTRL_APKNEW 2
#define APK_FS_CTRL_CANCEL 3
@@ -30,6 +33,8 @@ struct apk_fsdir {
};
struct apk_fsdir_ops {
+ uint8_t priority;
+
int (*dir_create)(struct apk_fsdir *, mode_t);
int (*dir_delete)(struct apk_fsdir *);
int (*dir_check)(struct apk_fsdir *, mode_t, uid_t, gid_t);
@@ -47,6 +52,10 @@ int apk_fs_extract(struct apk_ctx *, const struct apk_file_info *, struct apk_is
void apk_fsdir_get(struct apk_fsdir *, apk_blob_t dir, struct apk_ctx *, apk_blob_t);
+static inline uint8_t apk_fsdir_priority(struct apk_fsdir *fs) {
+ return fs->ops->priority;
+}
+
static inline int apk_fsdir_create(struct apk_fsdir *fs, mode_t mode) {
return fs->ops->dir_create(fs, mode);
}
diff --git a/src/database.c b/src/database.c
index a81feb1..bf970b1 100644
--- a/src/database.c
+++ b/src/database.c
@@ -2801,9 +2801,9 @@ static void apk_db_purge_pkg(struct apk_database *db,
}
}
-
-static void apk_db_migrate_files(struct apk_database *db,
- struct apk_installed_package *ipkg)
+static uint8_t apk_db_migrate_files_for_priority(struct apk_database *db,
+ struct apk_installed_package *ipkg,
+ uint8_t priority)
{
struct apk_out *out = &db->ctx->out;
struct apk_db_dir_instance *diri;
@@ -2816,13 +2816,20 @@ static void apk_db_migrate_files(struct apk_database *db,
unsigned long hash;
apk_blob_t dirname;
int r, ctrl;
+ uint8_t dir_priority, next_priority = 0xff;
hlist_for_each_entry_safe(diri, dc, dn, &ipkg->owned_dirs, pkg_dirs_list) {
dir = diri->dir;
- dir->modified = 1;
dirname = APK_BLOB_PTR_LEN(dir->name, dir->namelen);
apk_fsdir_get(&d, dirname, db->ctx, apk_pkg_ctx(ipkg->pkg));
+ dir_priority = apk_fsdir_priority(&d);
+ if (dir_priority != priority) {
+ if (dir_priority > priority && dir_priority < next_priority)
+ next_priority = dir_priority;
+ continue;
+ }
+ dir->modified = 1;
hlist_for_each_entry_safe(file, fc, fn, &diri->owned_files, diri_files_list) {
key = (struct apk_db_file_hash_key) {
.dirname = dirname,
@@ -2883,6 +2890,14 @@ static void apk_db_migrate_files(struct apk_database *db,
}
}
}
+ return next_priority;
+}
+
+static void apk_db_migrate_files(struct apk_database *db,
+ struct apk_installed_package *ipkg)
+{
+ for (uint8_t prio = APK_FS_PRIO_DISK; prio != 0xff; )
+ prio = apk_db_migrate_files_for_priority(db, ipkg, prio);
}
static int apk_db_unpack_pkg(struct apk_database *db,
diff --git a/src/fs_fsys.c b/src/fs_fsys.c
index 42c8a4c..b3ec1d5 100644
--- a/src/fs_fsys.c
+++ b/src/fs_fsys.c
@@ -285,6 +285,7 @@ static int fsys_file_digest(struct apk_fsdir *d, apk_blob_t filename, uint8_t al
}
static const struct apk_fsdir_ops fsdir_ops_fsys = {
+ .priority = APK_FS_PRIO_DISK,
.dir_create = fsys_dir_create,
.dir_delete = fsys_dir_delete,
.dir_check = fsys_dir_check,
diff --git a/src/fs_uvol.c b/src/fs_uvol.c
index d00cdc8..24952cf 100644
--- a/src/fs_uvol.c
+++ b/src/fs_uvol.c
@@ -156,6 +156,7 @@ static int uvol_file_digest(struct apk_fsdir *d, apk_blob_t filename, uint8_t al
}
const struct apk_fsdir_ops fsdir_ops_uvol = {
+ .priority = APK_FS_PRIO_UVOL,
.dir_create = uvol_dir_create,
.dir_delete = uvol_dir_delete,
.dir_check = uvol_dir_check,