2017-12-01 09:17:24 +00:00
|
|
|
#ifndef _CPIO_H_
|
|
|
|
#define _CPIO_H_
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "vector.h"
|
|
|
|
|
|
|
|
typedef struct cpio_entry {
|
|
|
|
// uint32_t ino;
|
|
|
|
uint32_t mode;
|
|
|
|
uint32_t uid;
|
|
|
|
uint32_t gid;
|
|
|
|
// uint32_t nlink;
|
|
|
|
// uint32_t mtime;
|
|
|
|
uint32_t filesize;
|
|
|
|
// uint32_t devmajor;
|
|
|
|
// uint32_t devminor;
|
|
|
|
// uint32_t rdevmajor;
|
|
|
|
// uint32_t rdevminor;
|
2017-12-03 19:14:04 +00:00
|
|
|
// uint32_t namesize;
|
2017-12-01 09:17:24 +00:00
|
|
|
// uint32_t check;
|
|
|
|
char *filename;
|
|
|
|
char *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;
|
|
|
|
|
2017-12-03 19:14:04 +00:00
|
|
|
// Basic cpio functions
|
|
|
|
void parse_cpio(struct vector *v, const char *filename);
|
|
|
|
void dump_cpio(struct vector *v, const char *filename);
|
2017-12-01 09:17:24 +00:00
|
|
|
void cpio_vec_destroy(struct vector *v);
|
2017-12-03 19:14:04 +00:00
|
|
|
void cpio_rm(struct vector *v, int recursive, const char *entry);
|
|
|
|
void cpio_mkdir(struct vector *v, mode_t mode, const char *entry);
|
2017-12-03 19:22:26 +00:00
|
|
|
void cpio_ln(struct vector *v, const char *target, const char *entry);
|
2017-12-03 19:14:04 +00:00
|
|
|
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);
|
2017-12-04 19:32:37 +00:00
|
|
|
void cpio_extract_all(struct vector *v);
|
2017-12-03 19:14:04 +00:00
|
|
|
|
|
|
|
// Magisk specific
|
|
|
|
int cpio_test(struct vector *v);
|
2017-12-06 04:51:16 +00:00
|
|
|
struct vector *cpio_backup(struct vector *v, const char *orig, const char *sha1);
|
|
|
|
void cpio_restore(struct vector *v);
|
2017-12-03 19:14:04 +00:00
|
|
|
char *cpio_stocksha1(struct vector *v);
|
2017-12-01 09:17:24 +00:00
|
|
|
|
|
|
|
#endif
|