summaryrefslogtreecommitdiffstats
path: root/qemu/roms/openbios/include/fs/fs.h
blob: 0a22fa27853ccc3a830f5389bbc1d71f486dfca4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
 *   Creation Date: <2001/05/06 17:12:45 samuel>
 *   Time-stamp: <2003/10/22 11:43:45 samuel>
 *
 *	<fs_loader.h>
 *
 *	Generic file system access
 *
 *   Copyright (C) 2001, 2002, 2003 Samuel Rydh (samuel@ibrium.se)
 *
 *   This program is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU General Public License
 *   as published by the Free Software Foundation
 *
 */

#ifndef _H_FS
#define _H_FS


typedef struct fs_ops 		fs_ops_t;
typedef struct opaque_struct	file_desc_t;

#define fs_open_path( fs, path ) 	(fs)->open_path( fs, path )
#define fs_search_rom( fs )		(fs)->search_rom( fs )
#define fs_search_file( fs, name )	(fs)->search_file( fs, name )
#define fs_vol_name( fs, buf, size )	(fs)->vol_name( fs, buf, size )

struct fs_ops {
	void		*fs_data;
	int		fd;		/* owner block device */
	int		type;

	void		(*close_fs)( fs_ops_t *fs );
	file_desc_t 	*(*open_path)( fs_ops_t *fs, const char *path );
	file_desc_t 	*(*search_rom)( fs_ops_t *fs );
	file_desc_t 	*(*search_file)( fs_ops_t *fs, const char *name );
	char		*(*vol_name)( fs_ops_t *fs, char *buf, int size );

	/* file ops */
	void		(*close)( file_desc_t *file );
	int		(*read)( file_desc_t *file, void *buf, size_t count );
	int		(*lseek)( file_desc_t *file, off_t offset, int whence );
	char		*(*get_path)( file_desc_t *file, char *buf, int len );
	void		(*dir)( file_desc_t *file );

        const char     	*(*get_fstype)( fs_ops_t *fs );
};

extern fs_ops_t		*fs_open( int fs_type, int fd );
extern void		fs_close( fs_ops_t *fs );
const char 		*fs_get_name( fs_ops_t *fs );

#ifdef CONFIG_HFSP
extern int		fs_hfsp_open( int fd, fs_ops_t *fs );
extern int 		fs_hfsp_probe( int fd, long long offs );
#else
static inline int	fs_hfsp_open( int fd, fs_ops_t *fs ) { return -1; }
static inline int	fs_hfsp_probe( int fd, long long offs ) { return -1; }
#endif

#ifdef CONFIG_HFS
extern int		fs_hfs_open( int fd, fs_ops_t *fs );
extern int 		fs_hfs_probe( int fd, long long offs );
#else
static inline int	fs_hfs_open( int fd, fs_ops_t *fs ) { return -1; }
static inline int	fs_hfs_probe( int fd, long long offs ) { return -1; }
#endif

#ifdef CONFIG_ISO9660
extern int		fs_iso9660_open( int fd, fs_ops_t *fs );
extern int 		fs_iso9660_probe( int fd, long long offs );
#else
static inline int	fs_iso9660_open( int fd, fs_ops_t *fs ) { return -1; }
static inline int	fs_iso9660_probe( int fd, long long offs ) { return -1; }
#endif

#ifdef CONFIG_EXT2
extern int		fs_ext2_open( int fd, fs_ops_t *fs );
extern int 		fs_ext2_probe( int fd, long long offs );
#else
static inline int	fs_ext2_open( int fd, fs_ops_t *fs ) { return -1; }
static inline int	fs_ext2_probe( int fd, long long offs ) { return -1; }
#endif

#ifdef CONFIG_GRUBFS
extern int		fs_grubfs_open( int fd, fs_ops_t *fs );
extern int 		fs_grubfs_probe( int fd, long long offs );
#else
static inline int	fs_grubfs_open( int fd, fs_ops_t *fs ) { return -1; }
static inline int	fs_grubfs_probe( int fd, long long offs ) { return -1; }
#endif



/* misc */
extern char 		*get_hfs_vol_name( int fd, char *buf, int size );


#endif   /* _H_FS */