diff --git a/libstream/Makefile b/libstream/Makefile index 8659587..06741d4 100644 --- a/libstream/Makefile +++ b/libstream/Makefile @@ -21,13 +21,15 @@ ISO9660_FLAGS = -DISO9660_SUPPORT -I$(TOP)/../libiso9660 CONTAINER_FLAGS = -DCONTAINER_SUPPORT -I$(TOP)/../libcontainer FLOPPY_FLAGS = -DFLOPPY_SUPPORT -I$(TOP)/../libfloppy BLOCK_FLAGS = -DBLOCK_SUPPORT -I$(TOP)/../libblock +MAP_FLAGS = -DMAP_SUPPORT -I$(TOP)/../libmap -I$(TOP)/../libemile all: $(LIBRARIES) scsi/libstream.a:: test -e scsi || mkdir scsi $(MAKE) -C scsi -f $(TOP)/Makefile TOP=$(TOP) LIBRARY=libstream.a CPPFLAGS="$(CPPFLAGS) \ - $(SCSI_FLAGS) $(CONTAINER_FLAGS) $(ISO9660_FLAGS)" libstream.a + $(SCSI_FLAGS) $(CONTAINER_FLAGS) $(ISO9660_FLAGS) $(MAP_FLAGS)" \ + libstream.a floppy/libstream.a:: test -e floppy || mkdir floppy @@ -38,7 +40,8 @@ full/libstream.a:: test -e full || mkdir full $(MAKE) -C full -f $(TOP)/Makefile TOP=$(TOP) LIBRARY=libstream.a \ CPPFLAGS="$(CPPFLAGS) $(SCSI_FLAGS) $(CONTAINER_FLAGS) \ - $(ISO9660_FLAGS) $(FLOPPY_FLAGS) $(BLOCK_FLAGS)" libstream.a + $(ISO9660_FLAGS) $(FLOPPY_FLAGS) $(BLOCK_FLAGS) $(MAP_FLAGS)" \ + libstream.a include $(TOP)/../tools.mk include $(TOP)/../Rules.mk diff --git a/libstream/stream_open.c b/libstream/stream_open.c index 3082de0..8d79054 100644 --- a/libstream/stream_open.c +++ b/libstream/stream_open.c @@ -24,6 +24,9 @@ #ifdef ISO9660_SUPPORT #include #endif +#ifdef MAP_SUPPORT +#include +#endif typedef enum { device_FLOPPY, @@ -175,6 +178,31 @@ stream_t *stream_open(char *dev) break; } + if (partition != -1) + { +#ifdef MAP_SUPPORT + int ret; + map_t *map; + + map = map_open(&stream->device); + if (map == NULL) + goto map_error; + + stream->device.data = map; + ret = map_read(map, partition); + if (ret == -1) + goto map_read_error; + stream->device.read_sector = (stream_read_sector_t)map_read_sector; + stream->device.close = (stream_close_t)map_close; +map_read_error: + map_close(map); +map_error: +#endif /* MAP_SUPPORT */ + stream->device.close(&stream->device); + free(stream); + return NULL; + } + switch(fs) { #ifdef BLOCK_SUPPORT