vfs.c revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* Interface between GRUB's fs drivers and application code */
#include <lib.h>
#include "filesys.h"
#include <fs.h>
#define DEBUG_THIS DEBUG_VFS
#include <debug.h>
int filepos;
int filemax;
void (*disk_read_hook) (int, int, int);
void (*disk_read_func) (int, int, int);
char FSYS_BUF[FSYS_BUFLEN];
int fsmax;
struct fsys_entry {
char *name;
int (*mount_func) (void);
void (*close_func) (void);
};
struct fsys_entry fsys_table[] = {
# ifdef FSYS_FAT
# endif
# ifdef FSYS_EXT2FS
# endif
# ifdef FSYS_MINIX
# endif
# ifdef FSYS_REISERFS
# endif
# ifdef FSYS_JFS
# endif
# ifdef FSYS_XFS
# endif
# ifdef FSYS_ISO9660
# endif
};
/* NULLFS is used to read images from raw device */
static int nullfs_dir(char *name)
{
if (name) {
debug("can't have a named file\n");
return 0;
}
/* GRUB code doesn't like 2GB or bigger files */
if (dev_size > 0x7fffffff)
dev_size = 0x7fffffff;
return 1;
}
{
return len;
} else
return 0;
}
static struct fsys_entry nullfs =
static struct fsys_entry *fsys;
int mount_fs(void)
{
int i;
for (i = 0; i < sizeof(fsys_table)/sizeof(fsys_table[0]); i++) {
if (fsys_table[i].mount_func()) {
fsys = &fsys_table[i];
return 1;
}
}
fsys = 0;
printf("Unknown filesystem type\n");
return 0;
}
{
char dev[32];
// char *dev=0;
const char *path;
int len;
int retval = 0;
int reopen;
if (path) {
path++;
//dev = malloc(len + 1);
} else {
/* No colon is given. Is this device or filename? */
if (filename[0] == '/') {
/* Anything starts with '/' must be a filename */
// dev = 0;
dev[0]=0;
} else {
// dev = strdup(filename);
path = 0;
}
}
fsys = 0;
goto out;
}
if (!reopen)
fsys = 0;
}
if (path) {
if (!mount_fs())
goto out;
}
using_devsize = 0;
if (!path[0]) {
printf("No filename is given\n");
goto out;
}
} else
filepos = 0;
errnum = 0;
// printf("File not found\n");
goto out;
}
retval = 1;
out:
// if (dev)
// free(dev);
return retval;
}
{
errnum = 0;
}
{
return filepos;
}
unsigned long file_size(void)
{
return filemax;
}
void file_close(void)
{
}