mirror of
https://github.com/vivier/EMILE.git
synced 2024-12-22 10:29:31 +00:00
Add stream_fstat()
This commit is contained in:
parent
341672825a
commit
a55aa395c7
@ -13,7 +13,7 @@ CPPFLAGS = -I$(TOP)/../libfloppy -I$(TOP)/../libscsi -I$(TOP)/../libblock \
|
||||
LIBRARY = libstream.a
|
||||
|
||||
SOURCES = stream_close.c stream_open.c stream_read.c stream_lseek.c \
|
||||
stream_uncompress.c gzio.c
|
||||
stream_uncompress.c gzio.c stream_fstat.c
|
||||
|
||||
HEADERS = libstream.h
|
||||
|
||||
|
@ -9,11 +9,16 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct stream_stat {
|
||||
off_t st_size;
|
||||
};
|
||||
|
||||
typedef int (*stream_read_sector_t)(void *data,off_t offset, void* buffer, size_t size);
|
||||
typedef ssize_t (*stream_read_t)(void *data, void *buf, size_t count);
|
||||
typedef int (*stream_lseek_t)(void *data, long offset, int whence);
|
||||
typedef int (*stream_close_t)(void *data);
|
||||
typedef int (*stream_umount_t)(void *data);
|
||||
typedef int (*stream_fstat_t)(void *data, struct stream_stat *buf);
|
||||
|
||||
typedef struct {
|
||||
void *data;
|
||||
@ -28,6 +33,7 @@ typedef struct {
|
||||
stream_lseek_t lseek;
|
||||
stream_close_t close;
|
||||
stream_umount_t umount;
|
||||
stream_fstat_t fstat;
|
||||
} filesystem_io_t;
|
||||
|
||||
typedef struct {
|
||||
@ -47,4 +53,5 @@ extern int stream_read(stream_t *stream, void *buf, size_t count);
|
||||
extern int stream_lseek(stream_t *stream, long offset, int whence);
|
||||
extern int stream_close(stream_t *stream);
|
||||
extern int stream_uncompress(stream_t *stream);
|
||||
extern int stream_fstat(stream_t *stream, struct stream_stat *buf);
|
||||
#endif /* __LIBSTREAM_H__ */
|
||||
|
15
libstream/stream_fstat.c
Normal file
15
libstream/stream_fstat.c
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "libstream.h"
|
||||
|
||||
int stream_fstat(stream_t *stream, struct stream_stat *buf)
|
||||
{
|
||||
if (stream->fs.fstat == NULL)
|
||||
return -1;
|
||||
|
||||
return stream->fs.fstat(stream->fs.file, buf);
|
||||
}
|
@ -160,17 +160,21 @@ stream_t *stream_open(char *dev)
|
||||
case fs_BLOCK:
|
||||
if (stream->fs.data == NULL)
|
||||
goto outfs;
|
||||
stream->fs.read = block_read;
|
||||
stream->fs.seek = block_seek;
|
||||
stream->fs.close = block_close;
|
||||
stream->fs.read = (stream_read_t)block_read;
|
||||
stream->fs.seek = (stream_lseek_t)block_seek;
|
||||
stream->fs.close = (stream_close_t)block_close;
|
||||
stream->fs.umount = (stream_umount_t)block_umount;
|
||||
stream->fs.fstat = (stream_fstat_t)block_fstat;
|
||||
break;
|
||||
case fs_CONTAINER:
|
||||
stream->fs.data = container_open(&stream->device, current);
|
||||
if (stream->fs.data == NULL)
|
||||
goto outfs;
|
||||
stream->fs.read = container_read;
|
||||
stream->fs.seek = container_seek;
|
||||
stream->fs.close = container_close;
|
||||
stream->fs.read = (stream_read_t)container_read;
|
||||
stream->fs.seek = (stream_lseek_t)container_seek;
|
||||
stream->fs.close = (stream_close_t)container_close;
|
||||
stream->fs.umount = (stream_umount_t)container_umount;
|
||||
stream->fs.fstat = (stream_fstat_t)container_fstat;
|
||||
break;
|
||||
#endif
|
||||
case fs_ISO9660:
|
||||
@ -190,6 +194,7 @@ stream_t *stream_open(char *dev)
|
||||
stream->fs.lseek = (stream_lseek_t)iso9660_lseek;
|
||||
stream->fs.close = (stream_close_t)iso9660_close;
|
||||
stream->fs.umount = (stream_umount_t)iso9660_umount;
|
||||
stream->fs.fstat = (stream_fstat_t)iso9660_fstat;
|
||||
break;
|
||||
default:
|
||||
outfs:
|
||||
|
Loading…
Reference in New Issue
Block a user