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 25 int ffs_mount (void); 26 int ffs_read (char *buf, int len); 27 int ffs_dir (char *dirname); 28 int 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 35 int ufs_mount (void); 36 int ufs_read (char *buf, int len); 37 int ufs_dir (char *dirname); 38 int 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 45 int ufs2_mount (void); 46 int ufs2_read (char *buf, int len); 47 int ufs2_dir (char *dirname); 48 int 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 55 int zfs_mount (void); 56 int zfs_read (char *buf, int len); 57 int zfs_open (char *dirname); 58 int 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 65 int fat_mount (void); 66 int fat_read (char *buf, int len); 67 int 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 74 int ext2fs_mount (void); 75 int ext2fs_read (char *buf, int len); 76 int 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 83 int minix_mount (void); 84 int minix_read (char *buf, int len); 85 int 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 92 int reiserfs_mount (void); 93 int reiserfs_read (char *buf, int len); 94 int reiserfs_dir (char *dirname); 95 int 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 102 int vstafs_mount (void); 103 int vstafs_read (char *buf, int len); 104 int 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 111 int jfs_mount (void); 112 int jfs_read (char *buf, int len); 113 int jfs_dir (char *dirname); 114 int 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 121 int xfs_mount (void); 122 int xfs_read (char *buf, int len); 123 int 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 130 int tftp_mount (void); 131 int tftp_read (char *buf, int len); 132 int tftp_dir (char *dirname); 133 void tftp_close (void); 134 #else 135 #define FSYS_TFTP_NUM 0 136 #endif 137 138 #ifdef FSYS_ISO9660 139 #define FSYS_ISO9660_NUM 1 140 int iso9660_mount (void); 141 int iso9660_read (char *buf, int len); 142 int 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 169 struct 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 182 extern int print_possibilities; 183 #endif 184 185 extern int fsmax; 186 extern struct fsys_entry fsys_table[NUM_FSYS + 1]; 187