Set more information in streamp_r, allows to retrieve unit id with stream_fstat()

This commit is contained in:
Laurent Vivier 2007-11-02 22:11:28 +00:00
parent 47a16fe0c8
commit b04a3d1638
3 changed files with 30 additions and 12 deletions

View File

@ -9,7 +9,19 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
typedef enum {
device_FLOPPY,
device_SCSI,
} device_t;
typedef enum {
fs_BLOCK,
fs_CONTAINER,
fs_ISO9660,
} fs_t;
struct stream_stat { struct stream_stat {
int st_dev;
off_t st_size; off_t st_size;
}; };
@ -48,6 +60,13 @@ typedef struct {
/* filesystem interface */ /* filesystem interface */
filesystem_io_t fs; filesystem_io_t fs;
/* info */
fs_t fs_id;
device_t device_id;
int unit, partition;
} stream_t; } stream_t;
extern stream_t *stream_open(char *dev); extern stream_t *stream_open(char *dev);

View File

@ -8,8 +8,13 @@
int stream_fstat(stream_t *stream, struct stream_stat *buf) int stream_fstat(stream_t *stream, struct stream_stat *buf)
{ {
int ret;
if (stream->fs.fstat == NULL) if (stream->fs.fstat == NULL)
return -1; 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;
} }

View File

@ -28,17 +28,6 @@
#include <libmap.h> #include <libmap.h>
#endif #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) static char* get_fs(char *path, fs_t *fs)
{ {
if (strncmp("block:", path, 6) == 0) if (strncmp("block:", path, 6) == 0)
@ -133,6 +122,11 @@ stream_t *stream_open(char *dev)
stream = (stream_t*)malloc(sizeof(stream_t)); stream = (stream_t*)malloc(sizeof(stream_t));
stream->fs_id = fs,
stream->device_id = device;
stream->unit = unit;
stream->partition = partition;
switch(device) switch(device)
{ {
#ifdef FLOPPY_SUPPORT #ifdef FLOPPY_SUPPORT