Add ext2 in libstream

This commit is contained in:
Laurent Vivier 2008-04-12 22:27:13 +00:00
parent fb689113dd
commit 5f7643e48b
4 changed files with 39 additions and 6 deletions

View File

@ -18,6 +18,7 @@ HEADERS = libstream.h
SCSI_FLAGS = -DSCSI_SUPPORT -I$(TOP)/../libscsi SCSI_FLAGS = -DSCSI_SUPPORT -I$(TOP)/../libscsi
ISO9660_FLAGS = -DISO9660_SUPPORT -I$(TOP)/../libiso9660 ISO9660_FLAGS = -DISO9660_SUPPORT -I$(TOP)/../libiso9660
EXT2_FLAGS = -DEXT2_SUPPORT -I$(TOP)/../libext2
CONTAINER_FLAGS = -DCONTAINER_SUPPORT -I$(TOP)/../libcontainer CONTAINER_FLAGS = -DCONTAINER_SUPPORT -I$(TOP)/../libcontainer
FLOPPY_FLAGS = -DFLOPPY_SUPPORT -I$(TOP)/../libfloppy FLOPPY_FLAGS = -DFLOPPY_SUPPORT -I$(TOP)/../libfloppy
BLOCK_FLAGS = -DBLOCK_SUPPORT -I$(TOP)/../libblock BLOCK_FLAGS = -DBLOCK_SUPPORT -I$(TOP)/../libblock
@ -28,8 +29,8 @@ all: $(LIBRARIES)
scsi/libstream.a:: scsi/libstream.a::
test -e scsi || mkdir scsi test -e scsi || mkdir scsi
$(MAKE) -C scsi -f $(TOP)/Makefile TOP=$(TOP) LIBRARY=libstream.a CPPFLAGS="$(CPPFLAGS) \ $(MAKE) -C scsi -f $(TOP)/Makefile TOP=$(TOP) LIBRARY=libstream.a CPPFLAGS="$(CPPFLAGS) \
$(SCSI_FLAGS) $(CONTAINER_FLAGS) $(BLOCK_FLAGS) $(ISO9660_FLAGS) $(MAP_FLAGS)" \ $(SCSI_FLAGS) $(CONTAINER_FLAGS) $(BLOCK_FLAGS) $(ISO9660_FLAGS) $(MAP_FLAGS) \
libstream.a $(EXT2_FLAGS)" libstream.a
floppy/libstream.a:: floppy/libstream.a::
test -e floppy || mkdir floppy test -e floppy || mkdir floppy
@ -40,8 +41,8 @@ full/libstream.a::
test -e full || mkdir full test -e full || mkdir full
$(MAKE) -C full -f $(TOP)/Makefile TOP=$(TOP) LIBRARY=libstream.a \ $(MAKE) -C full -f $(TOP)/Makefile TOP=$(TOP) LIBRARY=libstream.a \
CPPFLAGS="$(CPPFLAGS) $(SCSI_FLAGS) $(CONTAINER_FLAGS) \ CPPFLAGS="$(CPPFLAGS) $(SCSI_FLAGS) $(CONTAINER_FLAGS) \
$(ISO9660_FLAGS) $(FLOPPY_FLAGS) $(BLOCK_FLAGS) $(MAP_FLAGS)" \ $(ISO9660_FLAGS) $(FLOPPY_FLAGS) $(BLOCK_FLAGS) $(MAP_FLAGS) \
libstream.a $(EXT2_FLAGS)" libstream.a
include $(TOP)/../tools.mk include $(TOP)/../tools.mk
include $(TOP)/../Rules.mk include $(TOP)/../Rules.mk

View File

@ -18,6 +18,7 @@ typedef enum {
fs_BLOCK, fs_BLOCK,
fs_CONTAINER, fs_CONTAINER,
fs_ISO9660, fs_ISO9660,
fs_EXT2,
} fs_t; } fs_t;
struct stream_stat { struct stream_stat {

View File

@ -24,6 +24,9 @@
#ifdef ISO9660_SUPPORT #ifdef ISO9660_SUPPORT
#include <libiso9660.h> #include <libiso9660.h>
#endif #endif
#ifdef EXT2_SUPPORT
#include <libext2.h>
#endif
#ifdef MAP_SUPPORT #ifdef MAP_SUPPORT
#include <libmap.h> #include <libmap.h>
#endif #endif
@ -45,6 +48,11 @@ static char* get_fs(char *path, fs_t *fs)
*fs = fs_ISO9660; *fs = fs_ISO9660;
return path + 8; return path + 8;
} }
if (strncmp("ext2:", path, 8) == 0)
{
*fs = fs_EXT2;
return path + 8;
}
return NULL; return NULL;
} }
@ -258,6 +266,27 @@ stream_t *stream_open(char *dev)
break; break;
#endif /* ISO9660_SUPPORT */ #endif /* ISO9660_SUPPORT */
#ifdef EXT2_SUPPORT
case fs_EXT2:
stream->fs.volume = ext2_mount(&stream->device);
if (stream->fs.volume == NULL)
{
printf("Cannot mount volume ext2\n");
goto outfs;
}
stream->fs.file = ext2_open(stream->fs.volume, current);
if (stream->fs.file == NULL)
{
ext2_umount(stream->fs.volume);
goto outfs;
}
stream->fs.read = (stream_read_t)ext2_read;
stream->fs.lseek = (stream_lseek_t)ext2_lseek;
stream->fs.close = (stream_close_t)ext2_close;
stream->fs.umount = (stream_umount_t)ext2_umount;
stream->fs.fstat = (stream_fstat_t)ext2_fstat;
break;
#endif /* EXT2_SUPPORT */
default: default:
outfs: outfs:
stream->device.close(stream->device.data); stream->device.close(stream->device.data);

View File

@ -17,8 +17,10 @@ CPPFLAGS = -DVERSION="\"$(VERSION)\"" -I$(TOP) -Wa,-I$(TOP) \
# -O2 is needed to be able to inline functions from libmacos # -O2 is needed to be able to inline functions from libmacos
CFLAGS = $(OPT_CFLAGS) -nostdlib -nodefaultlibs -Wall -Werror -Wno-multichar -fpic -O2 CFLAGS = $(OPT_CFLAGS) -nostdlib -nodefaultlibs -Wall -Werror -Wno-multichar -fpic -O2
ASFLAGS = ASFLAGS =
LIBS = $(OPT_LIBS) -L$(TOP)/../libiso9660/m68k-linux \ LIBS = $(OPT_LIBS) \
-liso9660 -L$(TOP)/../libunix -lunix \ -L$(TOP)/../libiso9660/m68k-linux -liso9660 \
-L$(TOP)/../libext2/m68k-linux -lext2 \
-L$(TOP)/../libunix -lunix \
-L$(TOP)/../libmacos -lmacos -lunix \ -L$(TOP)/../libmacos -lmacos -lunix \
-L$(TOP)/../libgzip/m68k-linux -lgzip \ -L$(TOP)/../libgzip/m68k-linux -lgzip \
-L$(TOP)/../libfloppy -lfloppy -L$(TOP)/../libscsi -lscsi \ -L$(TOP)/../libfloppy -lfloppy -L$(TOP)/../libscsi -lscsi \