From b04a3d163875752b2dab573aee47f29f2fc33f09 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Fri, 2 Nov 2007 22:11:28 +0000 Subject: [PATCH] Set more information in streamp_r, allows to retrieve unit id with stream_fstat() --- libstream/libstream.h | 19 +++++++++++++++++++ libstream/stream_fstat.c | 7 ++++++- libstream/stream_open.c | 16 +++++----------- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/libstream/libstream.h b/libstream/libstream.h index bde6770..5a4a370 100644 --- a/libstream/libstream.h +++ b/libstream/libstream.h @@ -9,7 +9,19 @@ #include #include +typedef enum { + device_FLOPPY, + device_SCSI, +} device_t; + +typedef enum { + fs_BLOCK, + fs_CONTAINER, + fs_ISO9660, +} fs_t; + struct stream_stat { + int st_dev; off_t st_size; }; @@ -48,6 +60,13 @@ typedef struct { /* filesystem interface */ filesystem_io_t fs; + + /* info */ + + fs_t fs_id; + device_t device_id; + int unit, partition; + } stream_t; extern stream_t *stream_open(char *dev); diff --git a/libstream/stream_fstat.c b/libstream/stream_fstat.c index 04f8380..e532132 100644 --- a/libstream/stream_fstat.c +++ b/libstream/stream_fstat.c @@ -8,8 +8,13 @@ int stream_fstat(stream_t *stream, struct stream_stat *buf) { + int ret; + if (stream->fs.fstat == NULL) return -1; - return stream->fs.fstat(stream->fs.file, buf); + ret = stream->fs.fstat(stream->fs.file, buf); + buf->st_dev = stream->unit; + + return ret; } diff --git a/libstream/stream_open.c b/libstream/stream_open.c index 03658ae..d80460f 100644 --- a/libstream/stream_open.c +++ b/libstream/stream_open.c @@ -28,17 +28,6 @@ #include #endif -typedef enum { - device_FLOPPY, - device_SCSI, -} device_t; - -typedef enum { - fs_BLOCK, - fs_CONTAINER, - fs_ISO9660, -} fs_t; - static char* get_fs(char *path, fs_t *fs) { if (strncmp("block:", path, 6) == 0) @@ -133,6 +122,11 @@ stream_t *stream_open(char *dev) stream = (stream_t*)malloc(sizeof(stream_t)); + stream->fs_id = fs, + stream->device_id = device; + stream->unit = unit; + stream->partition = partition; + switch(device) { #ifdef FLOPPY_SUPPORT