mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk> git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@691 f158a5a8-5612-0410-a976-696ce0be7e32
51 lines
1.0 KiB
C
51 lines
1.0 KiB
C
/*
|
|
*
|
|
* (c) 2005-2009 Laurent Vivier <Laurent@vivier.eu>
|
|
*
|
|
* This file has been copied from EMILE, http://emile.sf.net
|
|
*
|
|
*/
|
|
|
|
#include "libiso9660.h"
|
|
#include "libopenbios/bindings.h"
|
|
#include "libc/diskio.h"
|
|
|
|
#define offsetof(t,m) ((long)&(((t *)0)->m))
|
|
|
|
static void read_extent(iso9660_DIR *dir)
|
|
{
|
|
seek_io(dir->volume->fd, dir->extent * ISOFS_BLOCK_SIZE);
|
|
read_io(dir->volume->fd, dir->buffer, ISOFS_BLOCK_SIZE);
|
|
|
|
dir->len -= ISOFS_BLOCK_SIZE;
|
|
dir->extent ++;
|
|
dir->index = 0;
|
|
}
|
|
|
|
struct iso_directory_record *iso9660_readdir(iso9660_DIR *dir)
|
|
{
|
|
struct iso_directory_record *idr;
|
|
|
|
if (dir->index >
|
|
ISOFS_BLOCK_SIZE - offsetof(struct iso_directory_record, name[0]))
|
|
{
|
|
if (dir->len <= 0)
|
|
return NULL;
|
|
|
|
read_extent(dir);
|
|
}
|
|
|
|
idr = (struct iso_directory_record *) &dir->buffer[dir->index];
|
|
if (idr->length[0] == 0) {
|
|
if (dir->len <= 0)
|
|
return NULL;
|
|
|
|
read_extent(dir);
|
|
idr = (struct iso_directory_record *) &dir->buffer[dir->index];
|
|
}
|
|
|
|
dir->index += dir->buffer[dir->index];
|
|
|
|
return idr;
|
|
}
|