17c478bd9Sstevel@tonic-gate /* filesys.h - abstract filesystem interface */ 27c478bd9Sstevel@tonic-gate /* 37c478bd9Sstevel@tonic-gate * GRUB -- GRand Unified Bootloader 47c478bd9Sstevel@tonic-gate * Copyright (C) 1999,2000,2001,2004 Free Software Foundation, Inc. 57c478bd9Sstevel@tonic-gate * 67c478bd9Sstevel@tonic-gate * This program is free software; you can redistribute it and/or modify 77c478bd9Sstevel@tonic-gate * it under the terms of the GNU General Public License as published by 87c478bd9Sstevel@tonic-gate * the Free Software Foundation; either version 2 of the License, or 97c478bd9Sstevel@tonic-gate * (at your option) any later version. 107c478bd9Sstevel@tonic-gate * 117c478bd9Sstevel@tonic-gate * This program is distributed in the hope that it will be useful, 127c478bd9Sstevel@tonic-gate * but WITHOUT ANY WARRANTY; without even the implied warranty of 137c478bd9Sstevel@tonic-gate * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 147c478bd9Sstevel@tonic-gate * GNU General Public License for more details. 157c478bd9Sstevel@tonic-gate * 167c478bd9Sstevel@tonic-gate * You should have received a copy of the GNU General Public License 177c478bd9Sstevel@tonic-gate * along with this program; if not, write to the Free Software 187c478bd9Sstevel@tonic-gate * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 197c478bd9Sstevel@tonic-gate */ 207c478bd9Sstevel@tonic-gate 217c478bd9Sstevel@tonic-gate #include "pc_slice.h" 227c478bd9Sstevel@tonic-gate 237c478bd9Sstevel@tonic-gate #ifdef FSYS_FFS 247c478bd9Sstevel@tonic-gate #define FSYS_FFS_NUM 1 257c478bd9Sstevel@tonic-gate int ffs_mount (void); 267c478bd9Sstevel@tonic-gate int ffs_read (char *buf, int len); 277c478bd9Sstevel@tonic-gate int ffs_dir (char *dirname); 28*2e1aefd1SJoshua M. Clulow int ffs_embed (unsigned long long *start_sector, int needed_sectors); 297c478bd9Sstevel@tonic-gate #else 307c478bd9Sstevel@tonic-gate #define FSYS_FFS_NUM 0 317c478bd9Sstevel@tonic-gate #endif 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifdef FSYS_UFS 347c478bd9Sstevel@tonic-gate #define FSYS_UFS_NUM 1 357c478bd9Sstevel@tonic-gate int ufs_mount (void); 367c478bd9Sstevel@tonic-gate int ufs_read (char *buf, int len); 377c478bd9Sstevel@tonic-gate int ufs_dir (char *dirname); 38*2e1aefd1SJoshua M. Clulow int ufs_embed (unsigned long long *start_sector, int needed_sectors); 397c478bd9Sstevel@tonic-gate #else 407c478bd9Sstevel@tonic-gate #define FSYS_UFS_NUM 0 417c478bd9Sstevel@tonic-gate #endif 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #ifdef FSYS_UFS2 447c478bd9Sstevel@tonic-gate #define FSYS_UFS2_NUM 1 457c478bd9Sstevel@tonic-gate int ufs2_mount (void); 467c478bd9Sstevel@tonic-gate int ufs2_read (char *buf, int len); 477c478bd9Sstevel@tonic-gate int ufs2_dir (char *dirname); 48*2e1aefd1SJoshua M. Clulow int ufs2_embed (unsigned long long *start_sector, int needed_sectors); 497c478bd9Sstevel@tonic-gate #else 507c478bd9Sstevel@tonic-gate #define FSYS_UFS2_NUM 0 517c478bd9Sstevel@tonic-gate #endif 527c478bd9Sstevel@tonic-gate 53b1b8ab34Slling #ifdef FSYS_ZFS 54b1b8ab34Slling #define FSYS_ZFS_NUM 1 55b1b8ab34Slling int zfs_mount (void); 56b1b8ab34Slling int zfs_read (char *buf, int len); 57b1b8ab34Slling int zfs_open (char *dirname); 58*2e1aefd1SJoshua M. Clulow int zfs_embed (unsigned long long *start_sector, int needed_sectors); 59b1b8ab34Slling #else 60b1b8ab34Slling #define FSYS_ZFS_NUM 0 61b1b8ab34Slling #endif 62b1b8ab34Slling 637c478bd9Sstevel@tonic-gate #ifdef FSYS_FAT 647c478bd9Sstevel@tonic-gate #define FSYS_FAT_NUM 1 657c478bd9Sstevel@tonic-gate int fat_mount (void); 667c478bd9Sstevel@tonic-gate int fat_read (char *buf, int len); 677c478bd9Sstevel@tonic-gate int fat_dir (char *dirname); 687c478bd9Sstevel@tonic-gate #else 697c478bd9Sstevel@tonic-gate #define FSYS_FAT_NUM 0 707c478bd9Sstevel@tonic-gate #endif 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate #ifdef FSYS_EXT2FS 737c478bd9Sstevel@tonic-gate #define FSYS_EXT2FS_NUM 1 747c478bd9Sstevel@tonic-gate int ext2fs_mount (void); 757c478bd9Sstevel@tonic-gate int ext2fs_read (char *buf, int len); 767c478bd9Sstevel@tonic-gate int ext2fs_dir (char *dirname); 777c478bd9Sstevel@tonic-gate #else 787c478bd9Sstevel@tonic-gate #define FSYS_EXT2FS_NUM 0 797c478bd9Sstevel@tonic-gate #endif 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate #ifdef FSYS_MINIX 827c478bd9Sstevel@tonic-gate #define FSYS_MINIX_NUM 1 837c478bd9Sstevel@tonic-gate int minix_mount (void); 847c478bd9Sstevel@tonic-gate int minix_read (char *buf, int len); 857c478bd9Sstevel@tonic-gate int minix_dir (char *dirname); 867c478bd9Sstevel@tonic-gate #else 877c478bd9Sstevel@tonic-gate #define FSYS_MINIX_NUM 0 887c478bd9Sstevel@tonic-gate #endif 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate #ifdef FSYS_REISERFS 917c478bd9Sstevel@tonic-gate #define FSYS_REISERFS_NUM 1 927c478bd9Sstevel@tonic-gate int reiserfs_mount (void); 937c478bd9Sstevel@tonic-gate int reiserfs_read (char *buf, int len); 947c478bd9Sstevel@tonic-gate int reiserfs_dir (char *dirname); 95*2e1aefd1SJoshua M. Clulow int reiserfs_embed (unsigned long long *start_sector, int needed_sectors); 967c478bd9Sstevel@tonic-gate #else 977c478bd9Sstevel@tonic-gate #define FSYS_REISERFS_NUM 0 987c478bd9Sstevel@tonic-gate #endif 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate #ifdef FSYS_VSTAFS 1017c478bd9Sstevel@tonic-gate #define FSYS_VSTAFS_NUM 1 1027c478bd9Sstevel@tonic-gate int vstafs_mount (void); 1037c478bd9Sstevel@tonic-gate int vstafs_read (char *buf, int len); 1047c478bd9Sstevel@tonic-gate int vstafs_dir (char *dirname); 1057c478bd9Sstevel@tonic-gate #else 1067c478bd9Sstevel@tonic-gate #define FSYS_VSTAFS_NUM 0 1077c478bd9Sstevel@tonic-gate #endif 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate #ifdef FSYS_JFS 1107c478bd9Sstevel@tonic-gate #define FSYS_JFS_NUM 1 1117c478bd9Sstevel@tonic-gate int jfs_mount (void); 1127c478bd9Sstevel@tonic-gate int jfs_read (char *buf, int len); 1137c478bd9Sstevel@tonic-gate int jfs_dir (char *dirname); 114*2e1aefd1SJoshua M. Clulow int jfs_embed (unsigned long long *start_sector, int needed_sectors); 1157c478bd9Sstevel@tonic-gate #else 1167c478bd9Sstevel@tonic-gate #define FSYS_JFS_NUM 0 1177c478bd9Sstevel@tonic-gate #endif 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate #ifdef FSYS_XFS 1207c478bd9Sstevel@tonic-gate #define FSYS_XFS_NUM 1 1217c478bd9Sstevel@tonic-gate int xfs_mount (void); 1227c478bd9Sstevel@tonic-gate int xfs_read (char *buf, int len); 1237c478bd9Sstevel@tonic-gate int xfs_dir (char *dirname); 1247c478bd9Sstevel@tonic-gate #else 1257c478bd9Sstevel@tonic-gate #define FSYS_XFS_NUM 0 1267c478bd9Sstevel@tonic-gate #endif 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate #ifdef FSYS_TFTP 1297c478bd9Sstevel@tonic-gate #define FSYS_TFTP_NUM 1 1307c478bd9Sstevel@tonic-gate int tftp_mount (void); 1317c478bd9Sstevel@tonic-gate int tftp_read (char *buf, int len); 1327c478bd9Sstevel@tonic-gate int tftp_dir (char *dirname); 1337c478bd9Sstevel@tonic-gate void tftp_close (void); 1347c478bd9Sstevel@tonic-gate #else 1357c478bd9Sstevel@tonic-gate #define FSYS_TFTP_NUM 0 1367c478bd9Sstevel@tonic-gate #endif 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate #ifdef FSYS_ISO9660 1397c478bd9Sstevel@tonic-gate #define FSYS_ISO9660_NUM 1 1407c478bd9Sstevel@tonic-gate int iso9660_mount (void); 1417c478bd9Sstevel@tonic-gate int iso9660_read (char *buf, int len); 1427c478bd9Sstevel@tonic-gate int iso9660_dir (char *dirname); 1437c478bd9Sstevel@tonic-gate #else 1447c478bd9Sstevel@tonic-gate #define FSYS_ISO9660_NUM 0 1457c478bd9Sstevel@tonic-gate #endif 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate #ifndef NUM_FSYS 1487c478bd9Sstevel@tonic-gate #define NUM_FSYS \ 1497c478bd9Sstevel@tonic-gate (FSYS_FFS_NUM + FSYS_FAT_NUM + FSYS_EXT2FS_NUM + FSYS_MINIX_NUM \ 1507c478bd9Sstevel@tonic-gate + FSYS_REISERFS_NUM + FSYS_VSTAFS_NUM + FSYS_JFS_NUM + FSYS_XFS_NUM \ 151b1b8ab34Slling + FSYS_TFTP_NUM + FSYS_ISO9660_NUM + FSYS_UFS_NUM + FSYS_UFS2_NUM \ 152b1b8ab34Slling + FSYS_ZFS_NUM) 1537c478bd9Sstevel@tonic-gate #endif 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate /* defines for the block filesystem info area */ 1567c478bd9Sstevel@tonic-gate #ifndef NO_BLOCK_FILES 1577c478bd9Sstevel@tonic-gate #define BLK_CUR_FILEPOS (*((int*)FSYS_BUF)) 1587c478bd9Sstevel@tonic-gate #define BLK_CUR_BLKLIST (*((int*)(FSYS_BUF+4))) 1597c478bd9Sstevel@tonic-gate #define BLK_CUR_BLKNUM (*((int*)(FSYS_BUF+8))) 1607c478bd9Sstevel@tonic-gate #define BLK_MAX_ADDR (FSYS_BUF+0x7FF9) 1617c478bd9Sstevel@tonic-gate #define BLK_BLKSTART(l) (*((int*)l)) 1627c478bd9Sstevel@tonic-gate #define BLK_BLKLENGTH(l) (*((int*)(l+4))) 1637c478bd9Sstevel@tonic-gate #define BLK_BLKLIST_START (FSYS_BUF+12) 1647c478bd9Sstevel@tonic-gate #define BLK_BLKLIST_INC_VAL 8 1657c478bd9Sstevel@tonic-gate #endif /* NO_BLOCK_FILES */ 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate /* this next part is pretty ugly, but it keeps it in one place! */ 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate struct fsys_entry 1707c478bd9Sstevel@tonic-gate { 1717c478bd9Sstevel@tonic-gate char *name; 1727c478bd9Sstevel@tonic-gate int (*mount_func) (void); 1737c478bd9Sstevel@tonic-gate int (*read_func) (char *buf, int len); 1747c478bd9Sstevel@tonic-gate int (*dir_func) (char *dirname); 1757c478bd9Sstevel@tonic-gate void (*close_func) (void); 176*2e1aefd1SJoshua M. Clulow int (*embed_func) (unsigned long long *start_sector, int needed_sectors); 1777c478bd9Sstevel@tonic-gate }; 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate #ifdef STAGE1_5 1807c478bd9Sstevel@tonic-gate # define print_possibilities 0 1817c478bd9Sstevel@tonic-gate #else 1827c478bd9Sstevel@tonic-gate extern int print_possibilities; 1837c478bd9Sstevel@tonic-gate #endif 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate extern int fsmax; 1867c478bd9Sstevel@tonic-gate extern struct fsys_entry fsys_table[NUM_FSYS + 1]; 187