mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-27 23:20:40 +00:00
Fix mountpoint listing in the rfs
shell ##fs
This commit is contained in:
parent
bd3cc5f205
commit
d7f19855ff
23
libr/fs/fs.c
23
libr/fs/fs.c
@ -3,7 +3,6 @@
|
||||
#include <r_fs.h>
|
||||
#include <config.h>
|
||||
#include "types.h"
|
||||
#include <errno.h>
|
||||
|
||||
#if WITH_GPL
|
||||
# ifndef USE_GRUB
|
||||
@ -22,7 +21,7 @@ static RFSPlugin* fs_static_plugins[] = {
|
||||
R_FS_STATIC_PLUGINS
|
||||
};
|
||||
|
||||
R_API RFS* r_fs_new(void) {
|
||||
R_API R_MUSTUSE RFS* r_fs_new(void) {
|
||||
int i;
|
||||
RFSPlugin* static_plugin;
|
||||
RFS* fs = R_NEW0 (RFS);
|
||||
@ -67,14 +66,13 @@ R_API RFSPlugin* r_fs_plugin_get(RFS* fs, const char* name) {
|
||||
}
|
||||
|
||||
R_API void r_fs_free(RFS* fs) {
|
||||
if (!fs) {
|
||||
return;
|
||||
if (fs) {
|
||||
//r_io_free (fs->iob.io);
|
||||
//root makes use of plugin so revert to avoid UaF
|
||||
r_list_free (fs->roots);
|
||||
r_list_free (fs->plugins);
|
||||
free (fs);
|
||||
}
|
||||
//r_io_free (fs->iob.io);
|
||||
//root makes use of plugin so revert to avoid UaF
|
||||
r_list_free (fs->roots);
|
||||
r_list_free (fs->plugins);
|
||||
free (fs);
|
||||
}
|
||||
|
||||
/* plugins */
|
||||
@ -579,13 +577,8 @@ R_API RList* r_fs_partitions(RFS* fs, const char* ptype, ut64 delta) {
|
||||
return list;
|
||||
}
|
||||
if (R_STR_ISNOTEMPTY (ptype)) {
|
||||
R_LOG_ERROR ("Unknown partition type '%s'", ptype);
|
||||
R_LOG_ERROR ("Unknown partition type '%s'. Use 'mL' command to list them all", ptype);
|
||||
}
|
||||
eprintf ("Supported types:\n");
|
||||
for (i = 0; partitions[i].name; i++) {
|
||||
eprintf (" %s", partitions[i].name);
|
||||
}
|
||||
eprintf ("\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,6 @@ static RList *FSP(_dir)(RFSRoot *root, const char *path, int view) {
|
||||
|
||||
gfs = root->ptr;
|
||||
list = r_list_new ();
|
||||
// eprintf ("r_fs_???_dir: %s\n", path);
|
||||
//gfs->file->device->data = &root->iob;
|
||||
grubfs_bind_io (&root->iob, root->delta);
|
||||
gfs->file->fs->dir (gfs->file->device, path, dirhook, 0);
|
||||
|
@ -57,7 +57,7 @@ static int fs_io_read(RFSFile *file, ut64 addr, int len) {
|
||||
if (res) {
|
||||
int encoded_size = strlen (res);
|
||||
if (encoded_size != len * 2) {
|
||||
eprintf ("Unexpected size (%d vs %d)\n", encoded_size, len*2);
|
||||
R_LOG_ERROR ("Unexpected size (%d vs %d)", encoded_size, len * 2);
|
||||
R_FREE (res);
|
||||
return -1;
|
||||
}
|
||||
@ -68,7 +68,7 @@ static int fs_io_read(RFSFile *file, ut64 addr, int len) {
|
||||
}
|
||||
int ret = r_hex_str2bin (res, file->data);
|
||||
if (ret != len) {
|
||||
eprintf ("Inconsistent read\n");
|
||||
R_LOG_ERROR ("Inconsistent read");
|
||||
R_FREE (file->data);
|
||||
}
|
||||
R_FREE (res);
|
||||
|
@ -120,7 +120,6 @@ static int fs_r2_read(RFSFile *file, ut64 addr, int len) {
|
||||
}
|
||||
|
||||
static void fs_r2_close(RFSFile *file) {
|
||||
// eprintf ("TODO: fs.r2.close\n");
|
||||
//fclose (file->ptr);
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
/* radare2 - LGPL - Copyright 2015-2017 - pancake */
|
||||
|
||||
/* XXX: maybe this should be implemented in RBin */
|
||||
/* we need to extract the code section and get offset flags */
|
||||
/* radare2 - LGPL - Copyright 2015-2022 - pancake */
|
||||
|
||||
#include <r_fs.h>
|
||||
#include <r_types.h>
|
||||
|
||||
R_PACKED (
|
||||
typedef struct {
|
||||
ut8 flag; // 0x80 if active
|
||||
@ -36,11 +34,10 @@ static int fs_part_dos(void *disk, void *ptr, void *closure) {
|
||||
memset (&mbr, 0, sizeof (mbr));
|
||||
fs->iob.read_at (fs->iob.io, 0, (ut8*)&mbr, sizeof (mbr));
|
||||
if (mbr.aa55 != 0xaa55) {
|
||||
eprintf ("Invalid DOS signature at 0x%x\n",
|
||||
(int)r_offsetof (MBR, aa55));
|
||||
R_LOG_ERROR ("Invalid DOS signature at 0x%x", (int)r_offsetof (MBR, aa55));
|
||||
return 0;
|
||||
}
|
||||
for (i=0; i<4; i++) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
ut64 addr, aend;
|
||||
DOS_ENTRY *e = &mbr.entries[i];
|
||||
if (e->type != 0) {
|
||||
|
@ -46,7 +46,7 @@ R_API int r_fs_shell_prompt(RFSShell* shell, RFS* fs, const char* root) {
|
||||
r_str_trim_path (buf);
|
||||
list = r_fs_root (fs, buf);
|
||||
if (r_list_empty (list)) {
|
||||
printf ("Unknown root\n");
|
||||
R_LOG_ERROR ("Unknown root");
|
||||
r_list_free (list);
|
||||
return false;
|
||||
}
|
||||
@ -140,8 +140,7 @@ R_API int r_fs_shell_prompt(RFSShell* shell, RFS* fs, const char* root) {
|
||||
ls++;
|
||||
*ls = 0;
|
||||
}
|
||||
// TODO: adjust contents between //
|
||||
if (r_str_startswith (me, base)) {
|
||||
if (r_str_startswith (base, path)) {
|
||||
cb_printf ("m %s\n", (r->path && r->path[0]) ? r->path + 1: "");
|
||||
}
|
||||
free (base);
|
||||
|
Loading…
Reference in New Issue
Block a user