2014-03-27 16:34:17 +01:00
|
|
|
#ifndef R2_FS_H
|
|
|
|
#define R2_FS_H
|
2011-01-07 18:22:02 +01:00
|
|
|
|
|
|
|
#include <r_types.h>
|
2011-01-12 00:01:06 +01:00
|
|
|
#include <r_list.h>
|
2017-10-23 03:48:48 +02:00
|
|
|
#include <r_bind.h> // RCoreBind
|
|
|
|
#include <r_io.h> // RIOBind
|
2018-11-14 14:54:22 +05:00
|
|
|
#include <r_util.h>
|
2011-01-07 18:22:02 +01:00
|
|
|
|
2013-06-18 12:09:23 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-06-14 02:51:33 +02:00
|
|
|
R_LIB_VERSION_HEADER (r_fs);
|
|
|
|
|
2011-01-12 00:01:06 +01:00
|
|
|
struct r_fs_plugin_t;
|
|
|
|
struct r_fs_root_t;
|
|
|
|
struct r_fs_t;
|
|
|
|
|
2011-01-07 18:22:02 +01:00
|
|
|
typedef struct r_fs_t {
|
|
|
|
RIOBind iob;
|
2017-10-23 03:48:48 +02:00
|
|
|
RCoreBind cob;
|
2011-01-12 00:01:06 +01:00
|
|
|
RList /*<RFSPlugin>*/ *plugins;
|
|
|
|
RList /*<RFSRoot>*/ *roots;
|
2011-05-13 02:31:18 +02:00
|
|
|
int view;
|
2011-01-12 00:01:06 +01:00
|
|
|
void *ptr;
|
2011-01-07 18:22:02 +01:00
|
|
|
} RFS;
|
|
|
|
|
2015-01-28 04:20:10 +01:00
|
|
|
typedef struct r_fs_partition_plugin_t {
|
|
|
|
const char *name;
|
|
|
|
} RFSPartitionPlugin;
|
|
|
|
|
2011-01-12 00:01:06 +01:00
|
|
|
typedef struct r_fs_file_t {
|
|
|
|
char *name;
|
|
|
|
char *path;
|
|
|
|
ut64 off;
|
|
|
|
ut32 size;
|
|
|
|
ut8 *data;
|
|
|
|
void *ctx;
|
|
|
|
char type;
|
|
|
|
ut64 time;
|
2011-01-14 01:02:20 +01:00
|
|
|
struct r_fs_plugin_t *p;
|
|
|
|
struct r_fs_root_t *root;
|
2011-02-21 19:07:57 +01:00
|
|
|
void *ptr; // internal pointer
|
2011-01-12 00:01:06 +01:00
|
|
|
} RFSFile;
|
|
|
|
|
|
|
|
typedef struct r_fs_root_t {
|
|
|
|
char *path;
|
|
|
|
ut64 delta;
|
2011-01-14 01:02:20 +01:00
|
|
|
struct r_fs_plugin_t *p;
|
2011-01-12 00:01:06 +01:00
|
|
|
void *ptr;
|
2011-01-14 01:02:20 +01:00
|
|
|
RIOBind iob;
|
2017-10-23 03:48:48 +02:00
|
|
|
RCoreBind cob;
|
2011-01-12 00:01:06 +01:00
|
|
|
} RFSRoot;
|
|
|
|
|
2011-01-07 18:22:02 +01:00
|
|
|
typedef struct r_fs_plugin_t {
|
|
|
|
const char *name;
|
2011-01-12 00:01:06 +01:00
|
|
|
const char *desc;
|
2017-11-08 00:49:29 +01:00
|
|
|
const char *license;
|
2011-01-14 01:05:23 +01:00
|
|
|
RFSFile* (*slurp)(RFSRoot *root, const char *path);
|
2011-01-14 01:02:20 +01:00
|
|
|
RFSFile* (*open)(RFSRoot *root, const char *path);
|
2016-01-03 02:05:13 +01:00
|
|
|
bool (*read)(RFSFile *fs, ut64 addr, int len);
|
2011-01-12 00:01:06 +01:00
|
|
|
void (*close)(RFSFile *fs);
|
2011-05-13 02:31:18 +02:00
|
|
|
RList *(*dir)(RFSRoot *root, const char *path, int view);
|
2015-01-13 03:40:01 +01:00
|
|
|
void (*init)(void);
|
|
|
|
void (*fini)(void);
|
2011-04-19 10:04:06 +02:00
|
|
|
int (*mount)(RFSRoot *root);
|
2011-01-14 01:02:20 +01:00
|
|
|
void (*umount)(RFSRoot *root);
|
2011-01-07 18:22:02 +01:00
|
|
|
} RFSPlugin;
|
|
|
|
|
2011-01-14 14:41:56 +01:00
|
|
|
typedef struct r_fs_partition_t {
|
2011-05-05 17:32:56 +02:00
|
|
|
int number;
|
2011-01-14 14:41:56 +01:00
|
|
|
ut64 start;
|
|
|
|
ut64 length;
|
|
|
|
int index;
|
|
|
|
int type;
|
|
|
|
} RFSPartition;
|
|
|
|
|
2018-03-21 07:59:39 -03:00
|
|
|
typedef struct r_fs_shell_t {
|
2018-04-24 08:57:17 -03:00
|
|
|
char **cwd;
|
2018-03-21 07:59:39 -03:00
|
|
|
void (*set_prompt)(const char *prompt);
|
|
|
|
const char* (*readline)(void);
|
|
|
|
int (*hist_add)(const char *line);
|
|
|
|
} RFSShell;
|
|
|
|
|
2017-10-23 01:11:43 +02:00
|
|
|
#define R_FS_FILE_TYPE_MOUNTPOINT 'm'
|
2011-01-12 00:01:06 +01:00
|
|
|
#define R_FS_FILE_TYPE_DIRECTORY 'd'
|
|
|
|
#define R_FS_FILE_TYPE_REGULAR 'r'
|
2011-05-13 02:31:18 +02:00
|
|
|
#define R_FS_FILE_TYPE_DELETED 'x'
|
|
|
|
#define R_FS_FILE_TYPE_SPECIAL 's'
|
|
|
|
#define R_FS_FILE_TYPE_MOUNT 'm'
|
2011-01-12 00:01:06 +01:00
|
|
|
|
2015-01-28 04:20:10 +01:00
|
|
|
typedef int (*RFSPartitionIterator)(void *disk, void *ptr, void *user);
|
2011-07-08 00:24:14 +02:00
|
|
|
typedef struct r_fs_partition_type_t {
|
|
|
|
const char *name;
|
2015-01-28 04:20:10 +01:00
|
|
|
void *ptr; // grub_msdos_partition_map
|
|
|
|
RFSPartitionIterator iterate;
|
|
|
|
//RFSPartitionIterator parhook;
|
2011-07-08 00:24:14 +02:00
|
|
|
} RFSPartitionType;
|
|
|
|
#define R_FS_PARTITIONS_LENGTH (int)(sizeof (partitions)/sizeof(RFSPartitionType)-1)
|
|
|
|
|
2011-05-13 02:31:18 +02:00
|
|
|
enum {
|
|
|
|
R_FS_VIEW_NORMAL = 0,
|
|
|
|
R_FS_VIEW_DELETED = 1,
|
|
|
|
R_FS_VIEW_SPECIAL = 2,
|
|
|
|
R_FS_VIEW_ALL = 0xff,
|
|
|
|
};
|
2011-01-12 00:01:06 +01:00
|
|
|
|
2011-05-13 02:31:18 +02:00
|
|
|
#ifdef R_API
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API RFS *r_fs_new(void);
|
2012-07-21 14:11:21 +04:00
|
|
|
R_API void r_fs_view(RFS* fs, int view);
|
|
|
|
R_API void r_fs_free(RFS* fs);
|
|
|
|
R_API void r_fs_add(RFS *fs, RFSPlugin *p);
|
|
|
|
R_API void r_fs_del(RFS *fs, RFSPlugin *p);
|
|
|
|
R_API RFSRoot *r_fs_mount(RFS* fs, const char *fstype, const char *path, ut64 delta);
|
2016-01-03 02:05:13 +01:00
|
|
|
R_API bool r_fs_umount(RFS* fs, const char *path);
|
2012-07-21 14:11:21 +04:00
|
|
|
R_API RList *r_fs_root(RFS *fs, const char *path);
|
|
|
|
R_API RFSFile *r_fs_open(RFS* fs, const char *path);
|
|
|
|
R_API void r_fs_close(RFS* fs, RFSFile *file);
|
|
|
|
R_API int r_fs_read(RFS* fs, RFSFile *file, ut64 addr, int len);
|
2011-01-14 01:05:23 +01:00
|
|
|
R_API RFSFile *r_fs_slurp(RFS* fs, const char *path);
|
2011-01-12 00:01:06 +01:00
|
|
|
R_API RList *r_fs_dir(RFS* fs, const char *path);
|
2012-07-21 14:11:21 +04:00
|
|
|
R_API int r_fs_dir_dump(RFS* fs, const char *path, const char *name);
|
|
|
|
R_API RList *r_fs_find_name(RFS* fs, const char *name, const char *glob);
|
|
|
|
R_API RList *r_fs_find_off(RFS* fs, const char *name, ut64 off);
|
2011-01-14 14:41:56 +01:00
|
|
|
R_API RList *r_fs_partitions(RFS* fs, const char *ptype, ut64 delta);
|
2012-07-21 14:11:21 +04:00
|
|
|
R_API char *r_fs_name(RFS *fs, ut64 offset);
|
|
|
|
R_API int r_fs_prompt(RFS *fs, const char *root);
|
2017-10-23 12:54:03 +02:00
|
|
|
R_API bool r_fs_check(RFS *fs, const char *p);
|
2018-03-21 07:59:39 -03:00
|
|
|
R_API int r_fs_shell_prompt(RFSShell *shell, RFS *fs, const char *root);
|
2011-01-12 00:01:06 +01:00
|
|
|
|
|
|
|
/* file.c */
|
2012-07-21 14:11:21 +04:00
|
|
|
R_API RFSFile *r_fs_file_new(RFSRoot *root, const char *path);
|
|
|
|
R_API void r_fs_file_free(RFSFile *file);
|
|
|
|
R_API RFSRoot *r_fs_root_new(const char *path, ut64 delta);
|
|
|
|
R_API void r_fs_root_free(RFSRoot *root);
|
2011-01-14 14:41:56 +01:00
|
|
|
R_API RFSPartition *r_fs_partition_new(int num, ut64 start, ut64 length);
|
2012-07-21 14:11:21 +04:00
|
|
|
R_API void r_fs_partition_free(RFSPartition *p);
|
|
|
|
R_API const char *r_fs_partition_type(const char *part, int type);
|
|
|
|
R_API const char *r_fs_partition_type_get(int n);
|
2015-01-13 03:40:01 +01:00
|
|
|
R_API int r_fs_partition_get_size(void); // WTF. wrong function name
|
2011-01-12 00:01:06 +01:00
|
|
|
|
|
|
|
/* plugins */
|
2017-10-22 23:52:07 +02:00
|
|
|
extern RFSPlugin r_fs_plugin_io;
|
2017-10-23 03:48:48 +02:00
|
|
|
extern RFSPlugin r_fs_plugin_r2;
|
2011-01-12 00:01:06 +01:00
|
|
|
extern RFSPlugin r_fs_plugin_ext2;
|
* Added r_fs support for the following filesystems:
fat, ntfs, cpio, tar, hfs, hfsplus, udf, iso9660,
reiserfs, ufs, ufs2, xfs and jfs
* Added vapi files for r_fs
2011-01-14 09:45:33 +01:00
|
|
|
extern RFSPlugin r_fs_plugin_fat;
|
|
|
|
extern RFSPlugin r_fs_plugin_ntfs;
|
|
|
|
extern RFSPlugin r_fs_plugin_hfs;
|
|
|
|
extern RFSPlugin r_fs_plugin_hfsplus;
|
|
|
|
extern RFSPlugin r_fs_plugin_reiserfs;
|
|
|
|
extern RFSPlugin r_fs_plugin_tar;
|
|
|
|
extern RFSPlugin r_fs_plugin_iso9660;
|
|
|
|
extern RFSPlugin r_fs_plugin_udf;
|
|
|
|
extern RFSPlugin r_fs_plugin_ufs;
|
|
|
|
extern RFSPlugin r_fs_plugin_ufs2;
|
|
|
|
extern RFSPlugin r_fs_plugin_sfs;
|
|
|
|
extern RFSPlugin r_fs_plugin_tar;
|
|
|
|
extern RFSPlugin r_fs_plugin_btrfs;
|
|
|
|
extern RFSPlugin r_fs_plugin_jfs;
|
|
|
|
extern RFSPlugin r_fs_plugin_afs;
|
|
|
|
extern RFSPlugin r_fs_plugin_affs;
|
|
|
|
extern RFSPlugin r_fs_plugin_cpio;
|
|
|
|
extern RFSPlugin r_fs_plugin_xfs;
|
2011-02-22 10:49:45 +01:00
|
|
|
extern RFSPlugin r_fs_plugin_fb;
|
|
|
|
extern RFSPlugin r_fs_plugin_minix;
|
2011-02-21 18:10:22 +01:00
|
|
|
extern RFSPlugin r_fs_plugin_posix;
|
2011-01-12 00:01:06 +01:00
|
|
|
#endif
|
2013-06-18 12:09:23 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-01-07 18:22:02 +01:00
|
|
|
#endif
|