2005-11-21 22:05:14 +00:00
|
|
|
/*
|
|
|
|
*
|
2007-10-08 20:56:21 +00:00
|
|
|
* (c) 2005-2007 Laurent Vivier <Laurent@lvivier.info>
|
2005-11-21 22:05:14 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef __LIBSTREAM_H__
|
|
|
|
#define __LIBSTREAM_H__
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2007-11-02 22:11:28 +00:00
|
|
|
typedef enum {
|
|
|
|
device_FLOPPY,
|
|
|
|
device_SCSI,
|
|
|
|
} device_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
fs_BLOCK,
|
|
|
|
fs_CONTAINER,
|
|
|
|
fs_ISO9660,
|
|
|
|
} fs_t;
|
|
|
|
|
2005-11-23 00:09:00 +00:00
|
|
|
struct stream_stat {
|
2007-11-02 22:11:28 +00:00
|
|
|
int st_dev;
|
2005-11-23 00:09:00 +00:00
|
|
|
off_t st_size;
|
|
|
|
};
|
|
|
|
|
2005-11-21 22:05:14 +00:00
|
|
|
typedef int (*stream_read_sector_t)(void *data,off_t offset, void* buffer, size_t size);
|
2007-10-08 20:56:21 +00:00
|
|
|
typedef int (*stream_write_sector_t)(void *data,off_t offset, void* buffer, size_t size);
|
2005-11-21 22:05:14 +00:00
|
|
|
typedef ssize_t (*stream_read_t)(void *data, void *buf, size_t count);
|
2005-11-21 23:52:44 +00:00
|
|
|
typedef int (*stream_lseek_t)(void *data, long offset, int whence);
|
2005-11-21 22:05:14 +00:00
|
|
|
typedef int (*stream_close_t)(void *data);
|
2005-11-21 23:52:44 +00:00
|
|
|
typedef int (*stream_umount_t)(void *data);
|
2005-11-23 00:09:00 +00:00
|
|
|
typedef int (*stream_fstat_t)(void *data, struct stream_stat *buf);
|
2005-11-23 22:37:27 +00:00
|
|
|
typedef int (*stream_get_blocksize_t)(void *data);
|
2005-11-21 22:05:14 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
void *data;
|
2007-10-08 20:56:21 +00:00
|
|
|
stream_write_sector_t write_sector;
|
2005-11-21 22:05:14 +00:00
|
|
|
stream_read_sector_t read_sector;
|
|
|
|
stream_close_t close;
|
2005-11-23 22:37:27 +00:00
|
|
|
stream_get_blocksize_t get_blocksize;
|
2005-11-21 22:05:14 +00:00
|
|
|
} device_io_t;
|
|
|
|
|
|
|
|
typedef struct {
|
2005-11-21 23:52:44 +00:00
|
|
|
void *volume;
|
|
|
|
void *file;
|
2005-11-21 22:05:14 +00:00
|
|
|
stream_read_t read;
|
2005-11-21 23:52:44 +00:00
|
|
|
stream_lseek_t lseek;
|
2005-11-21 22:05:14 +00:00
|
|
|
stream_close_t close;
|
2005-11-21 23:52:44 +00:00
|
|
|
stream_umount_t umount;
|
2005-11-23 00:09:00 +00:00
|
|
|
stream_fstat_t fstat;
|
2005-11-21 22:05:14 +00:00
|
|
|
} filesystem_io_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
/* device interface */
|
|
|
|
|
|
|
|
device_io_t device;
|
|
|
|
|
|
|
|
/* filesystem interface */
|
|
|
|
|
|
|
|
filesystem_io_t fs;
|
2007-11-02 22:11:28 +00:00
|
|
|
|
|
|
|
/* info */
|
|
|
|
|
|
|
|
fs_t fs_id;
|
|
|
|
device_t device_id;
|
|
|
|
int unit, partition;
|
|
|
|
|
2005-11-21 22:05:14 +00:00
|
|
|
} stream_t;
|
|
|
|
|
|
|
|
extern stream_t *stream_open(char *dev);
|
|
|
|
extern int stream_read_sector(stream_t *stream,
|
|
|
|
off_t offset, void* buffer, size_t size);
|
2005-11-22 23:13:02 +00:00
|
|
|
extern int stream_read(stream_t *stream, void *buf, size_t count);
|
|
|
|
extern int stream_lseek(stream_t *stream, long offset, int whence);
|
2005-11-21 22:05:14 +00:00
|
|
|
extern int stream_close(stream_t *stream);
|
2005-11-22 23:13:02 +00:00
|
|
|
extern int stream_uncompress(stream_t *stream);
|
2005-11-23 00:09:00 +00:00
|
|
|
extern int stream_fstat(stream_t *stream, struct stream_stat *buf);
|
2005-11-21 22:05:14 +00:00
|
|
|
#endif /* __LIBSTREAM_H__ */
|