mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-08 20:10:04 -04:00
Add more logging
This commit is contained in:
parent
3021aed283
commit
fc87097bf0
@ -85,6 +85,8 @@ 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){
|
||||
logging::logf(logging::log_level::TRACE, "devfs: read(buffer=%p, count=%d, offset=%d)\n", buffer, count, offset);
|
||||
|
||||
//Cannot access the root for reading
|
||||
if(file_path.is_root()){
|
||||
return std::ERROR_PERMISSION_DENIED;
|
||||
|
@ -229,6 +229,7 @@ size_t fat32::fat32_file_system::read(const path& file_path, char* buffer, size_
|
||||
vfs::file file;
|
||||
auto result = get_file(file_path, file);
|
||||
if(result > 0){
|
||||
logging::logf(logging::log_level::TRACE, "fat32: invalid file\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -237,11 +238,13 @@ size_t fat32::fat32_file_system::read(const path& file_path, char* buffer, size_
|
||||
|
||||
//Check the offset parameter
|
||||
if(offset > file_size){
|
||||
logging::logf(logging::log_level::TRACE, "fat32: invalid offset\n");
|
||||
return std::ERROR_INVALID_OFFSET;
|
||||
}
|
||||
|
||||
//No need to read the cluster if there are no content
|
||||
if(file_size == 0 || count == 0){
|
||||
logging::logf(logging::log_level::TRACE, "fat32: nothing to read\n");
|
||||
read = 0;
|
||||
return 0;
|
||||
}
|
||||
@ -262,6 +265,7 @@ size_t fat32::fat32_file_system::read(const path& file_path, char* buffer, size_
|
||||
auto cluster_last = (cluster + 1) * cluster_size;
|
||||
|
||||
if(first < cluster_last){
|
||||
logging::logf(logging::log_level::TRACE, "fat32: read_sectors\n");
|
||||
if(read_sectors(cluster_lba(cluster_number), fat_bs->sectors_per_cluster, cluster_buffer.get())){
|
||||
size_t i = 0;
|
||||
|
||||
@ -273,6 +277,7 @@ size_t fat32::fat32_file_system::read(const path& file_path, char* buffer, size_
|
||||
buffer[position++] = cluster_buffer[i];
|
||||
}
|
||||
} else {
|
||||
logging::logf(logging::log_level::TRACE, "fat32: read failed\n");
|
||||
return std::ERROR_FAILED;
|
||||
}
|
||||
} else {
|
||||
@ -299,6 +304,8 @@ size_t fat32::fat32_file_system::read(const path& file_path, char* buffer, size_
|
||||
|
||||
read = last - first;
|
||||
|
||||
logging::logf(logging::log_level::TRACE, "fat32: finished read\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user