blob: b3809dd9840580af43889c1213c1302d8d54c1cc [file] [log] [blame]
bigbiff32cbabe2020-04-12 19:16:19 -04001
2#ifndef TWRPAPEX_HPP
3#define TWRPAPEX_HPP
4
5#include <string>
6#include <vector>
7#include <filesystem>
bigbiffb5a20a82021-10-17 20:02:17 -04008#include <regex>
bigbiff79924302021-05-02 20:06:09 -04009#include <sstream>
bigbiff32cbabe2020-04-12 19:16:19 -040010
11#include <sys/types.h>
12#include <sys/stat.h>
13#include <sys/ioctl.h>
14#include <linux/loop.h>
15#include <sys/mount.h>
16#include <sys/sysmacros.h>
17#include <fcntl.h>
18#include <unistd.h>
bigbiffab036612021-06-24 21:31:40 -040019#include <android-base/properties.h>
bigbiff32cbabe2020-04-12 19:16:19 -040020
21#include <ziparchive/zip_archive.h>
22#include "twcommon.h"
23
bigbiff32cbabe2020-04-12 19:16:19 -040024#define APEX_DIR "/system_root/system/apex"
25#define APEX_PAYLOAD "apex_payload.img"
26#define LOOP_BLOCK_DEVICE_DIR "/dev/block/"
bigbiffad58e1b2020-07-06 20:24:34 -040027#define APEX_BASE "/apex/"
bigbiff0e97f7e2021-02-25 10:16:59 -050028#define LOOP_CONTROL "/dev/loop-control"
bigbiff32cbabe2020-04-12 19:16:19 -040029
30class twrpApex {
31public:
32 bool loadApexImages();
bigbiffcfa875c2021-06-20 16:20:27 -040033 bool Unmount();
bigbiff32cbabe2020-04-12 19:16:19 -040034
35private:
36 std::string unzipImage(std::string file);
bigbiff0e97f7e2021-02-25 10:16:59 -050037 bool mountApexOnLoopbackDevices(std::vector<std::string> apexFiles);
bigbiff32cbabe2020-04-12 19:16:19 -040038 bool loadApexImage(std::string fileToMount, size_t loop_device_number);
39};
40#endif