From 2e863bf2ce3c6144815f4a3b8f3cfd4a5ce15b5d Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Wed, 24 May 2006 11:10:55 +0000 Subject: [PATCH] some filesystem fixes (mostly remainder from blueswirl's -15) git-svn-id: svn://coreboot.org/openbios/openbios-devel@31 f158a5a8-5612-0410-a976-696ce0be7e32 --- fs/grubfs/fsys_ext2fs.c | 5 +++++ fs/grubfs/grubfs_fs.c | 2 +- fs/grubfs/iso9660.h | 11 +++++++---- libc/diskio.c | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/fs/grubfs/fsys_ext2fs.c b/fs/grubfs/fsys_ext2fs.c index b67e505..112a49b 100644 --- a/fs/grubfs/fsys_ext2fs.c +++ b/fs/grubfs/fsys_ext2fs.c @@ -19,10 +19,15 @@ #ifdef FSYS_EXT2FS +#include "openbios/config.h" #include "shared.h" #include "filesys.h" #include +#ifdef CONFIG_DEBUG_EXT2FS +#define E2DEBUG +#endif + static int mapblock1, mapblock2; /* sizes are always in bytes, BLOCK values are always in DEV_BSIZE (sectors) */ diff --git a/fs/grubfs/grubfs_fs.c b/fs/grubfs/grubfs_fs.c index 28e5811..53ff3f0 100644 --- a/fs/grubfs/grubfs_fs.c +++ b/fs/grubfs/grubfs_fs.c @@ -303,7 +303,7 @@ file_read( void *buf, unsigned long len ) { if (filepos < 0 || filepos > filemax) filepos = filemax; - if (len < 0 || len > filemax-filepos) + if (len > filemax-filepos) len = filemax - filepos; errnum = 0; return curfs->fsys->read_func( buf, len ); diff --git a/fs/grubfs/iso9660.h b/fs/grubfs/iso9660.h index 06a7906..80f0afa 100644 --- a/fs/grubfs/iso9660.h +++ b/fs/grubfs/iso9660.h @@ -158,10 +158,13 @@ typedef union RR_ptr { #define RRMAGIC(c1, c2) ((c1)|(c2) << 8) -#define CHECK2(ptr, c1, c2) \ - (*(unsigned short *)(ptr) == (((c1) | (c2) << 8) & 0xFFFF)) -#define CHECK4(ptr, c1, c2, c3, c4) \ - (*(unsigned long *)(ptr) == ((c1) | (c2)<<8 | (c3)<<16 | (c4)<<24)) +#define CHECK2(ptr, c1, c2) \ + (*(ptr) == (c1) && *(ptr + 1) == (c2)) +#define CHECK4(ptr, c1, c2, c3, c4) \ + (*(unsigned char *)(ptr) == (c1) && \ + *((unsigned char *)(ptr) + 1) == (c2) && \ + *((unsigned char *)(ptr) + 2) == (c3) && \ + *((unsigned char *)(ptr) + 3) == (c4)) #endif /* !ASM_FILE */ diff --git a/libc/diskio.c b/libc/diskio.c index 0d499a0..f8aa29b 100644 --- a/libc/diskio.c +++ b/libc/diskio.c @@ -184,7 +184,7 @@ seek_io( int fd, llong offs ) DPUSH( offs ); call_package( fdp->seek_xt, fdp->ih ); - return ((POP() >= 0)? 0 : -1); + return ((((cell)POP()) >= 0)? 0 : -1); } llong