#ifndef _SYS_BOOTVFS_H
#define _SYS_BOOTVFS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/bootstat.h>
#include <sys/dirent.h>
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#define VFS_SUCCESS 0
#define VFS_FAILURE -1
struct boot_fs_ops {
char *fsw_name;
int (*fsw_mountroot)(char *str);
int (*fsw_unmountroot)(void);
int (*fsw_open)(char *filename, int flags);
int (*fsw_close)(int fd);
ssize_t (*fsw_read)(int fd, caddr_t buf, size_t size);
off_t (*fsw_lseek)(int filefd, off_t addr, int whence);
int (*fsw_fstat)(int filefd, struct bootstat *buf);
void (*fsw_closeall)(int flag);
int (*fsw_getdents)(int fd, struct dirent *buf, unsigned size);
};
extern struct boot_fs_ops *bfs_ops;
#ifdef _KERNEL
extern int BRD_MOUNTROOT(struct boot_fs_ops *, char *);
extern int BRD_UNMOUNTROOT(struct boot_fs_ops *);
extern int BRD_OPEN(struct boot_fs_ops *, char *, int);
extern int BRD_CLOSE(struct boot_fs_ops *, int);
extern ssize_t BRD_READ(struct boot_fs_ops *, int, caddr_t, size_t);
extern off_t BRD_SEEK(struct boot_fs_ops *, int, off_t, int);
extern int BRD_FSTAT(struct boot_fs_ops *, int, struct bootstat *);
#else
#define BRD_MOUNTROOT(ops, str) ((ops)->fsw_mountroot)(str)
#define BRD_UNMOUNTROOT(ops) ((ops)->fsw_unmountroot)()
#define BRD_OPEN(ops, file, flag) ((ops)->fsw_open)(file, flag)
#define BRD_CLOSE(ops, fd) ((ops)->fsw_close)(fd)
#define BRD_READ(ops, fd, buf, s) ((ops)->fsw_read)(fd, buf, s)
#define BRD_SEEK(ops, fd, addr, w) ((ops)->fsw_lseek)(fd, addr, w)
#define BRD_FSTAT(ops, fd, stp) ((ops)->fsw_fstat)(fd, stp)
#endif
#define SYSTEM_BOOT_PATH "/system/boot"
#define BFD_F_SYSTEM_BOOT 0x40000000
#ifdef _BOOT
extern int mountroot(char *str);
extern int unmountroot(void);
extern int open(const char *filename, int flags);
extern int close(int fd);
extern ssize_t read(int fd, void *buf, size_t size);
extern off_t lseek(int filefd, off_t addr, int whence);
extern void closeall(int flag);
#endif
#ifdef __cplusplus
}
#endif
#endif