Adjusted to retrieve disk blocks via the new callback.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2501 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
dafa158b38
commit
6e2c8a42b5
@ -23,9 +23,10 @@ const char *kModuleDebugName = "fs/bfs";
|
|||||||
//#define TRACE(x) dprintf x
|
//#define TRACE(x) dprintf x
|
||||||
|
|
||||||
// prototypes
|
// prototypes
|
||||||
static status_t read_block(int fd, off_t offset, size_t size, uchar **block);
|
//static status_t read_block(int fd, off_t offset, size_t size, uchar **block);
|
||||||
static bool bfs_fs_identify(int deviceFD,
|
static bool bfs_fs_identify(int deviceFD,
|
||||||
struct extended_partition_info *partitionInfo, float *priority);
|
struct extended_partition_info *partitionInfo, float *priority,
|
||||||
|
fs_get_buffer get_buffer, struct fs_buffer_cache *cache);
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Stolen from src/add-ons/kernel/file_systems/bfs/bfs.h
|
// Stolen from src/add-ons/kernel/file_systems/bfs/bfs.h
|
||||||
@ -147,21 +148,15 @@ std_ops(int32 op, ...)
|
|||||||
// read_block
|
// read_block
|
||||||
static
|
static
|
||||||
status_t
|
status_t
|
||||||
read_block(int fd, off_t offset, size_t size, uchar **block)
|
read_block(fs_get_buffer get_buffer, struct fs_buffer_cache *cache,
|
||||||
|
off_t offset, size_t size, uchar **block)
|
||||||
{
|
{
|
||||||
status_t error = (block && size > 0 ? B_OK : B_BAD_VALUE);
|
size_t actualSize = 0;
|
||||||
if (error == B_OK) {
|
status_t error = get_buffer(cache, offset, size, (void**)block,
|
||||||
*block = malloc(size);
|
&actualSize);
|
||||||
if (*block) {
|
if (error == B_OK && actualSize != size) {
|
||||||
if (read_pos(fd, offset, *block, size) != (ssize_t)size) {
|
error = B_ERROR;
|
||||||
error = errno;
|
free(*block);
|
||||||
if (error == B_OK)
|
|
||||||
error = B_ERROR;
|
|
||||||
free(*block);
|
|
||||||
*block = NULL;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
error = B_NO_MEMORY;
|
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@ -176,7 +171,8 @@ read_block(int fd, off_t offset, size_t size, uchar **block)
|
|||||||
static
|
static
|
||||||
bool
|
bool
|
||||||
bfs_fs_identify(int deviceFD, struct extended_partition_info *partitionInfo,
|
bfs_fs_identify(int deviceFD, struct extended_partition_info *partitionInfo,
|
||||||
float *priority)
|
float *priority, fs_get_buffer get_buffer,
|
||||||
|
struct fs_buffer_cache *cache)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
TRACE(("%s: identify(%d, %p, offset: %lld)\n", kModuleDebugName, deviceFD,
|
TRACE(("%s: identify(%d, %p, offset: %lld)\n", kModuleDebugName, deviceFD,
|
||||||
@ -185,8 +181,8 @@ bfs_fs_identify(int deviceFD, struct extended_partition_info *partitionInfo,
|
|||||||
if (partitionInfo) {
|
if (partitionInfo) {
|
||||||
uchar *buffer = NULL;
|
uchar *buffer = NULL;
|
||||||
disk_super_block *superBlock = NULL;
|
disk_super_block *superBlock = NULL;
|
||||||
status_t error = read_block(deviceFD, partitionInfo->info.offset,
|
status_t error = read_block(get_buffer, cache,
|
||||||
1024, &buffer);
|
partitionInfo->info.offset, 1024, &buffer);
|
||||||
if (!error && buffer) {
|
if (!error && buffer) {
|
||||||
superBlock = (disk_super_block*)(buffer+512);
|
superBlock = (disk_super_block*)(buffer+512);
|
||||||
// dump_super_block(superBlock);
|
// dump_super_block(superBlock);
|
||||||
|
@ -130,21 +130,15 @@ std_ops(int32 op, ...)
|
|||||||
// read_block
|
// read_block
|
||||||
static
|
static
|
||||||
status_t
|
status_t
|
||||||
read_block(int fd, off_t offset, size_t size, uchar **block)
|
read_block(fs_get_buffer get_buffer, struct fs_buffer_cache *cache,
|
||||||
|
off_t offset, size_t size, uchar **block)
|
||||||
{
|
{
|
||||||
status_t error = (block && size > 0 ? B_OK : B_BAD_VALUE);
|
size_t actualSize = 0;
|
||||||
if (error == B_OK) {
|
status_t error = get_buffer(cache, offset, size, (void**)block,
|
||||||
*block = malloc(size);
|
&actualSize);
|
||||||
if (*block) {
|
if (error == B_OK && actualSize != size) {
|
||||||
if (read_pos(fd, offset, *block, size) != (ssize_t)size) {
|
error = B_ERROR;
|
||||||
error = errno;
|
free(*block);
|
||||||
if (error == B_OK)
|
|
||||||
error = B_ERROR;
|
|
||||||
free(*block);
|
|
||||||
*block = NULL;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
error = B_NO_MEMORY;
|
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@ -159,7 +153,8 @@ read_block(int fd, off_t offset, size_t size, uchar **block)
|
|||||||
static
|
static
|
||||||
bool
|
bool
|
||||||
iso9660_fs_identify(int deviceFD, struct extended_partition_info *partitionInfo,
|
iso9660_fs_identify(int deviceFD, struct extended_partition_info *partitionInfo,
|
||||||
float *priority)
|
float *priority, fs_get_buffer get_buffer,
|
||||||
|
struct fs_buffer_cache *cache)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
uchar *buffer = NULL;
|
uchar *buffer = NULL;
|
||||||
@ -180,7 +175,7 @@ iso9660_fs_identify(int deviceFD, struct extended_partition_info *partitionInfo,
|
|||||||
iso9660_common_volume_descriptor *common = NULL;
|
iso9660_common_volume_descriptor *common = NULL;
|
||||||
|
|
||||||
// Read the block containing the current descriptor
|
// Read the block containing the current descriptor
|
||||||
error = read_block(deviceFD, offset, blockSize, &buffer);
|
error = read_block(get_buffer, cache, offset, blockSize, &buffer);
|
||||||
offset += blockSize;
|
offset += blockSize;
|
||||||
if (!error) {
|
if (!error) {
|
||||||
common = (iso9660_common_volume_descriptor*)buffer;
|
common = (iso9660_common_volume_descriptor*)buffer;
|
||||||
|
Loading…
Reference in New Issue
Block a user