* 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
This commit is contained in:
pancake 2011-01-14 09:45:33 +01:00
parent 28b9e436c6
commit 08e37d54ab
54 changed files with 509 additions and 139 deletions

View File

@ -6,15 +6,12 @@ LDFLAGS+=${LINK}
foo: all
ALL_TARGETS=
# TODO: rename to enabled plugins
FSS=ext2.mk
include $(FSS)
FILESYSTEMS= ext2.mk fat.mk hfs.mk hfsplus.mk iso9660.mk jfs.mk
FILESYSTEMS+= ntfs.mk reiserfs.mk tar.mk udf.mk ufs2.mk ufs.mk xfs.mk
all: grublib ${ALL_TARGETS}
@true
include $(FILESYSTEMS)
grublib:
all:
cd grub && ${MAKE} lib
clean:

12
libr/fs/p/cpio.mk Normal file
View File

@ -0,0 +1,12 @@
OBJ_CPIO=fs_cpio.o
EXTRA=../p/grub/libgrubfs.a
CFLAGS+=-Igrub/include
STATIC_OBJ+=${OBJ_CPIO}
#STATIC_OBJ+=${EXTRA}
TARGET_CPIO=fs_cpio.${EXT_SO}
ALL_TARGETS+=${TARGET_CPIO}
${TARGET_CPIO}: ${OBJ_CPIO}
${CC} ${LDFLAGS} ${CFLAGS} -o ${TARGET_CPIO} ${OBJ_CPIO} ${EXTRA}

12
libr/fs/p/fat.mk Normal file
View File

@ -0,0 +1,12 @@
OBJ_FAT=fs_fat.o
EXTRA=../p/grub/libgrubfs.a
CFLAGS+=-Igrub/include
STATIC_OBJ+=${OBJ_FAT}
#STATIC_OBJ+=${EXTRA}
TARGET_FAT=fs_fat.${EXT_SO}
ALL_TARGETS+=${TARGET_FAT}
${TARGET_FAT}: ${OBJ_FAT}
${CC} ${LDFLAGS} ${CFLAGS} -o ${TARGET_FAT} ${OBJ_FAT} ${EXTRA}

10
libr/fs/p/fs_cpio.c Normal file
View File

@ -0,0 +1,10 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
#define FSP(x) cpio_##x
#define FSS(x) x##_cpio
#define FSNAME "cpio"
#define FSDESC "CPIO filesystem"
#define FSPRFX cpio
#define FSIPTR grub_cpio_fs
#include "fs_grub_base.c"

View File

@ -1,74 +1,10 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
#include <r_fs.h>
#include "grubfs.h"
#define FSP(x) ext2_##x
#define FSS(x) x##_ext2
#define FSNAME "ext2"
#define FSDESC "ext2 filesystem"
#define FSPRFX ext2
#define FSIPTR grub_ext2_fs
static RFSFile* ext2_open(RFSRoot *root, const char *path) {
RFSFile *file = r_fs_file_new (root, path);
GrubFS *gfs = grubfs_new (&grub_ext2_fs, &root->iob);
file->ptr = gfs;
file->p = root->p;
if (gfs->file->fs->open (gfs->file, path)) {
r_fs_file_free (file);
grubfs_free (gfs);
file = NULL;
} else file->size = gfs->file->size;
return file;
}
static boolt ext2_read(RFSFile *file, ut64 addr, int len) {
GrubFS *gfs = file->ptr;
grubfs_bind_io (NULL, file->root->delta);
gfs->file->fs->read (gfs->file, (char*)file->data, len);
return R_FALSE;
}
static void ext2_close(RFSFile *file) {
GrubFS *gfs = file->ptr;
gfs->file->fs->close (gfs->file);
}
static RList *list = NULL;
int dirhook (const char *filename, const struct grub_dirhook_info *info) {
RFSFile *fsf = r_fs_file_new (NULL, filename);
fsf->type = info->dir? 'd':'f';
fsf->time = info->mtime;
r_list_append (list, fsf);
//info->mtimeset
//info->case_insensitive
printf ("DIRFILE: %c (%d) %s\n", info->dir?'d':'f',
info->mtime, filename);
return 0;
}
static RList *ext2_dir(RFSRoot *root, const char *path) {
GrubFS *gfs = root->ptr;
list = r_list_new ();
eprintf ("ext2_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);
grubfs_bind_io (NULL, root->delta);
return list;
}
static void ext2_mount(RFSRoot *root) {
root->ptr = grubfs_new (&grub_ext2_fs, &root->iob);
}
static void ext2_umount(RFSRoot *root) {
grubfs_free (root->ptr);
root->ptr = NULL;
}
struct r_fs_plugin_t r_fs_plugin_ext2 = {
.name = "ext2",
.desc = "ext2 filesystem",
.open = ext2_open,
.read = ext2_read,
.close = ext2_close,
.dir = ext2_dir,
.mount = ext2_mount,
.umount = ext2_umount,
};
#include "fs_grub_base.c"

View File

@ -1,5 +1,5 @@
fs_ext2.o: fs_ext2.c ../../include/r_fs.h ../../include/r_types.h \
../../include/r_userconf.h ../../include/r_types_base.h \
p/fs_ext2.o: p/fs_ext2.c p/fs_grub_base.c ../include/r_fs.h \
../include/r_types.h ../include/r_userconf.h ../include/r_types_base.h \
/usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
/usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
/usr/include/gnu/stubs-32.h \
@ -21,13 +21,13 @@ fs_ext2.o: fs_ext2.c ../../include/r_fs.h ../../include/r_types.h \
/usr/include/bits/posix1_lim.h /usr/include/bits/local_lim.h \
/usr/include/linux/limits.h /usr/include/unistd.h \
/usr/include/bits/posix_opt.h /usr/include/bits/environments.h \
/usr/include/bits/confname.h /usr/include/getopt.h \
../../include/r_list.h ../../include/r_flist.h ../../include/r_io.h \
../../include/r_util.h ../../include/btree.h ../../include/r_types.h \
../../include/list.h /usr/include/gmp.h grub/include/grubfs.h \
grub/include/grub/file.h grub/include/grub/types.h grub/include/config.h \
grub/include/config-util.h grub/include/grub/cpu/types.h \
grub/include/grub/err.h grub/include/grub/symbol.h \
grub/include/grub/device.h grub/include/grub/fs.h \
grub/include/grub/list.h grub/include/grub/misc.h \
grub/include/grub/disk.h
/usr/include/bits/confname.h /usr/include/getopt.h ../include/r_list.h \
../include/r_flist.h ../include/r_io.h ../include/r_util.h \
../include/btree.h ../include/r_types.h ../include/list.h \
/usr/include/gmp.h p/grub/include/grubfs.h p/grub/include/grub/file.h \
p/grub/include/grub/types.h p/grub/include/config.h \
p/grub/include/config-util.h p/grub/include/grub/cpu/types.h \
p/grub/include/grub/err.h p/grub/include/grub/symbol.h \
p/grub/include/grub/device.h p/grub/include/grub/fs.h \
p/grub/include/grub/list.h p/grub/include/grub/misc.h \
p/grub/include/grub/disk.h

10
libr/fs/p/fs_fat.c Normal file
View File

@ -0,0 +1,10 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
#define FSP(x) fat_##x
#define FSS(x) x##_fat
#define FSNAME "fat"
#define FSDESC "FAT filesystem"
#define FSPRFX fat
#define FSIPTR grub_fat_fs
#include "fs_grub_base.c"

74
libr/fs/p/fs_grub_base.c Normal file
View File

@ -0,0 +1,74 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
#include <r_fs.h>
#include "grubfs.h"
static RFSFile* FSP(_open)(RFSRoot *root, const char *path) {
RFSFile *file = r_fs_file_new (root, path);
GrubFS *gfs = grubfs_new (&FSIPTR, &root->iob);
file->ptr = gfs;
file->p = root->p;
if (gfs->file->fs->open (gfs->file, path)) {
r_fs_file_free (file);
grubfs_free (gfs);
file = NULL;
} else file->size = gfs->file->size;
return file;
}
static boolt FSP(_read)(RFSFile *file, ut64 addr, int len) {
GrubFS *gfs = file->ptr;
grubfs_bind_io (NULL, file->root->delta);
gfs->file->fs->read (gfs->file, (char*)file->data, len);
return R_FALSE;
}
static void FSP(_close)(RFSFile *file) {
GrubFS *gfs = file->ptr;
gfs->file->fs->close (gfs->file);
}
static RList *list = NULL;
static int dirhook (const char *filename, const struct grub_dirhook_info *info) {
RFSFile *fsf = r_fs_file_new (NULL, filename);
fsf->type = info->dir? 'd':'f';
fsf->time = info->mtime;
r_list_append (list, fsf);
//info->mtimeset
//info->case_insensitive
printf ("DIRFILE: %c (%d) %s\n", info->dir?'d':'f',
info->mtime, filename);
return 0;
}
static RList *FSP(_dir)(RFSRoot *root, const char *path) {
GrubFS *gfs = root->ptr;
list = r_list_new ();
eprintf ("FSP(_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);
grubfs_bind_io (NULL, root->delta);
return list;
}
static void FSP(_mount)(RFSRoot *root) {
root->ptr = grubfs_new (&FSIPTR, &root->iob);
}
static void FSP(_umount)(RFSRoot *root) {
grubfs_free (root->ptr);
root->ptr = NULL;
}
struct r_fs_plugin_t FSS(r_fs_plugin) = {
.name = FSNAME,
.desc = FSDESC,
.open = FSP(_open),
.read = FSP(_read),
.close = FSP(_close),
.dir = FSP(_dir),
.mount = FSP(_mount),
.umount = FSP(_umount),
};

10
libr/fs/p/fs_hfs.c Normal file
View File

@ -0,0 +1,10 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
#define FSP(x) hfs_##x
#define FSS(x) x##_hfs
#define FSNAME "hfs"
#define FSDESC "HFS filesystem"
#define FSPRFX hfs
#define FSIPTR grub_hfs_fs
#include "fs_grub_base.c"

10
libr/fs/p/fs_hfsplus.c Normal file
View File

@ -0,0 +1,10 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
#define FSP(x) hfsplus_##x
#define FSS(x) x##_hfsplus
#define FSNAME "hfsplus"
#define FSDESC "HFSPLUS filesystem"
#define FSPRFX hfsplus
#define FSIPTR grub_hfsplus_fs
#include "fs_grub_base.c"

10
libr/fs/p/fs_iso9660.c Normal file
View File

@ -0,0 +1,10 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
#define FSP(x) iso9660_##x
#define FSS(x) x##_iso9660
#define FSNAME "iso9660"
#define FSDESC "ISO9660 filesystem"
#define FSPRFX iso9660
#define FSIPTR grub_iso9660_fs
#include "fs_grub_base.c"

10
libr/fs/p/fs_jfs.c Normal file
View File

@ -0,0 +1,10 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
#define FSP(x) jfs_##x
#define FSS(x) x##_jfs
#define FSNAME "jfs"
#define FSDESC "JFS filesystem"
#define FSPRFX jfs
#define FSIPTR grub_jfs_fs
#include "fs_grub_base.c"

10
libr/fs/p/fs_ntfs.c Normal file
View File

@ -0,0 +1,10 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
#define FSP(x) ntfs_##x
#define FSS(x) x##_ntfs
#define FSNAME "ntfs"
#define FSDESC "NTFS filesystem"
#define FSPRFX ntfs
#define FSIPTR grub_ntfs_fs
#include "fs_grub_base.c"

10
libr/fs/p/fs_reiserfs.c Normal file
View File

@ -0,0 +1,10 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
#define FSP(x) reiserfs_##x
#define FSS(x) x##_reiserfs
#define FSNAME "reiserfs"
#define FSDESC "REISERFS filesystem"
#define FSPRFX reiserfs
#define FSIPTR grub_reiserfs_fs
#include "fs_grub_base.c"

10
libr/fs/p/fs_tar.c Normal file
View File

@ -0,0 +1,10 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
#define FSP(x) tar_##x
#define FSS(x) x##_tar
#define FSNAME "tar"
#define FSDESC "TAR filesystem"
#define FSPRFX tar
#define FSIPTR grub_tar_fs
#include "fs_grub_base.c"

10
libr/fs/p/fs_udf.c Normal file
View File

@ -0,0 +1,10 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
#define FSP(x) udf_##x
#define FSS(x) x##_udf
#define FSNAME "udf"
#define FSDESC "UDF filesystem"
#define FSPRFX udf
#define FSIPTR grub_udf_fs
#include "fs_grub_base.c"

10
libr/fs/p/fs_ufs.c Normal file
View File

@ -0,0 +1,10 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
#define FSP(x) ufs_##x
#define FSS(x) x##_ufs
#define FSNAME "ufs"
#define FSDESC "UFS filesystem"
#define FSPRFX ufs
#define FSIPTR grub_ufs_fs
#include "fs_grub_base.c"

10
libr/fs/p/fs_ufs2.c Normal file
View File

@ -0,0 +1,10 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
#define FSP(x) ufs2_##x
#define FSS(x) x##_ufs2
#define FSNAME "ufs2"
#define FSDESC "UFS2 filesystem"
#define FSPRFX ufs2
#define FSIPTR grub_ufs2_fs
#include "fs_grub_base.c"

10
libr/fs/p/fs_xfs.c Normal file
View File

@ -0,0 +1,10 @@
/* radare - LGPL - Copyright 2011 pancake<nopcode.org> */
#define FSP(x) xfs_##x
#define FSS(x) x##_xfs
#define FSNAME "xfs"
#define FSDESC "XFS filesystem"
#define FSPRFX xfs
#define FSIPTR grub_xfs_fs
#include "fs_grub_base.c"

View File

@ -7,7 +7,13 @@ KERNFILES+=kern/env.c kern/disk.c
KERNFILES+=kern/fs.c kern/misc.c
KERNFILES+=kern/time.c
KERNFILES+=kern/list.c kern/partition.c
KERNFILES+=fs/fshelp.c fs/ext2.c
KERNFILES+=fs/fshelp.c
KERNFILES+=fs/reiserfs.c fs/ext2.c
KERNFILES+=fs/fat.c fs/ntfs.c
KERNFILES+=fs/hfs.c fs/hfsplus.c
KERNFILES+=fs/udf.c fs/iso9660.c
KERNFILES+=fs/cpio.c fs/tar.c
KERNFILES+=fs/xfs.c fs/jfs.c
#KERNFILES+=main.c
KERNFILES+=grubfs.c

View File

@ -527,7 +527,7 @@ grub_affs_label (grub_device_t device, char **label)
}
static struct grub_fs grub_affs_fs =
struct grub_fs grub_affs_fs =
{
.name = "affs",
.dir = grub_affs_dir,

View File

@ -680,7 +680,7 @@ grub_afs_label (grub_device_t device, char **label)
}
static struct grub_fs grub_afs_fs = {
struct grub_fs grub_afs_fs = {
.name = GRUB_AFS_FSNAME,
.dir = grub_afs_dir,
.open = grub_afs_open,

View File

@ -113,7 +113,7 @@ grub_btrfs_uuid (grub_device_t device, char **uuid)
return grub_errno;
}
static struct grub_fs grub_btrfs_fs =
struct grub_fs grub_btrfs_fs =
{
.name = "btrfs",
.dir = grub_btrfs_dir,

View File

@ -344,10 +344,11 @@ grub_cpio_close (grub_file_t file)
return grub_errno;
}
static struct grub_fs grub_cpio_fs = {
#ifdef MODE_USTAR
struct grub_fs grub_tar_fs = {
.name = "tarfs",
#else
struct grub_fs grub_cpio_fs = {
.name = "cpiofs",
#endif
.dir = grub_cpio_dir,
@ -358,22 +359,3 @@ static struct grub_fs grub_cpio_fs = {
.reserved_first_sector = 0,
#endif
};
#ifdef MODE_USTAR
GRUB_MOD_INIT (tar)
#else
GRUB_MOD_INIT (cpio)
#endif
{
grub_fs_register (&grub_cpio_fs);
my_mod = mod;
}
#ifdef MODE_USTAR
GRUB_MOD_FINI (tar)
#else
GRUB_MOD_FINI (cpio)
#endif
{
grub_fs_unregister (&grub_cpio_fs);
}

View File

@ -848,7 +848,7 @@ grub_fat_uuid (grub_device_t device, char **uuid)
return grub_errno;
}
static struct grub_fs grub_fat_fs =
struct grub_fs grub_fat_fs =
{
.name = "fat",
.dir = grub_fat_dir,

View File

@ -1098,7 +1098,7 @@ grub_hfs_uuid (grub_device_t device, char **uuid)
static struct grub_fs grub_hfs_fs =
struct grub_fs grub_hfs_fs =
{
.name = "hfs",
.dir = grub_hfs_dir,

View File

@ -1020,7 +1020,7 @@ grub_hfsplus_uuid (grub_device_t device, char **uuid)
static struct grub_fs grub_hfsplus_fs =
struct grub_fs grub_hfsplus_fs =
{
.name = "hfsplus",
.dir = grub_hfsplus_dir,

View File

@ -873,7 +873,7 @@ grub_iso9660_uuid (grub_device_t device, char **uuid)
static struct grub_fs grub_iso9660_fs =
struct grub_fs grub_iso9660_fs =
{
.name = "iso9660",
.dir = grub_iso9660_dir,

View File

@ -875,7 +875,7 @@ grub_jfs_label (grub_device_t device, char **label)
}
static struct grub_fs grub_jfs_fs =
struct grub_fs grub_jfs_fs =
{
.name = "jfs",
.dir = grub_jfs_dir,

View File

@ -554,7 +554,7 @@ grub_minix_close (grub_file_t file)
static struct grub_fs grub_minix_fs =
struct grub_fs grub_minix_fs =
{
#ifdef MODE_MINIX2
.name = "minix2",

View File

@ -1157,7 +1157,7 @@ grub_nilfs2_mtime (grub_device_t device, grub_int32_t * tm)
static struct grub_fs grub_nilfs2_fs = {
struct grub_fs grub_nilfs2_fs = {
.name = "nilfs2",
.dir = grub_nilfs2_dir,
.open = grub_nilfs2_open,

View File

@ -1088,7 +1088,7 @@ grub_ntfs_uuid (grub_device_t device, char **uuid)
return grub_errno;
}
static struct grub_fs grub_ntfs_fs =
struct grub_fs grub_ntfs_fs =
{
.name = "ntfs",
.dir = grub_ntfs_dir,

View File

@ -1358,7 +1358,7 @@ grub_reiserfs_uuid (grub_device_t device, char **uuid)
return grub_errno;
}
static struct grub_fs grub_reiserfs_fs =
struct grub_fs grub_reiserfs_fs =
{
.name = "reiserfs",
.dir = grub_reiserfs_dir,

View File

@ -571,7 +571,7 @@ grub_sfs_label (grub_device_t device, char **label)
}
static struct grub_fs grub_sfs_fs =
struct grub_fs grub_sfs_fs =
{
.name = "sfs",
.dir = grub_sfs_dir,

View File

@ -1037,7 +1037,7 @@ grub_udf_label (grub_device_t device, char **label)
return grub_errno;
}
static struct grub_fs grub_udf_fs = {
struct grub_fs grub_udf_fs = {
.name = "udf",
.dir = grub_udf_dir,
.open = grub_udf_open,

View File

@ -770,7 +770,7 @@ grub_ufs_mtime (grub_device_t device, grub_int32_t *tm)
static struct grub_fs grub_ufs_fs =
struct grub_fs grub_ufs_fs =
{
#ifdef MODE_UFS2
.name = "ufs2",

View File

@ -799,7 +799,7 @@ grub_xfs_uuid (grub_device_t device, char **uuid)
static struct grub_fs grub_xfs_fs =
struct grub_fs grub_xfs_fs =
{
.name = "xfs",
.dir = grub_xfs_dir,
@ -813,14 +813,3 @@ static struct grub_fs grub_xfs_fs =
#endif
.next = 0
};
GRUB_MOD_INIT(xfs)
{
grub_fs_register (&grub_xfs_fs);
my_mod = mod;
}
GRUB_MOD_FINI(xfs)
{
grub_fs_unregister (&grub_xfs_fs);
}

View File

@ -14,5 +14,21 @@ void grubfs_free (GrubFS *gf);
void grubfs_bind_io (RIOBind *iob, ut64 _delta);
extern struct grub_fs grub_ext2_fs;
extern struct grub_fs grub_fat_fs;
extern struct grub_fs grub_ntfs_fs;
extern struct grub_fs grub_reiserfs_fs;
extern struct grub_fs grub_hfs_fs;
extern struct grub_fs grub_hfsplus_fs;
extern struct grub_fs grub_ufs_fs;
extern struct grub_fs grub_ufs2_fs;
extern struct grub_fs grub_udf_fs;
extern struct grub_fs grub_iso9660_fs;
extern struct grub_fs grub_jfs_fs;
extern struct grub_fs grub_sfs_fs;
extern struct grub_fs grub_btrfs_fs;
extern struct grub_fs grub_xfs_fs;
extern struct grub_fs grub_tar_fs;
extern struct grub_fs grub_cpio_fs;
extern struct grub_fs grub_udf_fs;
#endif

12
libr/fs/p/hfs.mk Normal file
View File

@ -0,0 +1,12 @@
OBJ_HFS=fs_hfs.o
EXTRA=../p/grub/libgrubfs.a
CFLAGS+=-Igrub/include
STATIC_OBJ+=${OBJ_HFS}
#STATIC_OBJ+=${EXTRA}
TARGET_HFS=fs_hfs.${EXT_SO}
ALL_TARGETS+=${TARGET_HFS}
${TARGET_HFS}: ${OBJ_HFS}
${CC} ${LDFLAGS} ${CFLAGS} -o ${TARGET_HFS} ${OBJ_HFS} ${EXTRA}

12
libr/fs/p/hfsplus.mk Normal file
View File

@ -0,0 +1,12 @@
OBJ_HFSPLUS=fs_hfsplus.o
EXTRA=../p/grub/libgrubfs.a
CFLAGS+=-Igrub/include
STATIC_OBJ+=${OBJ_HFSPLUS}
#STATIC_OBJ+=${EXTRA}
TARGET_HFSPLUS=fs_hfsplus.${EXT_SO}
ALL_TARGETS+=${TARGET_HFSPLUS}
${TARGET_HFSPLUS}: ${OBJ_HFSPLUS}
${CC} ${LDFLAGS} ${CFLAGS} -o ${TARGET_HFSPLUS} ${OBJ_HFSPLUS} ${EXTRA}

12
libr/fs/p/iso9660.mk Normal file
View File

@ -0,0 +1,12 @@
OBJ_ISO9660=fs_iso9660.o
EXTRA=../p/grub/libgrubfs.a
CFLAGS+=-Igrub/include
STATIC_OBJ+=${OBJ_ISO9660}
#STATIC_OBJ+=${EXTRA}
TARGET_ISO9660=fs_iso9660.${EXT_SO}
ALL_TARGETS+=${TARGET_ISO9660}
${TARGET_ISO9660}: ${OBJ_ISO9660}
${CC} ${LDFLAGS} ${CFLAGS} -o ${TARGET_ISO9660} ${OBJ_ISO9660} ${EXTRA}

12
libr/fs/p/jfs.mk Normal file
View File

@ -0,0 +1,12 @@
OBJ_JFS=fs_jfs.o
EXTRA=../p/grub/libgrubfs.a
CFLAGS+=-Igrub/include
STATIC_OBJ+=${OBJ_JFS}
#STATIC_OBJ+=${EXTRA}
TARGET_JFS=fs_jfs.${EXT_SO}
ALL_TARGETS+=${TARGET_JFS}
${TARGET_JFS}: ${OBJ_JFS}
${CC} ${LDFLAGS} ${CFLAGS} -o ${TARGET_JFS} ${OBJ_JFS} ${EXTRA}

11
libr/fs/p/makeplugin.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
# TODO: btrfs does not have READ hook
# TODO: cpio | tarfs
if [ -z "$1" ]; then
echo "Use: makeplugin.sh [newplugname]"
exit 1
fi
U=$(echo $1 | tr '[a-z]' '[A-Z]')
sed -e s,fat,$1,g -e s,FAT,$U,g fat.mk > $1.mk
sed -e s,fat,$1,g -e s,FAT,$U,g fs_fat.c > fs_$1.c

12
libr/fs/p/ntfs.mk Normal file
View File

@ -0,0 +1,12 @@
OBJ_NTFS=fs_ntfs.o
EXTRA=../p/grub/libgrubfs.a
CFLAGS+=-Igrub/include
STATIC_OBJ+=${OBJ_NTFS}
#STATIC_OBJ+=${EXTRA}
TARGET_NTFS=fs_ntfs.${EXT_SO}
ALL_TARGETS+=${TARGET_NTFS}
${TARGET_NTFS}: ${OBJ_NTFS}
${CC} ${LDFLAGS} ${CFLAGS} -o ${TARGET_NTFS} ${OBJ_NTFS} ${EXTRA}

12
libr/fs/p/reiserfs.mk Normal file
View File

@ -0,0 +1,12 @@
OBJ_REISERFS=fs_reiserfs.o
EXTRA=../p/grub/libgrubfs.a
CFLAGS+=-Igrub/include
STATIC_OBJ+=${OBJ_REISERFS}
#STATIC_OBJ+=${EXTRA}
TARGET_REISERFS=fs_reiserfs.${EXT_SO}
ALL_TARGETS+=${TARGET_REISERFS}
${TARGET_REISERFS}: ${OBJ_REISERFS}
${CC} ${LDFLAGS} ${CFLAGS} -o ${TARGET_REISERFS} ${OBJ_REISERFS} ${EXTRA}

12
libr/fs/p/tar.mk Normal file
View File

@ -0,0 +1,12 @@
OBJ_TAR=fs_tar.o
EXTRA=../p/grub/libgrubfs.a
CFLAGS+=-Igrub/include
STATIC_OBJ+=${OBJ_TAR}
#STATIC_OBJ+=${EXTRA}
TARGET_TAR=fs_tar.${EXT_SO}
ALL_TARGETS+=${TARGET_TAR}
${TARGET_TAR}: ${OBJ_TAR}
${CC} ${LDFLAGS} ${CFLAGS} -o ${TARGET_TAR} ${OBJ_TAR} ${EXTRA}

12
libr/fs/p/udf.mk Normal file
View File

@ -0,0 +1,12 @@
OBJ_UDF=fs_udf.o
EXTRA=../p/grub/libgrubfs.a
CFLAGS+=-Igrub/include
STATIC_OBJ+=${OBJ_UDF}
#STATIC_OBJ+=${EXTRA}
TARGET_UDF=fs_udf.${EXT_SO}
ALL_TARGETS+=${TARGET_UDF}
${TARGET_UDF}: ${OBJ_UDF}
${CC} ${LDFLAGS} ${CFLAGS} -o ${TARGET_UDF} ${OBJ_UDF} ${EXTRA}

12
libr/fs/p/ufs.mk Normal file
View File

@ -0,0 +1,12 @@
OBJ_UFS=fs_ufs.o
EXTRA=../p/grub/libgrubfs.a
CFLAGS+=-Igrub/include
STATIC_OBJ+=${OBJ_UFS}
#STATIC_OBJ+=${EXTRA}
TARGET_UFS=fs_ufs.${EXT_SO}
ALL_TARGETS+=${TARGET_UFS}
${TARGET_UFS}: ${OBJ_UFS}
${CC} ${LDFLAGS} ${CFLAGS} -o ${TARGET_UFS} ${OBJ_UFS} ${EXTRA}

12
libr/fs/p/ufs2.mk Normal file
View File

@ -0,0 +1,12 @@
OBJ_UFS2=fs_ufs2.o
EXTRA=../p/grub/libgrubfs.a
CFLAGS+=-Igrub/include
STATIC_OBJ+=${OBJ_UFS2}
#STATIC_OBJ+=${EXTRA}
TARGET_UFS2=fs_ufs2.${EXT_SO}
ALL_TARGETS+=${TARGET_UFS2}
${TARGET_UFS2}: ${OBJ_UFS2}
${CC} ${LDFLAGS} ${CFLAGS} -o ${TARGET_UFS2} ${OBJ_UFS2} ${EXTRA}

12
libr/fs/p/xfs.mk Normal file
View File

@ -0,0 +1,12 @@
OBJ_XFS=fs_xfs.o
EXTRA=../p/grub/libgrubfs.a
CFLAGS+=-Igrub/include
STATIC_OBJ+=${OBJ_XFS}
#STATIC_OBJ+=${EXTRA}
TARGET_XFS=fs_xfs.${EXT_SO}
ALL_TARGETS+=${TARGET_XFS}
${TARGET_XFS}: ${OBJ_XFS}
${CC} ${LDFLAGS} ${CFLAGS} -o ${TARGET_XFS} ${OBJ_XFS} ${EXTRA}

View File

@ -62,7 +62,7 @@ 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);
R_API int r_fs_umount (RFS* fs, const char *path);
R_API boolt r_fs_umount (RFS* fs, const char *path);
R_API RFSRoot *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);
@ -78,6 +78,24 @@ R_API void r_fs_root_free (RFSRoot *root);
/* plugins */
extern RFSPlugin r_fs_plugin_ext2;
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;
#endif
#endif

View File

@ -32,7 +32,18 @@ bp.ppc
cmd.dummy
crypto.aes
debug.native
fs.fat
fs.ntfs
fs.ext2
fs.hfs
fs.hfsplus
fs.reiserfs
fs.iso9660
fs.udf
fs.tar
fs.cpio
fs.jfs
fs.xfs
io.debug
io.rap
io.gdb

2
swig/vapi/r_fs.deps Normal file
View File

@ -0,0 +1,2 @@
r_io
r_util

42
swig/vapi/r_fs.vapi Normal file
View File

@ -0,0 +1,42 @@
/* radare2 - LGPL - Copyright 2011 pancake<nopcode.org> */
// TODO: Use nested classes instead of this wide class layout
namespace Radare {
[Compact]
[CCode (cheader_filename="r_asm.h", cname="struct r_asm_t", free_function="r_asm_free", cprefix="r_asm_")]
public class RFS {
public RFS();
public RFSRoot mount (string fstype, string path, uint64 delta);
public bool umount (string path);
public RFSRoot root (string path);
public RFSFile open (string path);
public void close (RFSFile file);
public int read(RFSFile file, uint64 addr, int len);
public RFSFile slurp(string path);
public RList<RFSFile> dir(string path);
}
[Compact]
public class RFSFile {
public string name;
public string path;
public uint64 path;
public uint32 size;
public uint64 time;
public void *ptr;
}
[Compact]
public class RFSPlugin {
public string name;
public string desc;
}
[Compact]
public class RFSRoot {
public string path;
public uint64 delta;
public RFSPlugin p;
public void *ptr;
}
}