summaryrefslogtreecommitdiff
path: root/src/extract_v3.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2021-11-05 13:20:19 +0200
committerTimo Teräs <timo.teras@iki.fi>2021-11-09 21:50:11 +0200
commita6736532001fd625f1ab3dd82abc2a4c5366c79c (patch)
tree47ead4bc00519f0b1e3ea52bf576da5bb8b66530 /src/extract_v3.c
parentd441cf523cea6ab2d2ee1c0f50fab0bb620f2ea1 (diff)
downloadapk-tools-a6736532001fd625f1ab3dd82abc2a4c5366c79c.tar.gz
apk-tools-a6736532001fd625f1ab3dd82abc2a4c5366c79c.tar.bz2
apk-tools-a6736532001fd625f1ab3dd82abc2a4c5366c79c.tar.xz
apk-tools-a6736532001fd625f1ab3dd82abc2a4c5366c79c.zip
database: implement uvol support
by adding an abstraction layer to the file system
Diffstat (limited to 'src/extract_v3.c')
-rw-r--r--src/extract_v3.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/extract_v3.c b/src/extract_v3.c
index dcc5c24..c25b2ae 100644
--- a/src/extract_v3.c
+++ b/src/extract_v3.c
@@ -22,15 +22,6 @@ struct apk_extract_v3_ctx {
struct apk_pathbuilder pb;
};
-static const char *uvol_detect(struct apk_ctx *ac, const char *path)
-{
- if (!apk_ctx_get_uvol(ac)) return 0;
- if (strncmp(path, "uvol", 4) != 0) return 0;
- if (path[4] == 0) return path;
- if (path[4] == '/') return &path[5];
- return 0;
-}
-
static void apk_extract_v3_acl(struct apk_file_info *fi, struct adb_obj *o, struct apk_id_cache *idc)
{
fi->mode = adb_ro_int(o, ADBI_ACL_MODE);
@@ -41,11 +32,9 @@ static void apk_extract_v3_acl(struct apk_file_info *fi, struct adb_obj *o, stru
static int apk_extract_v3_file(struct apk_extract_ctx *ectx, off_t sz, struct apk_istream *is)
{
struct apk_extract_v3_ctx *ctx = ectx->pctx;
- struct apk_ctx *ac = ectx->ac;
const char *path_name = apk_pathbuilder_cstr(&ctx->pb);
struct apk_file_info fi = {
.name = path_name,
- .uvol_name = uvol_detect(ac, path_name),
.size = adb_ro_int(&ctx->file, ADBI_FI_SIZE),
.mtime = adb_ro_int(&ctx->file, ADBI_FI_MTIME),
};
@@ -92,23 +81,18 @@ static int apk_extract_v3_file(struct apk_extract_ctx *ectx, off_t sz, struct ap
if (fi.digest.alg == APK_DIGEST_NONE) return -APKE_ADB_SCHEMA;
fi.mode |= S_IFREG;
- r = ectx->ops->file(ectx, &fi, apk_istream_verify(&dis, is, &fi.digest));
- if (r == APK_EXTRACT_SKIP_FILE)
- return 0;
+ r = ectx->ops->file(ectx, &fi, apk_istream_verify(&dis, is, fi.size, &fi.digest));
return apk_istream_close_error(&dis.is, r);
}
static int apk_extract_v3_directory(struct apk_extract_ctx *ectx)
{
struct apk_extract_v3_ctx *ctx = ectx->pctx;
- struct apk_ctx *ac = ectx->ac;
struct apk_file_info fi = {
.name = apk_pathbuilder_cstr(&ctx->pb),
};
struct adb_obj acl;
- if (uvol_detect(ac, fi.name)) return 0;
-
apk_extract_v3_acl(&fi, adb_ro_obj(&ctx->path, ADBI_DI_ACL, &acl), apk_ctx_get_id_cache(ectx->ac));
fi.mode |= S_IFDIR;
@@ -263,3 +247,16 @@ int apk_extract_v3(struct apk_extract_ctx *ectx, struct apk_istream *is)
return r;
}
+
+int apk_extract(struct apk_extract_ctx *ectx, struct apk_istream *is)
+{
+ void *sig;
+
+ if (IS_ERR(is)) return PTR_ERR(is);
+
+ sig = apk_istream_peek(is, 4);
+ if (IS_ERR(sig)) return apk_istream_close_error(is, PTR_ERR(sig));
+
+ if (memcmp(sig, "ADB", 3) == 0) return apk_extract_v3(ectx, is);
+ return apk_extract_v2(ectx, is);
+}