use libmap

This commit is contained in:
Laurent Vivier 2007-10-10 21:13:35 +00:00
parent b0c25d723f
commit 7473cf35d2
2 changed files with 33 additions and 2 deletions

View File

@ -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

View File

@ -24,6 +24,9 @@
#ifdef ISO9660_SUPPORT
#include <libiso9660.h>
#endif
#ifdef MAP_SUPPORT
#include <libmap.h>
#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