1/* filesys.h - abstract filesystem interface */ 2/* 3 * GRUB -- GRand Unified Bootloader 4 * Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 */ 20 21#include "pc_slice.h" 22 23#ifdef FSYS_FFS 24#define FSYS_FFS_NUM 1 25int ffs_mount (void); 26int ffs_read (char *buf, int len); 27int ffs_dir (char *dirname); 28int ffs_embed (int *start_sector, int needed_sectors); 29#else 30#define FSYS_FFS_NUM 0 31#endif 32 33#ifdef FSYS_UFS 34#define FSYS_UFS_NUM 1 35int ufs_mount (void); 36int ufs_read (char *buf, int len); 37int ufs_dir (char *dirname); 38int ufs_embed (int *start_sector, int needed_sectors); 39#else 40#define FSYS_UFS_NUM 0 41#endif 42 43#ifdef FSYS_UFS2 44#define FSYS_UFS2_NUM 1 45int ufs2_mount (void); 46int ufs2_read (char *buf, int len); 47int ufs2_dir (char *dirname); 48int ufs2_embed (int *start_sector, int needed_sectors); 49#else 50#define FSYS_UFS2_NUM 0 51#endif 52 53#ifdef FSYS_ZFS 54#define FSYS_ZFS_NUM 1 55int zfs_mount (void); 56int zfs_read (char *buf, int len); 57int zfs_open (char *dirname); 58int zfs_embed (int *start_sector, int needed_sectors); 59#else 60#define FSYS_ZFS_NUM 0 61#endif 62 63#ifdef FSYS_FAT 64#define FSYS_FAT_NUM 1 65int fat_mount (void); 66int fat_read (char *buf, int len); 67int fat_dir (char *dirname); 68#else 69#define FSYS_FAT_NUM 0 70#endif 71 72#ifdef FSYS_EXT2FS 73#define FSYS_EXT2FS_NUM 1 74int ext2fs_mount (void); 75int ext2fs_read (char *buf, int len); 76int ext2fs_dir (char *dirname); 77#else 78#define FSYS_EXT2FS_NUM 0 79#endif 80 81#ifdef FSYS_MINIX 82#define FSYS_MINIX_NUM 1 83int minix_mount (void); 84int minix_read (char *buf, int len); 85int minix_dir (char *dirname); 86#else 87#define FSYS_MINIX_NUM 0 88#endif 89 90#ifdef FSYS_REISERFS 91#define FSYS_REISERFS_NUM 1 92int reiserfs_mount (void); 93int reiserfs_read (char *buf, int len); 94int reiserfs_dir (char *dirname); 95int reiserfs_embed (int *start_sector, int needed_sectors); 96#else 97#define FSYS_REISERFS_NUM 0 98#endif 99 100#ifdef FSYS_VSTAFS 101#define FSYS_VSTAFS_NUM 1 102int vstafs_mount (void); 103int vstafs_read (char *buf, int len); 104int vstafs_dir (char *dirname); 105#else 106#define FSYS_VSTAFS_NUM 0 107#endif 108 109#ifdef FSYS_JFS 110#define FSYS_JFS_NUM 1 111int jfs_mount (void); 112int jfs_read (char *buf, int len); 113int jfs_dir (char *dirname); 114int jfs_embed (int *start_sector, int needed_sectors); 115#else 116#define FSYS_JFS_NUM 0 117#endif 118 119#ifdef FSYS_XFS 120#define FSYS_XFS_NUM 1 121int xfs_mount (void); 122int xfs_read (char *buf, int len); 123int xfs_dir (char *dirname); 124#else 125#define FSYS_XFS_NUM 0 126#endif 127 128#ifdef FSYS_TFTP 129#define FSYS_TFTP_NUM 1 130int tftp_mount (void); 131int tftp_read (char *buf, int len); 132int tftp_dir (char *dirname); 133void tftp_close (void); 134#else 135#define FSYS_TFTP_NUM 0 136#endif 137 138#ifdef FSYS_ISO9660 139#define FSYS_ISO9660_NUM 1 140int iso9660_mount (void); 141int iso9660_read (char *buf, int len); 142int iso9660_dir (char *dirname); 143#else 144#define FSYS_ISO9660_NUM 0 145#endif 146 147#ifndef NUM_FSYS 148#define NUM_FSYS \ 149 (FSYS_FFS_NUM + FSYS_FAT_NUM + FSYS_EXT2FS_NUM + FSYS_MINIX_NUM \ 150 + FSYS_REISERFS_NUM + FSYS_VSTAFS_NUM + FSYS_JFS_NUM + FSYS_XFS_NUM \ 151 + FSYS_TFTP_NUM + FSYS_ISO9660_NUM + FSYS_UFS_NUM + FSYS_UFS2_NUM \ 152 + FSYS_ZFS_NUM) 153#endif 154 155/* defines for the block filesystem info area */ 156#ifndef NO_BLOCK_FILES 157#define BLK_CUR_FILEPOS (*((int*)FSYS_BUF)) 158#define BLK_CUR_BLKLIST (*((int*)(FSYS_BUF+4))) 159#define BLK_CUR_BLKNUM (*((int*)(FSYS_BUF+8))) 160#define BLK_MAX_ADDR (FSYS_BUF+0x7FF9) 161#define BLK_BLKSTART(l) (*((int*)l)) 162#define BLK_BLKLENGTH(l) (*((int*)(l+4))) 163#define BLK_BLKLIST_START (FSYS_BUF+12) 164#define BLK_BLKLIST_INC_VAL 8 165#endif /* NO_BLOCK_FILES */ 166 167/* this next part is pretty ugly, but it keeps it in one place! */ 168 169struct fsys_entry 170{ 171 char *name; 172 int (*mount_func) (void); 173 int (*read_func) (char *buf, int len); 174 int (*dir_func) (char *dirname); 175 void (*close_func) (void); 176 int (*embed_func) (int *start_sector, int needed_sectors); 177}; 178 179#ifdef STAGE1_5 180# define print_possibilities 0 181#else 182extern int print_possibilities; 183#endif 184 185extern int fsmax; 186extern struct fsys_entry fsys_table[NUM_FSYS + 1]; 187