Autodetect and mount ISO9660 partitions

This commit is contained in:
pancake 2017-11-06 23:58:50 +01:00
parent 2e08b0c91f
commit 5fc5137c70
5 changed files with 18 additions and 13 deletions

View File

@ -1102,7 +1102,8 @@ int main(int argc, char **argv, char **envp) {
return 1;
}
if (r.bin->cur && r.bin->cur->o && r.bin->cur->o->info && r.bin->cur->o->info->rclass && !strcmp ("fs", r.bin->cur->o->info->rclass)) {
r_core_cmd0 (&r, "m /root @ 0");
const char *fstype = r.bin->cur->o->info->bclass;
r_core_cmdf (&r, "m /root %s @ 0", fstype);
}
iod = r.io ? r_io_desc_get (r.io, fh->fd) : NULL;
#if USE_THREADS

View File

@ -15,20 +15,21 @@ static char *fsname(const ut8* buf, ut64 length) {
len = R_MIN (f->buflen, sizeof (fs_lbuf));
memset (fs_lbuf, 0, sizeof (fs_lbuf));
if (f->bufoff + len > length) break;
if (f->bufoff + len > length) {
break;
}
memcpy (fs_lbuf, buf + f->bufoff, len);
if ((f->buflen > 0) && (len >= f->buflen)) {
if ((f->buflen > 0) && len >= f->buflen) {
int min = R_MIN (f->buflen, sizeof (fs_lbuf));
if (!memcmp (fs_lbuf, f->buf, min)) {
ret = true;
len = R_MIN (f->bytelen, sizeof (fs_lbuf));
if (f->byteoff + len > length) break;
if (f->byteoff + len > length) {
break;
}
memcpy (fs_lbuf, buf + f->byteoff, len);
for (j = 0; j < f->bytelen; j++) {
// for (j = 0; j < f->bytelen; j++) {
for (j = 0; j < len; j++) {
if (fs_lbuf[j] != f->byte) {
ret = false;
break;

View File

@ -77,7 +77,8 @@ static int cmd_mount(void *data, const char *_input) {
} else {
if (!(ptr = r_fs_name (core->fs, core->offset))) {
eprintf ("Unknown filesystem type\n");
} else if (!r_fs_mount (core->fs, ptr, input, core->offset)) {
}
if (!r_fs_mount (core->fs, ptr, input, core->offset)) {
eprintf ("Cannot mount %s\n", input);
}
free (ptr);

View File

@ -109,8 +109,8 @@ R_API RFSRoot* r_fs_mount(RFS* fs, const char* fstype, const char* path, ut64 de
eprintf ("r_fs_mount: invalid mountpoint %s\n", path);
return NULL;
}
if (!fstype) {
fstype = r_fs_name(fs, delta);
if (!fstype || !*fstype) {
fstype = r_fs_name (fs, delta);
}
if (!(p = r_fs_plugin_get (fs, fstype))) {
// eprintf ("r_fs_mount: Invalid filesystem type\n");
@ -645,7 +645,8 @@ R_API char* r_fs_name(RFS* fs, ut64 offset) {
ret = true;
len = R_MIN (f->bytelen, sizeof (buf));
fs->iob.read_at (fs->iob.io, offset + f->byteoff, buf, len);
for (j = 0; j < f->bytelen; j++) {
// for (j = 0; j < f->bytelen; j++) {
for (j = 0; j < len; j++) {
if (buf[j] != f->byte) {
ret = false;
break;

View File

@ -15,5 +15,6 @@ static RFSType fstypes[] = {
{ "fat", 0x52, "FAT32", 5, 0, 0, 0 },
{ "ext2", 0x438, "\x53\xef", 2, 0, 0, 0 },
{ "btrfs", 0x10040, "_BHRfS_M", 8, 0, 0, 0x0 },
{ "iso9660", 0x8000, "\x01" "CD0", 4, 0, 0, 0x8000 },
{ NULL }
};