* The partition modules have a short_name field now instead of the
identify_module() hook. * get_nth_session_module() returns the name of the partition module. * There is no special handling for CDs anymore. The session modules are tried on any device now. * Fixed a bug in get_buffer() causing a crash when reading from disk failed. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2555 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -119,7 +119,7 @@ read_block(int fd, off_t offset, size_t size, uchar **block)
|
|||||||
if (read_pos(fd, offset, *block, size) != (ssize_t)size) {
|
if (read_pos(fd, offset, *block, size) != (ssize_t)size) {
|
||||||
error = errno;
|
error = errno;
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
error = B_ERROR;
|
error = B_IO_ERROR;
|
||||||
free(*block);
|
free(*block);
|
||||||
*block = NULL;
|
*block = NULL;
|
||||||
}
|
}
|
||||||
@@ -184,7 +184,7 @@ get_partition_module_for_identifier(const char *identifier,
|
|||||||
bufferSize = sizeof(moduleName)) {
|
bufferSize = sizeof(moduleName)) {
|
||||||
partition_module_info *module = NULL;
|
partition_module_info *module = NULL;
|
||||||
if (get_module(moduleName, (module_info**)&module) == B_OK) {
|
if (get_module(moduleName, (module_info**)&module) == B_OK) {
|
||||||
if (module->identify_module(identifier)) {
|
if (!strcmp(module->short_name, identifier)) {
|
||||||
// found module
|
// found module
|
||||||
*partitionModule = module;
|
*partitionModule = module;
|
||||||
break;
|
break;
|
||||||
@@ -237,7 +237,6 @@ disk_scanner_get_nth_session_info(int deviceFD, int32 index,
|
|||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
session_module_info *sessionModule
|
session_module_info *sessionModule
|
||||||
= (_sessionModule ? *_sessionModule : NULL);
|
= (_sessionModule ? *_sessionModule : NULL);
|
||||||
bool isCD = false;
|
|
||||||
int32 blockSize = 0;
|
int32 blockSize = 0;
|
||||||
off_t deviceSize = 0;
|
off_t deviceSize = 0;
|
||||||
device_geometry geometry;
|
device_geometry geometry;
|
||||||
@@ -248,43 +247,39 @@ disk_scanner_get_nth_session_info(int deviceFD, int32 index,
|
|||||||
TRACE(("disk_scanner: get_nth_session_info(%d, %ld)\n", deviceFD, index));
|
TRACE(("disk_scanner: get_nth_session_info(%d, %ld)\n", deviceFD, index));
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
if (ioctl(deviceFD, B_GET_GEOMETRY, &geometry) == 0) {
|
if (ioctl(deviceFD, B_GET_GEOMETRY, &geometry) == 0) {
|
||||||
isCD = (geometry.device_type == B_CD);
|
|
||||||
blockSize = geometry.bytes_per_sector;
|
blockSize = geometry.bytes_per_sector;
|
||||||
deviceSize = (off_t)blockSize * geometry.sectors_per_track
|
deviceSize = (off_t)blockSize * geometry.sectors_per_track
|
||||||
* geometry.cylinder_count * geometry.head_count;
|
* geometry.cylinder_count * geometry.head_count;
|
||||||
} else
|
} else
|
||||||
error = errno;
|
error = errno;
|
||||||
}
|
}
|
||||||
TRACE(("disk_scanner: check: %s\n", strerror(error)));
|
|
||||||
// get a session module, if the device is a CD, otherwise return a
|
// get a session module, if the device is a CD, otherwise return a
|
||||||
// virtual session
|
// virtual session
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
if (isCD) {
|
// get the session module
|
||||||
// get the session module
|
if (!sessionModule) {
|
||||||
if (!sessionModule) {
|
error = disk_scanner_get_session_module(deviceFD, deviceSize,
|
||||||
error = disk_scanner_get_session_module(deviceFD, deviceSize,
|
blockSize,
|
||||||
blockSize,
|
&sessionModule);
|
||||||
&sessionModule);
|
|
||||||
TRACE(("disk_scanner: check: %s\n", strerror(error)));
|
|
||||||
}
|
|
||||||
// get the info
|
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
error = sessionModule->get_nth_info(deviceFD, index,
|
error = sessionModule->get_nth_info(deviceFD, index,
|
||||||
deviceSize, blockSize,
|
deviceSize, blockSize,
|
||||||
sessionInfo);
|
sessionInfo);
|
||||||
TRACE(("disk_scanner: check: %s\n", strerror(error)));
|
} else if (error == B_ENTRY_NOT_FOUND) {
|
||||||
|
// no session add-on found -- return a virtual session for
|
||||||
|
// index 0
|
||||||
|
error = B_OK;
|
||||||
|
if (index == 0) {
|
||||||
|
sessionInfo->offset = 0;
|
||||||
|
sessionInfo->size = deviceSize;
|
||||||
|
sessionInfo->logical_block_size = blockSize;
|
||||||
|
sessionInfo->index = 0;
|
||||||
|
sessionInfo->flags = B_VIRTUAL_SESSION;
|
||||||
|
} else
|
||||||
|
error = B_ENTRY_NOT_FOUND;
|
||||||
}
|
}
|
||||||
} else if (index == 0) {
|
}
|
||||||
// no CD -- virtual session
|
|
||||||
sessionInfo->offset = 0;
|
|
||||||
sessionInfo->size = deviceSize;
|
|
||||||
sessionInfo->logical_block_size = blockSize;
|
|
||||||
sessionInfo->index = 0;
|
|
||||||
sessionInfo->flags = B_VIRTUAL_SESSION;
|
|
||||||
} else // no CD, fail after the first session
|
|
||||||
error = B_ENTRY_NOT_FOUND;
|
|
||||||
}
|
}
|
||||||
TRACE(("disk_scanner: check: %s\n", strerror(error)));
|
|
||||||
// cleanup / set results
|
// cleanup / set results
|
||||||
if (_sessionModule)
|
if (_sessionModule)
|
||||||
*_sessionModule = sessionModule;
|
*_sessionModule = sessionModule;
|
||||||
@@ -302,6 +297,7 @@ disk_scanner_get_nth_partition_info(int deviceFD,
|
|||||||
const session_info *sessionInfo,
|
const session_info *sessionInfo,
|
||||||
int32 partitionIndex,
|
int32 partitionIndex,
|
||||||
extended_partition_info *partitionInfo,
|
extended_partition_info *partitionInfo,
|
||||||
|
char *partitionMapName,
|
||||||
partition_module_info **_partitionModule)
|
partition_module_info **_partitionModule)
|
||||||
{
|
{
|
||||||
partition_module_info *partitionModule
|
partition_module_info *partitionModule
|
||||||
@@ -345,7 +341,14 @@ disk_scanner_get_nth_partition_info(int deviceFD,
|
|||||||
error = partitionModule->get_nth_info(deviceFD, sessionInfo,
|
error = partitionModule->get_nth_info(deviceFD, sessionInfo,
|
||||||
block, partitionIndex, partitionInfo);
|
block, partitionIndex, partitionInfo);
|
||||||
}
|
}
|
||||||
// cleanup / set results
|
// set results / cleanup
|
||||||
|
if (error == B_OK && partitionMapName) {
|
||||||
|
// return partition module identifier
|
||||||
|
if (partitionModule)
|
||||||
|
strcpy(partitionMapName, partitionModule->short_name);
|
||||||
|
else
|
||||||
|
partitionMapName[0] = '\0';
|
||||||
|
}
|
||||||
if (_partitionModule)
|
if (_partitionModule)
|
||||||
*_partitionModule = partitionModule;
|
*_partitionModule = partitionModule;
|
||||||
else if (partitionModule)
|
else if (partitionModule)
|
||||||
@@ -377,7 +380,7 @@ disk_scanner_get_partition_fs_info(int deviceFD,
|
|||||||
cacheInitialized = (error == B_OK);
|
cacheInitialized = (error == B_OK);
|
||||||
}
|
}
|
||||||
// Iterate through the list of FS modules and return the result of the
|
// Iterate through the list of FS modules and return the result of the
|
||||||
// first one that thinks, it is the right one.
|
// one with the highest priority that thinks, it is the right one.
|
||||||
if (error == B_OK && ((list = open_module_list(kFSModulePrefix)))) {
|
if (error == B_OK && ((list = open_module_list(kFSModulePrefix)))) {
|
||||||
extended_partition_info bestInfo;
|
extended_partition_info bestInfo;
|
||||||
float bestPriority = -2;
|
float bestPriority = -2;
|
||||||
@@ -562,7 +565,7 @@ get_buffer(struct fs_buffer_cache *cache, off_t offset, size_t size,
|
|||||||
size_t remainingBytes = size;
|
size_t remainingBytes = size;
|
||||||
fs_block *block = NULL;
|
fs_block *block = NULL;
|
||||||
for (block = cache->first_block;
|
for (block = cache->first_block;
|
||||||
error == B_OK && remainingBytes > 0;
|
remainingBytes > 0;
|
||||||
block = block->next) {
|
block = block->next) {
|
||||||
if (!block || block->offset >= blockOffset) {
|
if (!block || block->offset >= blockOffset) {
|
||||||
if (!block || block->offset > blockOffset) {
|
if (!block || block->offset > blockOffset) {
|
||||||
@@ -604,6 +607,9 @@ get_buffer(struct fs_buffer_cache *cache, off_t offset, size_t size,
|
|||||||
remainingBytes -= toCopy;
|
remainingBytes -= toCopy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// bail out on failure
|
||||||
|
if (error != B_OK)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
error = B_NO_MEMORY;
|
error = B_NO_MEMORY;
|
||||||
|
|||||||
Reference in New Issue
Block a user