From 0dddb61de8bda455595f129709b1b3c6a5ecbf7f Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Wed, 23 Jun 2010 20:41:34 +0000 Subject: [PATCH] Fix up non-grub iso9660 filesystem, plus correct a thinko where the sense of the existing hfs/ext2 probe functions was inverted by default. Signed-off-by: Mark Cave-Ayland git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@796 f158a5a8-5612-0410-a976-696ce0be7e32 --- fs/ext2/ext2_fs.c | 4 ++-- fs/hfs/hfs_fs.c | 4 ++-- fs/hfsplus/hfsp_fs.c | 4 ++-- fs/iso9660/iso9660_fs.c | 9 +++++++++ fs/iso9660/iso9660_mount.c | 16 ++++++++++++++++ fs/iso9660/libiso9660.h | 1 + include/fs/fs.h | 2 ++ packages/misc-files.c | 6 +++--- 8 files changed, 37 insertions(+), 9 deletions(-) diff --git a/fs/ext2/ext2_fs.c b/fs/ext2/ext2_fs.c index 1e04b05..f91d3d5 100644 --- a/fs/ext2/ext2_fs.c +++ b/fs/ext2/ext2_fs.c @@ -205,7 +205,7 @@ int fs_ext2_open(int fd, fs_ops_t *fs) int fs_ext2_probe(int fd, llong offs) { if (ext2_probe(fd, offs)) - return -1; + return 0; - return 0; + return -1; } diff --git a/fs/hfs/hfs_fs.c b/fs/hfs/hfs_fs.c index e58f724..b624877 100644 --- a/fs/hfs/hfs_fs.c +++ b/fs/hfs/hfs_fs.c @@ -463,7 +463,7 @@ int fs_hfs_probe( int fd, llong offs ) { if (hfs_probe(fd, offs)) - return -1; + return 0; - return 0; + return -1; } diff --git a/fs/hfsplus/hfsp_fs.c b/fs/hfsplus/hfsp_fs.c index 3de6fdd..cdce906 100644 --- a/fs/hfsplus/hfsp_fs.c +++ b/fs/hfsplus/hfsp_fs.c @@ -402,7 +402,7 @@ int fs_hfsp_probe(int fd, llong offs) { if (volume_probe(fd, offs)) - return -1; + return 0; - return 0; + return -1; } diff --git a/fs/iso9660/iso9660_fs.c b/fs/iso9660/iso9660_fs.c index 59a661b..9fe3ee6 100644 --- a/fs/iso9660/iso9660_fs.c +++ b/fs/iso9660/iso9660_fs.c @@ -152,6 +152,15 @@ static const fs_ops_t iso9660_ops = { .get_fstype = get_fstype, }; +int +fs_iso9660_probe( int fd, llong offs ) +{ + if (iso9660_probe(fd, offs)) + return 0; + + return -1; +} + int fs_iso9660_open(int fd, fs_ops_t *fs) { iso9660_VOLUME *volume; diff --git a/fs/iso9660/iso9660_mount.c b/fs/iso9660/iso9660_mount.c index 88a38c9..16833a8 100644 --- a/fs/iso9660/iso9660_mount.c +++ b/fs/iso9660/iso9660_mount.c @@ -189,6 +189,22 @@ int iso9660_umount(iso9660_VOLUME* volume) return 0; } +int iso9660_probe(int fd, llong offset) +{ + struct iso_primary_descriptor ipd; + + seek_io(fd, 16 * ISOFS_BLOCK_SIZE + offset); + read_io(fd, &ipd, sizeof (ipd)); + + if ((ipd.type[0] != ISO_VD_PRIMARY) || + (strncmp(ipd.id, ISO_STANDARD_ID, sizeof (ipd.id)) != 0) || + (ipd.version[0] != 1)) { + return 0; + } + + return -1; +} + struct iso_directory_record *iso9660_get_root_node(iso9660_VOLUME* volume) { return (struct iso_directory_record *)volume->descriptor->root_directory_record; diff --git a/fs/iso9660/libiso9660.h b/fs/iso9660/libiso9660.h index 2a980aa..20c4184 100644 --- a/fs/iso9660/libiso9660.h +++ b/fs/iso9660/libiso9660.h @@ -14,6 +14,7 @@ extern iso9660_VOLUME* iso9660_mount(int fd); extern int iso9660_umount(iso9660_VOLUME *volume); +extern int iso9660_probe(int fd, llong offs); extern iso9660_DIR* iso9660_opendir(iso9660_VOLUME *, const char *name); extern iso9660_FILE* iso9660_open(iso9660_VOLUME *, const char *pathname); extern int iso9660_closedir(iso9660_DIR *dir); diff --git a/include/fs/fs.h b/include/fs/fs.h index 5bc0760..672a780 100644 --- a/include/fs/fs.h +++ b/include/fs/fs.h @@ -69,8 +69,10 @@ static inline int fs_hfs_probe( int fd, llong offs ) { return -1; } #ifdef CONFIG_ISO9660 extern int fs_iso9660_open( int fd, fs_ops_t *fs ); +extern int fs_iso9660_probe( int fd, llong offs ); #else static inline int fs_iso9660_open( int fd, fs_ops_t *fs ) { return -1; } +static inline int fs_iso9660_probe( int fd, llong offs ) { return -1; } #endif #ifdef CONFIG_EXT2 diff --git a/packages/misc-files.c b/packages/misc-files.c index e2004aa..5519b9b 100644 --- a/packages/misc-files.c +++ b/packages/misc-files.c @@ -359,12 +359,12 @@ files_probe( files_info_t *mi ) err = fs_hfs_probe(fd, offs); DPRINTF("--- HFS returned %d\n", err); } -/* + if( err ) { - err = fs_iso9660_open(fd, fs); + err = fs_iso9660_probe(fd, offs); DPRINTF("--- ISO9660 returned %d\n", err); } -*/ + if( err ) { err = fs_ext2_probe(fd, offs); DPRINTF("--- ext2 returned %d\n", err);