mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-29 16:10:52 +00:00
* Implement r_fs_view() method to set visibility options for filesystems
- Added enum for VIEW_{DELETED|SPECIAL} ... - Implement support for listing deleted files for FAT. - Experimental state * Add 'fs.view' eval variable - values normal, all, deleted and special - only 3 letters are checked 'del' and 'spe' are ok * Add missing include files
This commit is contained in:
parent
c2d5f9215b
commit
a3050fce7b
1
binr/rarc2/config.h
Normal file
1
binr/rarc2/config.h
Normal file
@ -0,0 +1 @@
|
||||
#define SYNTAX_ATT 1
|
@ -241,6 +241,24 @@ static int config_tracetag_callback(void *user, void *data) {
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
static int config_fsview_callback(void *user, void *data) {
|
||||
int type = R_FS_VIEW_NORMAL;
|
||||
RCore *core = (RCore *) user;
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
if (!strcmp (node->value, "?")) {
|
||||
eprintf ("Values: all|deleted|special\n");
|
||||
return R_FALSE;
|
||||
}
|
||||
if (!strcmp (node->value, "all"))
|
||||
type = R_FS_VIEW_ALL;
|
||||
if (!strstr (node->value, "del"))
|
||||
type |= R_FS_VIEW_DELETED;
|
||||
if (!strstr (node->value, "spe"))
|
||||
type |= R_FS_VIEW_SPECIAL;
|
||||
r_fs_view (core->fs, type);
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
static int config_scrprompt_callback(void *user, void *data) {
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
r_line_singleton()->echo = node->i_value;
|
||||
@ -377,6 +395,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
r_config_set_cb (cfg, "dbg.swstep", "false", &config_swstep_callback);
|
||||
r_config_set_cb (cfg, "dbg.trace", "true", &config_trace_callback);
|
||||
r_config_set_cb (cfg, "dbg.trace.tag", "0xff", &config_tracetag_callback);
|
||||
r_config_set_cb (cfg, "fs.view", "normal", &config_fsview_callback);
|
||||
r_config_set (cfg, "cmd.hit", "");
|
||||
r_config_set (cfg, "cmd.open", "");
|
||||
r_config_set (cfg, "cmd.prompt", "");
|
||||
@ -589,6 +608,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
snprintf(buf, 1023, "%s/.radare/rdb/", getenv("HOME"));
|
||||
config_set("dir.project", buf); // ~/.radare/rdb/
|
||||
config_set("dir.tmp", get_tmp_dir());
|
||||
config_set_cb ("fs.view", "normal");
|
||||
config_set("graph.color", "magic");
|
||||
config_set("graph.split", "false"); // split blocks // SHOULD BE TRUE, but true algo is buggy
|
||||
config_set("graph.jmpblocks", "true");
|
||||
|
@ -11,6 +11,7 @@ R_API RFS *r_fs_new () {
|
||||
RFSPlugin *static_plugin;
|
||||
RFS *fs = R_NEW (RFS);
|
||||
if (fs) {
|
||||
fs->view = R_FS_VIEW_NORMAL;
|
||||
fs->roots = r_list_new ();
|
||||
fs->roots->free = (RListFree)r_fs_root_free;
|
||||
fs->plugins = r_list_new ();
|
||||
@ -178,7 +179,7 @@ R_API RList *r_fs_dir(RFS* fs, const char *p) {
|
||||
else
|
||||
dir = path + strlen (root->path);
|
||||
if (!*dir) dir = "/";
|
||||
ret = root->p->dir (root, dir);
|
||||
ret = root->p->dir (root, dir, fs->view);
|
||||
} else eprintf ("r_fs_dir: not mounted '%s'\n", path);
|
||||
free (path);
|
||||
return ret;
|
||||
@ -489,3 +490,7 @@ R_API int r_fs_prompt (RFS *fs, char *root) {
|
||||
printf ("\n");
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
R_API void r_fs_view (RFS *fs, int view) {
|
||||
fs->view = view;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ static int dirhook (const char *filename, const struct grub_dirhook_info *info,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static RList *FSP(_dir)(RFSRoot *root, const char *path) {
|
||||
static RList *FSP(_dir)(RFSRoot *root, const char *path, int view) {
|
||||
GrubFS *gfs = root->ptr;
|
||||
if (root == NULL) {
|
||||
return NULL;
|
||||
|
@ -31,7 +31,7 @@ static void fs_posix_close(RFSFile *file) {
|
||||
//fclose (file->ptr);
|
||||
}
|
||||
|
||||
static RList *fs_posix_dir(RFSRoot *root, const char *path) {
|
||||
static RList *fs_posix_dir(RFSRoot *root, const char *path, int view /*ignored*/) {
|
||||
char fullpath[4096];
|
||||
RList *list;
|
||||
struct stat st;
|
||||
@ -55,8 +55,9 @@ static RList *fs_posix_dir(RFSRoot *root, const char *path) {
|
||||
return list;
|
||||
}
|
||||
|
||||
static void fs_posix_mount(RFSRoot *root) {
|
||||
static int fs_posix_mount(RFSRoot *root) {
|
||||
root->ptr = NULL; // XXX: TODO
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
static void fs_posix_umount(RFSRoot *root) {
|
||||
@ -69,7 +70,7 @@ struct r_fs_plugin_t r_fs_plugin_posix = {
|
||||
.open = fs_posix_open,
|
||||
.read = fs_posix_read,
|
||||
.close = fs_posix_close,
|
||||
.dir = fs_posix_dir,
|
||||
.dir = &fs_posix_dir,
|
||||
.mount = fs_posix_mount,
|
||||
.umount = fs_posix_umount,
|
||||
};
|
||||
|
@ -17,7 +17,9 @@
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <r_fs.h>
|
||||
#include <grub/fs.h>
|
||||
#include <grub/fshelp.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/types.h>
|
||||
@ -536,6 +538,7 @@ grub_fat_iterate_dir (grub_disk_t disk, struct grub_fat_data *data,
|
||||
}
|
||||
|
||||
/* Check if this entry is valid. */
|
||||
if (!(grub_fshelp_view & R_FS_VIEW_DELETED))
|
||||
if (dir.name[0] == 0xe5 || (dir.attr & ~GRUB_FAT_ATTR_VALID))
|
||||
continue;
|
||||
|
||||
|
@ -23,10 +23,13 @@
|
||||
#include <grub/disk.h>
|
||||
#include <grub/fshelp.h>
|
||||
|
||||
GRUB_EXPORT(grub_fshelp_view);
|
||||
GRUB_EXPORT(grub_fshelp_find_file);
|
||||
GRUB_EXPORT(grub_fshelp_log2blksize);
|
||||
GRUB_EXPORT(grub_fshelp_read_file);
|
||||
|
||||
int grub_fshelp_view = 0;
|
||||
|
||||
struct grub_fshelp_find_file_closure
|
||||
{
|
||||
grub_fshelp_node_t rootnode;
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
typedef struct grub_fshelp_node *grub_fshelp_node_t;
|
||||
|
||||
extern int grub_fshelp_view;
|
||||
#define GRUB_FSHELP_CASE_INSENSITIVE 0x100
|
||||
#define GRUB_FSHELP_TYPE_MASK 0xff
|
||||
#define GRUB_FSHELP_FLAGS_MASK 0x100
|
||||
@ -67,7 +68,7 @@ grub_err_t grub_fshelp_find_file (const char *path,
|
||||
beginning with the block POS. READ_HOOK should be set before
|
||||
reading a block from the file. GET_BLOCK is used to translate file
|
||||
blocks to disk blocks. The file is FILESIZE bytes big and the
|
||||
blocks have a size of LOG2BLOCKSIZE (in log2). */
|
||||
blocks have a size of LOG2BLOCKSIZE (in log2).
|
||||
grub_ssize_t grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
|
||||
void (*read_hook)
|
||||
(grub_disk_addr_t sector,
|
||||
@ -80,6 +81,7 @@ grub_ssize_t grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
|
||||
(grub_fshelp_node_t node,
|
||||
grub_disk_addr_t block),
|
||||
grub_off_t filesize, int log2blocksize);
|
||||
*/
|
||||
|
||||
unsigned int grub_fshelp_log2blksize (unsigned int blksize,
|
||||
unsigned int *pow);
|
||||
|
@ -13,6 +13,7 @@ typedef struct r_fs_t {
|
||||
RIOBind iob;
|
||||
RList /*<RFSPlugin>*/ *plugins;
|
||||
RList /*<RFSRoot>*/ *roots;
|
||||
int view;
|
||||
void *ptr;
|
||||
} RFS;
|
||||
|
||||
@ -45,7 +46,7 @@ typedef struct r_fs_plugin_t {
|
||||
RFSFile* (*open)(RFSRoot *root, const char *path);
|
||||
boolt (*read)(RFSFile *fs, ut64 addr, int len);
|
||||
void (*close)(RFSFile *fs);
|
||||
RList *(*dir)(RFSRoot *root, const char *path);
|
||||
RList *(*dir)(RFSRoot *root, const char *path, int view);
|
||||
void (*init)();
|
||||
void (*fini)();
|
||||
int (*mount)(RFSRoot *root);
|
||||
@ -62,10 +63,20 @@ typedef struct r_fs_partition_t {
|
||||
|
||||
#define R_FS_FILE_TYPE_DIRECTORY 'd'
|
||||
#define R_FS_FILE_TYPE_REGULAR 'r'
|
||||
#define R_FS_FILE_TYPE_DELETED 'x'
|
||||
#define R_FS_FILE_TYPE_SPECIAL 's'
|
||||
#define R_FS_FILE_TYPE_MOUNT 'm'
|
||||
|
||||
enum {
|
||||
R_FS_VIEW_NORMAL = 0,
|
||||
R_FS_VIEW_DELETED = 1,
|
||||
R_FS_VIEW_SPECIAL = 2,
|
||||
R_FS_VIEW_ALL = 0xff,
|
||||
};
|
||||
|
||||
#ifdef R_API
|
||||
|
||||
R_API RFS *r_fs_new ();
|
||||
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);
|
||||
@ -114,7 +125,5 @@ extern RFSPlugin r_fs_plugin_xfs;
|
||||
extern RFSPlugin r_fs_plugin_fb;
|
||||
extern RFSPlugin r_fs_plugin_minix;
|
||||
extern RFSPlugin r_fs_plugin_posix;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user