Fix up the majority of the non-grubfs filesystems from my last commit, since they require a "probe with offset" function to

allow the partition handler to identify a valid FS before interposition to /packages/misc-files.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>


git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@792 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Mark Cave-Ayland
2010-06-09 22:30:32 +00:00
committed by Mark Cave-Ayland
parent 7fc4e304c3
commit 372ad163dc
15 changed files with 123 additions and 7 deletions

View File

@@ -201,3 +201,11 @@ int fs_ext2_open(int fd, fs_ops_t *fs)
return 0;
}
int fs_ext2_probe(int fd, llong offs)
{
if (ext2_probe(fd, offs))
return -1;
return 0;
}

View File

@@ -12,6 +12,23 @@
#include "libc/diskio.h"
#include "libc/byteorder.h"
int ext2_probe(int fd, llong offset)
{
struct ext2_super_block *super;
super = (struct ext2_super_block*)malloc(sizeof(struct ext2_super_block));
seek_io(fd, 2 * 512 + offset);
read_io(fd, super, sizeof (*super));
if (__be16_to_cpu(super->s_magic) != EXT2_SUPER_MAGIC) {
free(super);
return 0;
}
free(super);
return -1;
}
void ext2_get_super(int fd, struct ext2_super_block *super)
{
seek_io(fd, 2 * 512);

View File

@@ -36,6 +36,7 @@
/* utilities */
extern int ext2_probe(int fd, llong offset);
extern void ext2_get_super(int fd, struct ext2_super_block *super);
extern void ext2_read_block(ext2_VOLUME* volume, unsigned int fsblock);
extern void ext2_get_group_desc(ext2_VOLUME* volume,

View File

@@ -736,3 +736,12 @@ int hfs_fstat(hfsfile *file, hfsdirent *ent)
return 0;
}
/*
* NAME: hfs->probe()
* DESCRIPTION: return whether a HFS filesystem is present at the given offset
*/
int hfs_probe(int fd, llong offset)
{
return v_probe(fd, offset);
}

View File

@@ -458,3 +458,12 @@ fs_hfs_open( int os_fd, fs_ops_t *fs )
return 0;
}
int
fs_hfs_probe( int fd, llong offs )
{
if (hfs_probe(fd, offs))
return -1;
return 0;
}

View File

@@ -177,3 +177,4 @@ int hfs_nparts(const char *);
int hfs_format(const char *, int, int,
const char *, unsigned int, const unsigned long []);
int hfs_probe(int fd, llong offset);

View File

@@ -66,5 +66,6 @@ int v_mkdir(hfsvol *, unsigned long, const char *);
int v_scavenge(hfsvol *);
int v_probe(int fd, llong offset);
#endif /* _H_VOLUME */

View File

@@ -32,6 +32,8 @@
#include "record.h"
#include "os.h"
#include "libc/byteorder.h"
/*
* NAME: vol->init()
* DESCRIPTION: initialize volume structure
@@ -589,3 +591,22 @@ done:
fail:
return -1;
}
/* Determine whether the volume is a HFS volume */
int
v_probe(int fd, llong offset)
{
MDB *mdb;
mdb = (MDB*)malloc(2 * 512);
os_seek_offset( fd, 2 * 512 + offset );
os_read(fd, mdb, 2, 9);
if (__be16_to_cpu(mdb->drSigWord) != HFS_SIGWORD) {
free(mdb);
return 0;
}
free(mdb);
return -1;
}

View File

@@ -397,3 +397,12 @@ fs_hfsp_open( int os_fd, fs_ops_t *fs )
return 0;
}
int
fs_hfsp_probe(int fd, llong offs)
{
if (volume_probe(fd, offs))
return -1;
return 0;
}

View File

@@ -72,6 +72,8 @@ static inline btree* volume_get_extents_tree(volume* vol) {
return vol->extents;
}
/* Determine whether the volume is a HFS-plus volume */
int volume_probe(int fd, llong offset);
#ifdef DEBUG
/* Print raw fork information to stdout */

View File

@@ -35,6 +35,7 @@
#include "swab.h"
#include "hfstime.h"
/* Fill a given buffer with the given block in volume.
*/
int
@@ -288,3 +289,22 @@ volume_create_extents_tree(volume* vol)
fail:
vol->extents = NULL;
}
/* Determine whether the volume is a HFS-plus volume */
int
volume_probe(int fd, llong offset)
{
struct hfsp_vh *vol;
vol = (struct hfsp_vh*)malloc(2 * 1 << HFSP_BLOCKSZ_BITS);
os_seek_offset( fd, 2 * (1 << HFSP_BLOCKSZ_BITS) + offset );
os_read(fd, vol, 2, HFSP_BLOCKSZ_BITS);
if (__be16_to_cpu(vol->signature) != HFSP_VOLHEAD_SIG) {
free(vol);
return 0;
}
free(vol);
return -1;
}

View File

@@ -79,6 +79,12 @@ os_seek( int fd, ulong blknum, int blksize_bits )
return blknum;
}
void
os_seek_offset( int fd, llong offset )
{
seek_io(fd, offset);
}
int
os_same( int fd1, int fd2 )
{

View File

@@ -47,5 +47,11 @@ unsigned long os_read( int fd, void *buf, unsigned long len, int blksize_bits);
*/
unsigned long os_write( int fd, const void *buf, unsigned long len, int blksize_bits);
/*
* NAME: os->seek_offset()
* DESCRIPTION: set a descriptor's seek pointer (offset in bytes)
*/
void os_seek_offset( int fd, llong offset );
#endif /* _H_OS */