mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-11-08 07:23:29 +00:00
Migrate MagiskBoot to C++
This commit is contained in:
@@ -3,9 +3,26 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "vector.h"
|
||||
#include "array.h"
|
||||
|
||||
typedef struct cpio_entry {
|
||||
struct cpio_newc_header {
|
||||
char magic[6];
|
||||
char ino[8];
|
||||
char mode[8];
|
||||
char uid[8];
|
||||
char gid[8];
|
||||
char nlink[8];
|
||||
char mtime[8];
|
||||
char filesize[8];
|
||||
char devmajor[8];
|
||||
char devminor[8];
|
||||
char rdevmajor[8];
|
||||
char rdevminor[8];
|
||||
char namesize[8];
|
||||
char check[8];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct cpio_entry {
|
||||
// uint32_t ino;
|
||||
uint32_t mode;
|
||||
uint32_t uid;
|
||||
@@ -21,40 +38,31 @@ typedef struct cpio_entry {
|
||||
// uint32_t check;
|
||||
char *filename;
|
||||
void *data;
|
||||
int remove;
|
||||
} cpio_entry;
|
||||
|
||||
typedef struct cpio_newc_header {
|
||||
char magic[6];
|
||||
char ino[8];
|
||||
char mode[8];
|
||||
char uid[8];
|
||||
char gid[8];
|
||||
char nlink[8];
|
||||
char mtime[8];
|
||||
char filesize[8];
|
||||
char devmajor[8];
|
||||
char devminor[8];
|
||||
char rdevmajor[8];
|
||||
char rdevminor[8];
|
||||
char namesize[8];
|
||||
char check[8];
|
||||
} cpio_newc_header;
|
||||
cpio_entry() {}
|
||||
cpio_entry(int fd, cpio_newc_header &header);
|
||||
~cpio_entry();
|
||||
};
|
||||
|
||||
// Basic cpio functions
|
||||
void cpio_free(cpio_entry *e);
|
||||
int cpio_find(struct vector *v, const char *entry);
|
||||
int cpio_cmp(const void *a, const void *b);
|
||||
void parse_cpio(struct vector *v, const char *filename);
|
||||
void dump_cpio(struct vector *v, const char *filename);
|
||||
void cpio_vec_insert(struct vector *v, cpio_entry *n);
|
||||
void cpio_vec_destroy(struct vector *v);
|
||||
void cpio_rm(struct vector *v, int recursive, const char *entry);
|
||||
void cpio_mkdir(struct vector *v, mode_t mode, const char *entry);
|
||||
void cpio_ln(struct vector *v, const char *target, const char *entry);
|
||||
void cpio_add(struct vector *v, mode_t mode, const char *entry, const char *filename);
|
||||
int cpio_mv(struct vector *v, const char *from, const char *to);
|
||||
int cpio_extract(struct vector *v, const char *entry, const char *filename);
|
||||
void cpio_extract_all(struct vector *v);
|
||||
class cpio {
|
||||
public:
|
||||
cpio(const char *filename);
|
||||
~cpio();
|
||||
void dump(const char *file);
|
||||
int find(const char *name);
|
||||
void insert(cpio_entry *e);
|
||||
void rm(int recur, const char *name);
|
||||
void makedir(mode_t mode, const char *name);
|
||||
void ln(const char *target, const char *name);
|
||||
void add(mode_t mode, const char *name, const char *file);
|
||||
void insert(Array<cpio_entry *> &arr);
|
||||
bool mv(const char *from, const char *to);
|
||||
void extract();
|
||||
bool extract(const char *name, const char *file);
|
||||
void sort();
|
||||
|
||||
protected:
|
||||
Array<cpio_entry *> arr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user