kernel/disk_device_manager: Improve tracing code.
* Use the standard TRACE{|_ALWAYS|_ERROR} setup.
* Put DBG(OUT... code as TRACE.
Makes syslog output from this module significantly less verbose
in default builds.
This commit is contained in:
@@ -38,10 +38,15 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
// debugging
|
|
||||||
//#define DBG(x)
|
//#define TRACE_KDISK_DEVICE_MANAGER
|
||||||
#define DBG(x) x
|
#ifdef TRACE_KDISK_DEVICE_MANAGER
|
||||||
#define OUT dprintf
|
# define TRACE TRACE_ALWAYS
|
||||||
|
#else
|
||||||
|
# define TRACE(x...) do { } while (false)
|
||||||
|
#endif
|
||||||
|
#define TRACE_ALWAYS(x...) dprintf("disk_device_manager: " x)
|
||||||
|
#define TRACE_ERROR(x...) dprintf("disk_device_manager: error: " x)
|
||||||
|
|
||||||
|
|
||||||
// directories for partitioning and file system modules
|
// directories for partitioning and file system modules
|
||||||
@@ -262,7 +267,7 @@ KDiskDeviceManager::KDiskDeviceManager()
|
|||||||
if (fMediaChecker >= 0)
|
if (fMediaChecker >= 0)
|
||||||
resume_thread(fMediaChecker);
|
resume_thread(fMediaChecker);
|
||||||
|
|
||||||
DBG(OUT("number of disk systems: %" B_PRId32 "\n", CountDiskSystems()));
|
TRACE("number of disk systems: %" B_PRId32 "\n", CountDiskSystems());
|
||||||
// TODO: Watch the disk systems and the relevant directories.
|
// TODO: Watch the disk systems and the relevant directories.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,27 +291,27 @@ KDiskDeviceManager::~KDiskDeviceManager()
|
|||||||
|
|
||||||
// some sanity checks
|
// some sanity checks
|
||||||
if (fPartitions->Count() > 0) {
|
if (fPartitions->Count() > 0) {
|
||||||
DBG(OUT("WARNING: There are still %" B_PRId32 " unremoved partitions!\n",
|
TRACE_ALWAYS("WARNING: There are still %" B_PRId32 " unremoved partitions!\n",
|
||||||
fPartitions->Count()));
|
fPartitions->Count());
|
||||||
for (PartitionMap::Iterator it = fPartitions->Begin();
|
for (PartitionMap::Iterator it = fPartitions->Begin();
|
||||||
it != fPartitions->End(); ++it) {
|
it != fPartitions->End(); ++it) {
|
||||||
DBG(OUT(" partition: %" B_PRId32 "\n", it->Value()->ID()));
|
TRACE(" partition: %" B_PRId32 "\n", it->Value()->ID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fObsoletePartitions->Count() > 0) {
|
if (fObsoletePartitions->Count() > 0) {
|
||||||
DBG(OUT("WARNING: There are still %" B_PRId32 " obsolete partitions!\n",
|
TRACE_ALWAYS("WARNING: There are still %" B_PRId32 " obsolete partitions!\n",
|
||||||
fObsoletePartitions->Count()));
|
fObsoletePartitions->Count());
|
||||||
for (PartitionSet::Iterator it = fObsoletePartitions->Begin();
|
for (PartitionSet::Iterator it = fObsoletePartitions->Begin();
|
||||||
it != fObsoletePartitions->End(); ++it) {
|
it != fObsoletePartitions->End(); ++it) {
|
||||||
DBG(OUT(" partition: %" B_PRId32 "\n", (*it)->ID()));
|
TRACE(" partition: %" B_PRId32 "\n", (*it)->ID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// remove all disk systems
|
// remove all disk systems
|
||||||
for (int32 cookie = 0; KDiskSystem* diskSystem = NextDiskSystem(&cookie);) {
|
for (int32 cookie = 0; KDiskSystem* diskSystem = NextDiskSystem(&cookie);) {
|
||||||
fDiskSystems->Remove(diskSystem->ID());
|
fDiskSystems->Remove(diskSystem->ID());
|
||||||
if (diskSystem->IsLoaded()) {
|
if (diskSystem->IsLoaded()) {
|
||||||
DBG(OUT("WARNING: Disk system `%s' (%" B_PRId32 ") is still loaded!\n",
|
TRACE_ALWAYS("WARNING: Disk system `%s' (%" B_PRId32 ") is still loaded!\n",
|
||||||
diskSystem->Name(), diskSystem->ID()));
|
diskSystem->Name(), diskSystem->ID());
|
||||||
} else
|
} else
|
||||||
delete diskSystem;
|
delete diskSystem;
|
||||||
}
|
}
|
||||||
@@ -1059,10 +1064,10 @@ KDiskDeviceManager::_RescanDiskSystems(DiskSystemMap& addedSystems,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (fileSystems) {
|
if (fileSystems) {
|
||||||
DBG(OUT("file system: %s\n", name.Path()));
|
TRACE("file system: %s\n", name.Path());
|
||||||
_AddFileSystem(name.Path());
|
_AddFileSystem(name.Path());
|
||||||
} else {
|
} else {
|
||||||
DBG(OUT("partitioning system: %s\n", name.Path()));
|
TRACE("partitioning system: %s\n", name.Path());
|
||||||
_AddPartitioningSystem(name.Path());
|
_AddPartitioningSystem(name.Path());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1145,16 +1150,16 @@ KDiskDeviceManager::_AddDiskSystem(KDiskSystem* diskSystem)
|
|||||||
{
|
{
|
||||||
if (!diskSystem)
|
if (!diskSystem)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
DBG(OUT("KDiskDeviceManager::_AddDiskSystem(%s)\n", diskSystem->Name()));
|
TRACE("KDiskDeviceManager::_AddDiskSystem(%s)\n", diskSystem->Name());
|
||||||
status_t error = diskSystem->Init();
|
status_t error = diskSystem->Init();
|
||||||
DBG(if (error != B_OK)
|
if (error != B_OK) {
|
||||||
OUT(" initialization failed: %s\n", strerror(error)));
|
TRACE(" initialization failed: %s\n", strerror(error));
|
||||||
|
}
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
error = fDiskSystems->Put(diskSystem->ID(), diskSystem);
|
error = fDiskSystems->Put(diskSystem->ID(), diskSystem);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
delete diskSystem;
|
delete diskSystem;
|
||||||
DBG(OUT("KDiskDeviceManager::_AddDiskSystem() done: %s\n",
|
TRACE("KDiskDeviceManager::_AddDiskSystem() done: %s\n", strerror(error));
|
||||||
strerror(error)));
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1252,7 +1257,7 @@ KDiskDeviceManager::_UpdateBusyPartitions(KDiskDevice *device)
|
|||||||
status_t
|
status_t
|
||||||
KDiskDeviceManager::_Scan(const char* path)
|
KDiskDeviceManager::_Scan(const char* path)
|
||||||
{
|
{
|
||||||
DBG(OUT("KDiskDeviceManager::_Scan(%s)\n", path));
|
TRACE("KDiskDeviceManager::_Scan(%s)\n", path);
|
||||||
status_t error = B_ENTRY_NOT_FOUND;
|
status_t error = B_ENTRY_NOT_FOUND;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (lstat(path, &st) < 0) {
|
if (lstat(path, &st) < 0) {
|
||||||
@@ -1288,7 +1293,7 @@ KDiskDeviceManager::_Scan(const char* path)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG(OUT(" found device: %s\n", path));
|
TRACE(" found device: %s\n", path);
|
||||||
// create a KDiskDevice for it
|
// create a KDiskDevice for it
|
||||||
KDiskDevice* device = new(nothrow) KDiskDevice;
|
KDiskDevice* device = new(nothrow) KDiskDevice;
|
||||||
if (!device)
|
if (!device)
|
||||||
@@ -1381,14 +1386,12 @@ KDiskDeviceManager::_ScanPartition(KPartition* partition,
|
|||||||
// Just ignore the partition...
|
// Just ignore the partition...
|
||||||
if (partition->Offset() < 0 || partition->BlockSize() == 0
|
if (partition->Offset() < 0 || partition->BlockSize() == 0
|
||||||
|| partition->Size() <= 0) {
|
|| partition->Size() <= 0) {
|
||||||
OUT("Partition %s has invalid parameters, ignoring it.\n",
|
TRACE_ALWAYS("Partition %s has invalid parameters, ignoring it.\n",
|
||||||
partitionPath.Path());
|
partitionPath.Path());
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG(
|
TRACE("KDiskDeviceManager::_ScanPartition(%s)\n", partitionPath.Path());
|
||||||
OUT("KDiskDeviceManager::_ScanPartition(%s)\n", partitionPath.Path());
|
|
||||||
)
|
|
||||||
|
|
||||||
// publish the partition
|
// publish the partition
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
@@ -1412,12 +1415,12 @@ KDiskDeviceManager::_ScanPartition(KPartition* partition,
|
|||||||
if (diskSystem->Load() != B_OK)
|
if (diskSystem->Load() != B_OK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DBG(OUT(" trying: %s\n", diskSystem->Name()));
|
TRACE(" trying: %s\n", diskSystem->Name());
|
||||||
|
|
||||||
void* cookie = NULL;
|
void* cookie = NULL;
|
||||||
float priority = diskSystem->Identify(partition, &cookie);
|
float priority = diskSystem->Identify(partition, &cookie);
|
||||||
|
|
||||||
DBG(OUT(" returned: %g\n", priority));
|
TRACE(" returned: %g\n", priority);
|
||||||
|
|
||||||
if (priority >= 0 && priority > bestPriority) {
|
if (priority >= 0 && priority > bestPriority) {
|
||||||
// new best disk system
|
// new best disk system
|
||||||
@@ -1439,7 +1442,7 @@ KDiskDeviceManager::_ScanPartition(KPartition* partition,
|
|||||||
|
|
||||||
// now, if we have found a disk system, let it scan the partition
|
// now, if we have found a disk system, let it scan the partition
|
||||||
if (bestDiskSystem != NULL) {
|
if (bestDiskSystem != NULL) {
|
||||||
DBG(OUT(" scanning with: %s\n", bestDiskSystem->Name()));
|
TRACE(" scanning with: %s\n", bestDiskSystem->Name());
|
||||||
error = bestDiskSystem->Scan(partition, bestCookie);
|
error = bestDiskSystem->Scan(partition, bestCookie);
|
||||||
bestDiskSystem->FreeIdentifyCookie(partition, bestCookie);
|
bestDiskSystem->FreeIdentifyCookie(partition, bestCookie);
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
@@ -1448,7 +1451,7 @@ KDiskDeviceManager::_ScanPartition(KPartition* partition,
|
|||||||
_ScanPartition(child, restrictScan);
|
_ScanPartition(child, restrictScan);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Handle the error.
|
// TODO: Handle the error.
|
||||||
DBG(OUT(" scanning failed: %s\n", strerror(error)));
|
TRACE_ERROR("scanning failed: %s\n", strerror(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
// now we can safely unload the disk system -- it has been loaded by
|
// now we can safely unload the disk system -- it has been loaded by
|
||||||
|
|||||||
Reference in New Issue
Block a user