mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
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:
committed by
Mark Cave-Ayland
parent
7fc4e304c3
commit
372ad163dc
@@ -201,3 +201,11 @@ int fs_ext2_open(int fd, fs_ops_t *fs)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fs_ext2_probe(int fd, llong offs)
|
||||||
|
{
|
||||||
|
if (ext2_probe(fd, offs))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,6 +12,23 @@
|
|||||||
#include "libc/diskio.h"
|
#include "libc/diskio.h"
|
||||||
#include "libc/byteorder.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)
|
void ext2_get_super(int fd, struct ext2_super_block *super)
|
||||||
{
|
{
|
||||||
seek_io(fd, 2 * 512);
|
seek_io(fd, 2 * 512);
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
/* utilities */
|
/* utilities */
|
||||||
|
|
||||||
|
extern int ext2_probe(int fd, llong offset);
|
||||||
extern void ext2_get_super(int fd, struct ext2_super_block *super);
|
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_read_block(ext2_VOLUME* volume, unsigned int fsblock);
|
||||||
extern void ext2_get_group_desc(ext2_VOLUME* volume,
|
extern void ext2_get_group_desc(ext2_VOLUME* volume,
|
||||||
|
|||||||
@@ -736,3 +736,12 @@ int hfs_fstat(hfsfile *file, hfsdirent *ent)
|
|||||||
|
|
||||||
return 0;
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -458,3 +458,12 @@ fs_hfs_open( int os_fd, fs_ops_t *fs )
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
fs_hfs_probe( int fd, llong offs )
|
||||||
|
{
|
||||||
|
if (hfs_probe(fd, offs))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -177,3 +177,4 @@ int hfs_nparts(const char *);
|
|||||||
|
|
||||||
int hfs_format(const char *, int, int,
|
int hfs_format(const char *, int, int,
|
||||||
const char *, unsigned int, const unsigned long []);
|
const char *, unsigned int, const unsigned long []);
|
||||||
|
int hfs_probe(int fd, llong offset);
|
||||||
|
|||||||
@@ -66,5 +66,6 @@ int v_mkdir(hfsvol *, unsigned long, const char *);
|
|||||||
|
|
||||||
int v_scavenge(hfsvol *);
|
int v_scavenge(hfsvol *);
|
||||||
|
|
||||||
|
int v_probe(int fd, llong offset);
|
||||||
|
|
||||||
#endif /* _H_VOLUME */
|
#endif /* _H_VOLUME */
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
#include "record.h"
|
#include "record.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
|
#include "libc/byteorder.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NAME: vol->init()
|
* NAME: vol->init()
|
||||||
* DESCRIPTION: initialize volume structure
|
* DESCRIPTION: initialize volume structure
|
||||||
@@ -589,3 +591,22 @@ done:
|
|||||||
fail:
|
fail:
|
||||||
return -1;
|
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;
|
||||||
|
}
|
||||||
@@ -397,3 +397,12 @@ fs_hfsp_open( int os_fd, fs_ops_t *fs )
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
fs_hfsp_probe(int fd, llong offs)
|
||||||
|
{
|
||||||
|
if (volume_probe(fd, offs))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -72,6 +72,8 @@ static inline btree* volume_get_extents_tree(volume* vol) {
|
|||||||
return vol->extents;
|
return vol->extents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Determine whether the volume is a HFS-plus volume */
|
||||||
|
int volume_probe(int fd, llong offset);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/* Print raw fork information to stdout */
|
/* Print raw fork information to stdout */
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "swab.h"
|
#include "swab.h"
|
||||||
#include "hfstime.h"
|
#include "hfstime.h"
|
||||||
|
|
||||||
|
|
||||||
/* Fill a given buffer with the given block in volume.
|
/* Fill a given buffer with the given block in volume.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@@ -288,3 +289,22 @@ volume_create_extents_tree(volume* vol)
|
|||||||
fail:
|
fail:
|
||||||
vol->extents = NULL;
|
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;
|
||||||
|
}
|
||||||
@@ -79,6 +79,12 @@ os_seek( int fd, ulong blknum, int blksize_bits )
|
|||||||
return blknum;
|
return blknum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
os_seek_offset( int fd, llong offset )
|
||||||
|
{
|
||||||
|
seek_io(fd, offset);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_same( int fd1, int fd2 )
|
os_same( int fd1, int fd2 )
|
||||||
{
|
{
|
||||||
|
|||||||
6
fs/os.h
6
fs/os.h
@@ -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);
|
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 */
|
#endif /* _H_OS */
|
||||||
|
|||||||
@@ -53,14 +53,18 @@ const char *fs_get_name( fs_ops_t *fs );
|
|||||||
|
|
||||||
#ifdef CONFIG_HFSP
|
#ifdef CONFIG_HFSP
|
||||||
extern int fs_hfsp_open( int fd, fs_ops_t *fs );
|
extern int fs_hfsp_open( int fd, fs_ops_t *fs );
|
||||||
|
extern int fs_hfsp_probe( int fd, llong offs );
|
||||||
#else
|
#else
|
||||||
static inline int fs_hfsp_open( int fd, fs_ops_t *fs ) { return -1; }
|
static inline int fs_hfsp_open( int fd, fs_ops_t *fs ) { return -1; }
|
||||||
|
static inline int fs_hfsp_probe( int fd, llong offs ) { return -1; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_HFS
|
#ifdef CONFIG_HFS
|
||||||
extern int fs_hfs_open( int fd, fs_ops_t *fs );
|
extern int fs_hfs_open( int fd, fs_ops_t *fs );
|
||||||
|
extern int fs_hfs_probe( int fd, llong offs );
|
||||||
#else
|
#else
|
||||||
static inline int fs_hfs_open( int fd, fs_ops_t *fs ) { return -1; }
|
static inline int fs_hfs_open( int fd, fs_ops_t *fs ) { return -1; }
|
||||||
|
static inline int fs_hfs_probe( int fd, llong offs ) { return -1; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_ISO9660
|
#ifdef CONFIG_ISO9660
|
||||||
@@ -71,8 +75,10 @@ static inline int fs_iso9660_open( int fd, fs_ops_t *fs ) { return -1; }
|
|||||||
|
|
||||||
#ifdef CONFIG_EXT2
|
#ifdef CONFIG_EXT2
|
||||||
extern int fs_ext2_open( int fd, fs_ops_t *fs );
|
extern int fs_ext2_open( int fd, fs_ops_t *fs );
|
||||||
|
extern int fs_ext2_probe( int fd, llong offs );
|
||||||
#else
|
#else
|
||||||
static inline int fs_ext2_open( int fd, fs_ops_t *fs ) { return -1; }
|
static inline int fs_ext2_open( int fd, fs_ops_t *fs ) { return -1; }
|
||||||
|
static inline int fs_ext2_probe( int fd, llong offs ) { return -1; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_GRUBFS
|
#ifdef CONFIG_GRUBFS
|
||||||
@@ -80,6 +86,7 @@ extern int fs_grubfs_open( int fd, fs_ops_t *fs );
|
|||||||
extern int fs_grubfs_probe( int fd, llong offs );
|
extern int fs_grubfs_probe( int fd, llong offs );
|
||||||
#else
|
#else
|
||||||
static inline int fs_grubfs_open( int fd, fs_ops_t *fs ) { return -1; }
|
static inline int fs_grubfs_open( int fd, fs_ops_t *fs ) { return -1; }
|
||||||
|
static inline int fs_grubfs_probe( int fd, llong offs ) { return -1; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -351,25 +351,24 @@ files_probe( files_info_t *mi )
|
|||||||
|
|
||||||
err = (fd = open_ih(ih)) == -1;
|
err = (fd = open_ih(ih)) == -1;
|
||||||
if( !err ) {
|
if( !err ) {
|
||||||
/*
|
|
||||||
err = fs_hfsp_open(fd, fs);
|
err = fs_hfsp_probe(fd, offs);
|
||||||
DPRINTF("--- HFSP returned %d\n", err);
|
DPRINTF("--- HFSP returned %d\n", err);
|
||||||
|
|
||||||
if( err ) {
|
if( err ) {
|
||||||
err = fs_hfs_open(fd, fs);
|
err = fs_hfs_probe(fd, offs);
|
||||||
DPRINTF("--- HFS returned %d\n", err);
|
DPRINTF("--- HFS returned %d\n", err);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if( err ) {
|
if( err ) {
|
||||||
err = fs_iso9660_open(fd, fs);
|
err = fs_iso9660_open(fd, fs);
|
||||||
DPRINTF("--- ISO9660 returned %d\n", err);
|
DPRINTF("--- ISO9660 returned %d\n", err);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
if( err ) {
|
if( err ) {
|
||||||
err = fs_ext2_open(fd, fs);
|
err = fs_ext2_probe(fd, offs);
|
||||||
DPRINTF("--- ext2 returned %d\n", err);
|
DPRINTF("--- ext2 returned %d\n", err);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
if( err ) {
|
if( err ) {
|
||||||
err = fs_grubfs_probe(fd, offs);
|
err = fs_grubfs_probe(fd, offs);
|
||||||
|
|||||||
Reference in New Issue
Block a user