mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-10 13:04:53 -04:00
Cleanup verbose logging
This commit is contained in:
parent
fc87097bf0
commit
0d8189bde2
@ -23,6 +23,12 @@
|
|||||||
#include "disks.hpp"
|
#include "disks.hpp"
|
||||||
#include "block_cache.hpp"
|
#include "block_cache.hpp"
|
||||||
|
|
||||||
|
#ifdef THOR_CONFIG_ATA_VERBOSE
|
||||||
|
#define verbose_logf(...) logging::logf(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define verbose_logf(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
static constexpr const size_t BLOCK_SIZE = 512;
|
static constexpr const size_t BLOCK_SIZE = 512;
|
||||||
@ -388,7 +394,7 @@ ata::drive_descriptor& ata::drive(uint8_t disk){
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t ata::ata_driver::read(void* data, char* target, size_t count, size_t offset, size_t& read){
|
size_t ata::ata_driver::read(void* data, char* target, size_t count, size_t offset, size_t& read){
|
||||||
logging::logf(logging::log_level::TRACE, "ata: read(target=%p, count=%d, offset=%d)\n", target, count, offset);
|
verbose_logf(logging::log_level::TRACE, "ata: read(target=%p, count=%d, offset=%d)\n", target, count, offset);
|
||||||
|
|
||||||
if(count % BLOCK_SIZE != 0){
|
if(count % BLOCK_SIZE != 0){
|
||||||
return std::ERROR_INVALID_COUNT;
|
return std::ERROR_INVALID_COUNT;
|
||||||
@ -457,7 +463,7 @@ size_t ata::ata_driver::size(void* data){
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t ata::ata_part_driver::read(void* data, char* target, size_t count, size_t offset, size_t& read){
|
size_t ata::ata_part_driver::read(void* data, char* target, size_t count, size_t offset, size_t& read){
|
||||||
logging::logf(logging::log_level::TRACE, "ata_part: read(target=%p, count=%d, offset=%d)\n", target, count, offset);
|
verbose_logf(logging::log_level::TRACE, "ata_part: read(target=%p, count=%d, offset=%d)\n", target, count, offset);
|
||||||
|
|
||||||
if(count % BLOCK_SIZE != 0){
|
if(count % BLOCK_SIZE != 0){
|
||||||
return std::ERROR_INVALID_COUNT;
|
return std::ERROR_INVALID_COUNT;
|
||||||
|
@ -16,6 +16,12 @@
|
|||||||
#include "console.hpp"
|
#include "console.hpp"
|
||||||
#include "logging.hpp"
|
#include "logging.hpp"
|
||||||
|
|
||||||
|
#ifdef THOR_CONFIG_DEVFS_VERBOSE
|
||||||
|
#define verbose_logf(...) logging::logf(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define verbose_logf(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct device {
|
struct device {
|
||||||
@ -85,7 +91,7 @@ size_t devfs::devfs_file_system::get_file(const path& file_path, vfs::file& f){
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t devfs::devfs_file_system::read(const path& file_path, char* buffer, size_t count, size_t offset, size_t& read){
|
size_t devfs::devfs_file_system::read(const path& file_path, char* buffer, size_t count, size_t offset, size_t& read){
|
||||||
logging::logf(logging::log_level::TRACE, "devfs: read(buffer=%p, count=%d, offset=%d)\n", buffer, count, offset);
|
verbose_logf(logging::log_level::TRACE, "devfs: read(buffer=%p, count=%d, offset=%d)\n", buffer, count, offset);
|
||||||
|
|
||||||
//Cannot access the root for reading
|
//Cannot access the root for reading
|
||||||
if(file_path.is_root()){
|
if(file_path.is_root()){
|
||||||
|
@ -18,6 +18,12 @@
|
|||||||
#include "console.hpp"
|
#include "console.hpp"
|
||||||
#include "logging.hpp"
|
#include "logging.hpp"
|
||||||
|
|
||||||
|
#ifdef THOR_CONFIG_FAT32_VERBOSE
|
||||||
|
#define verbose_logf(...) logging::logf(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define verbose_logf(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr const uint32_t CLUSTER_FREE = 0x0;
|
constexpr const uint32_t CLUSTER_FREE = 0x0;
|
||||||
@ -224,12 +230,12 @@ size_t fat32::fat32_file_system::get_file(const path& file_path, vfs::file& file
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t fat32::fat32_file_system::read(const path& file_path, char* buffer, size_t count, size_t offset, size_t& read){
|
size_t fat32::fat32_file_system::read(const path& file_path, char* buffer, size_t count, size_t offset, size_t& read){
|
||||||
logging::logf(logging::log_level::TRACE, "fat32: Start read (buffer=%p,count=%d,offset=%d)\n", buffer, count, offset);
|
verbose_logf(logging::log_level::TRACE, "fat32: Start read (buffer=%p,count=%d,offset=%d)\n", buffer, count, offset);
|
||||||
|
|
||||||
vfs::file file;
|
vfs::file file;
|
||||||
auto result = get_file(file_path, file);
|
auto result = get_file(file_path, file);
|
||||||
if(result > 0){
|
if(result > 0){
|
||||||
logging::logf(logging::log_level::TRACE, "fat32: invalid file\n");
|
verbose_logf(logging::log_level::TRACE, "fat32: invalid file\n");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,13 +244,13 @@ size_t fat32::fat32_file_system::read(const path& file_path, char* buffer, size_
|
|||||||
|
|
||||||
//Check the offset parameter
|
//Check the offset parameter
|
||||||
if(offset > file_size){
|
if(offset > file_size){
|
||||||
logging::logf(logging::log_level::TRACE, "fat32: invalid offset\n");
|
verbose_logf(logging::log_level::TRACE, "fat32: invalid offset\n");
|
||||||
return std::ERROR_INVALID_OFFSET;
|
return std::ERROR_INVALID_OFFSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
//No need to read the cluster if there are no content
|
//No need to read the cluster if there are no content
|
||||||
if(file_size == 0 || count == 0){
|
if(file_size == 0 || count == 0){
|
||||||
logging::logf(logging::log_level::TRACE, "fat32: nothing to read\n");
|
verbose_logf(logging::log_level::TRACE, "fat32: nothing to read\n");
|
||||||
read = 0;
|
read = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -265,7 +271,8 @@ size_t fat32::fat32_file_system::read(const path& file_path, char* buffer, size_
|
|||||||
auto cluster_last = (cluster + 1) * cluster_size;
|
auto cluster_last = (cluster + 1) * cluster_size;
|
||||||
|
|
||||||
if(first < cluster_last){
|
if(first < cluster_last){
|
||||||
logging::logf(logging::log_level::TRACE, "fat32: read_sectors\n");
|
verbose_logf(logging::log_level::TRACE, "fat32: read_sectors\n");
|
||||||
|
|
||||||
if(read_sectors(cluster_lba(cluster_number), fat_bs->sectors_per_cluster, cluster_buffer.get())){
|
if(read_sectors(cluster_lba(cluster_number), fat_bs->sectors_per_cluster, cluster_buffer.get())){
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
||||||
@ -277,7 +284,8 @@ size_t fat32::fat32_file_system::read(const path& file_path, char* buffer, size_
|
|||||||
buffer[position++] = cluster_buffer[i];
|
buffer[position++] = cluster_buffer[i];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logging::logf(logging::log_level::TRACE, "fat32: read failed\n");
|
verbose_logf(logging::log_level::TRACE, "fat32: read failed\n");
|
||||||
|
|
||||||
return std::ERROR_FAILED;
|
return std::ERROR_FAILED;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -304,7 +312,7 @@ size_t fat32::fat32_file_system::read(const path& file_path, char* buffer, size_
|
|||||||
|
|
||||||
read = last - first;
|
read = last - first;
|
||||||
|
|
||||||
logging::logf(logging::log_level::TRACE, "fat32: finished read\n");
|
verbose_logf(logging::log_level::TRACE, "fat32: finished read\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -631,10 +639,8 @@ size_t fat32::fat32_file_system::mkdir(const path& file_path){
|
|||||||
return std::ERROR_DISK_FULL;
|
return std::ERROR_DISK_FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef THOR_CONFIG_DEBUG_FAT32
|
verbose_logf(logging::log_level::TRACE, "fat32: mkdir: free_cluster:%u\n", size_t(cluster));
|
||||||
logging::logf(logging::log_level::TRACE, "fat32: mkdir: free_cluster:%u\n", size_t(cluster));
|
verbose_logf(logging::log_level::TRACE, "fat32: mkdir: parent_cluster:%u\n", size_t(parent_cluster));
|
||||||
logging::logf(logging::log_level::TRACE, "fat32: mkdir: parent_cluster:%u\n", size_t(parent_cluster));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::unique_heap_array<cluster_entry> directory_cluster(16 * fat_bs->sectors_per_cluster);
|
std::unique_heap_array<cluster_entry> directory_cluster(16 * fat_bs->sectors_per_cluster);
|
||||||
if(!read_sectors(cluster_lba(parent_cluster), fat_bs->sectors_per_cluster, directory_cluster.get())){
|
if(!read_sectors(cluster_lba(parent_cluster), fat_bs->sectors_per_cluster, directory_cluster.get())){
|
||||||
@ -687,10 +693,8 @@ size_t fat32::fat32_file_system::mkdir(const path& file_path){
|
|||||||
return std::ERROR_FAILED;
|
return std::ERROR_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef THOR_CONFIG_DEBUG_FAT32
|
verbose_logf(logging::log_level::TRACE, "fat32: mkdir: special entry . -> %u\n", size_t(new_directory_cluster[0].cluster_low));
|
||||||
logging::logf(logging::log_level::TRACE, "fat32: mkdir: special entry . -> %u\n", size_t(new_directory_cluster[0].cluster_low));
|
verbose_logf(logging::log_level::TRACE, "fat32: mkdir: special entry . -> %u\n", size_t(new_directory_cluster[1].cluster_low));
|
||||||
logging::logf(logging::log_level::TRACE, "fat32: mkdir: special entry . -> %u\n", size_t(new_directory_cluster[1].cluster_low));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user