mirror of
https://github.com/radareorg/radare2.git
synced 2025-03-01 10:48:05 +00:00
* r_fs_mount returns boolean value for success
This commit is contained in:
parent
a16f3f27b4
commit
194bc4dafd
@ -1061,7 +1061,8 @@ static int cmd_mount(void *data, const char *_input) {
|
||||
off = r_num_math (core->num, ptr2+1);
|
||||
}
|
||||
//r_io_bind (core->io, &(core->fs->iob));
|
||||
r_fs_mount (core->fs, input, ptr, off);
|
||||
if (!r_fs_mount (core->fs, input, ptr, off))
|
||||
eprintf ("Cannot mount %s\n", input);
|
||||
} else eprintf ("Usage: m ext2 /mnt");
|
||||
break;
|
||||
case '-':
|
||||
|
27
libr/fs/fs.c
27
libr/fs/fs.c
@ -69,7 +69,12 @@ R_API RFSRoot *r_fs_mount (RFS* fs, const char *fstype, const char *path, ut64 d
|
||||
root->p = p;
|
||||
//memcpy (&root->iob, &fs->iob, sizeof (root->iob));
|
||||
root->iob = fs->iob;
|
||||
p->mount (root);
|
||||
if (!p->mount (root)) {
|
||||
eprintf ("r_fs_mount: Cannot mount partition\n");
|
||||
free (str);
|
||||
r_fs_root_free (root);
|
||||
return NULL;
|
||||
}
|
||||
r_list_append (fs->roots, root);
|
||||
eprintf ("Mounted %s on %s at 0x%llx\n", fstype, str, 0LL);
|
||||
free (str);
|
||||
@ -156,17 +161,15 @@ R_API int r_fs_read (RFS* fs, RFSFile *file, ut64 addr, int len) {
|
||||
R_API RList *r_fs_dir(RFS* fs, const char *p) {
|
||||
RList *ret = NULL;
|
||||
RFSRoot *root;
|
||||
if (fs) {
|
||||
char *path = strdup (p);
|
||||
r_str_chop_path (path);
|
||||
root = r_fs_root (fs, path);
|
||||
if (root) {
|
||||
const char *dir = path + strlen (root->path);
|
||||
if (!*dir) dir = "/";
|
||||
ret = root->p->dir (root, dir);
|
||||
} else eprintf ("r_fs_dir: not mounted '%s'\n", path);
|
||||
free (path);
|
||||
}
|
||||
char *path = strdup (p);
|
||||
r_str_chop_path (path);
|
||||
root = r_fs_root (fs, path);
|
||||
if (root) {
|
||||
const char *dir = path + strlen (root->path);
|
||||
if (!*dir) dir = "/";
|
||||
ret = root->p->dir (root, dir);
|
||||
} else eprintf ("r_fs_dir: not mounted '%s'\n", path);
|
||||
free (path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,10 @@ static RList *FSP(_dir)(RFSRoot *root, const char *path) {
|
||||
return list;
|
||||
}
|
||||
|
||||
static void FSP(_mount)(RFSRoot *root) {
|
||||
root->ptr = grubfs_new (&FSIPTR, &root->iob);
|
||||
static int FSP(_mount)(RFSRoot *root) {
|
||||
GrubFS *gfs = grubfs_new (&FSIPTR, &root->iob);
|
||||
root->ptr = gfs;
|
||||
return gfs->file->fs->dir (gfs->file->device, "/", NULL, 0)? R_FALSE:R_TRUE;
|
||||
}
|
||||
|
||||
static void FSP(_umount)(RFSRoot *root) {
|
||||
|
@ -48,7 +48,7 @@ typedef struct r_fs_plugin_t {
|
||||
RList *(*dir)(RFSRoot *root, const char *path);
|
||||
void (*init)();
|
||||
void (*fini)();
|
||||
void (*mount)(RFSRoot *root);
|
||||
int (*mount)(RFSRoot *root);
|
||||
void (*umount)(RFSRoot *root);
|
||||
} RFSPlugin;
|
||||
|
||||
|
@ -14,6 +14,7 @@ namespace Radare {
|
||||
public int read(RFSFile file, uint64 addr, int len);
|
||||
public RFSFile slurp(string path);
|
||||
public RList<RFSFile> dir(string path);
|
||||
public RList<RFSRoot> roots;
|
||||
}
|
||||
|
||||
[Compact]
|
||||
|
Loading…
x
Reference in New Issue
Block a user