Home | History | Annotate | Download | only in stage2
      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_UFS2
     34 #define FSYS_UFS2_NUM 1
     35 int ufs2_mount (void);
     36 int ufs2_read (char *buf, int len);
     37 int ufs2_dir (char *dirname);
     38 int ufs2_embed (int *start_sector, int needed_sectors);
     39 #else
     40 #define FSYS_UFS2_NUM 0
     41 #endif
     42 
     43 #ifdef FSYS_FAT
     44 #define FSYS_FAT_NUM 1
     45 int fat_mount (void);
     46 int fat_read (char *buf, int len);
     47 int fat_dir (char *dirname);
     48 #else
     49 #define FSYS_FAT_NUM 0
     50 #endif
     51 
     52 #ifdef FSYS_EXT2FS
     53 #define FSYS_EXT2FS_NUM 1
     54 int ext2fs_mount (void);
     55 int ext2fs_read (char *buf, int len);
     56 int ext2fs_dir (char *dirname);
     57 #else
     58 #define FSYS_EXT2FS_NUM 0
     59 #endif
     60 
     61 #ifdef FSYS_MINIX
     62 #define FSYS_MINIX_NUM 1
     63 int minix_mount (void);
     64 int minix_read (char *buf, int len);
     65 int minix_dir (char *dirname);
     66 #else
     67 #define FSYS_MINIX_NUM 0
     68 #endif
     69 
     70 #ifdef FSYS_REISERFS
     71 #define FSYS_REISERFS_NUM 1
     72 int reiserfs_mount (void);
     73 int reiserfs_read (char *buf, int len);
     74 int reiserfs_dir (char *dirname);
     75 int reiserfs_embed (int *start_sector, int needed_sectors);
     76 #else
     77 #define FSYS_REISERFS_NUM 0
     78 #endif
     79 
     80 #ifdef FSYS_VSTAFS
     81 #define FSYS_VSTAFS_NUM 1
     82 int vstafs_mount (void);
     83 int vstafs_read (char *buf, int len);
     84 int vstafs_dir (char *dirname);
     85 #else
     86 #define FSYS_VSTAFS_NUM 0
     87 #endif
     88 
     89 #ifdef FSYS_JFS
     90 #define FSYS_JFS_NUM 1
     91 int jfs_mount (void);
     92 int jfs_read (char *buf, int len);
     93 int jfs_dir (char *dirname);
     94 int jfs_embed (int *start_sector, int needed_sectors);
     95 #else
     96 #define FSYS_JFS_NUM 0
     97 #endif
     98 
     99 #ifdef FSYS_XFS
    100 #define FSYS_XFS_NUM 1
    101 int xfs_mount (void);
    102 int xfs_read (char *buf, int len);
    103 int xfs_dir (char *dirname);
    104 #else
    105 #define FSYS_XFS_NUM 0
    106 #endif
    107 
    108 #ifdef FSYS_TFTP
    109 #define FSYS_TFTP_NUM 1
    110 int tftp_mount (void);
    111 int tftp_read (char *buf, int len);
    112 int tftp_dir (char *dirname);
    113 void tftp_close (void);
    114 #else
    115 #define FSYS_TFTP_NUM 0
    116 #endif
    117 
    118 #ifdef FSYS_ISO9660
    119 #define FSYS_ISO9660_NUM 1
    120 int iso9660_mount (void);
    121 int iso9660_read (char *buf, int len);
    122 int iso9660_dir (char *dirname);
    123 #else
    124 #define FSYS_ISO9660_NUM 0
    125 #endif
    126 
    127 #ifndef NUM_FSYS
    128 #define NUM_FSYS	\
    129   (FSYS_FFS_NUM + FSYS_FAT_NUM + FSYS_EXT2FS_NUM + FSYS_MINIX_NUM	\
    130    + FSYS_REISERFS_NUM + FSYS_VSTAFS_NUM + FSYS_JFS_NUM + FSYS_XFS_NUM	\
    131    + FSYS_TFTP_NUM + FSYS_ISO9660_NUM + FSYS_UFS2_NUM)
    132 #endif
    133 
    134 /* defines for the block filesystem info area */
    135 #ifndef NO_BLOCK_FILES
    136 #define BLK_CUR_FILEPOS      (*((int*)FSYS_BUF))
    137 #define BLK_CUR_BLKLIST      (*((int*)(FSYS_BUF+4)))
    138 #define BLK_CUR_BLKNUM       (*((int*)(FSYS_BUF+8)))
    139 #define BLK_MAX_ADDR         (FSYS_BUF+0x7FF9)
    140 #define BLK_BLKSTART(l)      (*((int*)l))
    141 #define BLK_BLKLENGTH(l)     (*((int*)(l+4)))
    142 #define BLK_BLKLIST_START    (FSYS_BUF+12)
    143 #define BLK_BLKLIST_INC_VAL  8
    144 #endif /* NO_BLOCK_FILES */
    145 
    146 /* this next part is pretty ugly, but it keeps it in one place! */
    147 
    148 struct fsys_entry
    149 {
    150   char *name;
    151   int (*mount_func) (void);
    152   int (*read_func) (char *buf, int len);
    153   int (*dir_func) (char *dirname);
    154   void (*close_func) (void);
    155   int (*embed_func) (int *start_sector, int needed_sectors);
    156 };
    157 
    158 #ifdef STAGE1_5
    159 # define print_possibilities 0
    160 #else
    161 extern int print_possibilities;
    162 #endif
    163 
    164 extern int fsmax;
    165 extern struct fsys_entry fsys_table[NUM_FSYS + 1];
    166