Improve handling of root directory

This commit is contained in:
Baptiste Wicht 2014-02-27 22:47:00 +01:00
parent d2f8a3e8ba
commit 387777438b
2 changed files with 12 additions and 10 deletions

View File

@ -851,11 +851,7 @@ void scheduler::release_handle(size_t fd){
}
bool scheduler::has_handle(size_t fd){
if(fd < pcb[current_pid].handles.size()){
return !pcb[current_pid].handles[fd].empty();
}
return false;
return fd < pcb[current_pid].handles.size();
}
const std::vector<std::string>& scheduler::get_handle(size_t fd){

View File

@ -53,6 +53,11 @@ int64_t vfs::open(const char* file_path, size_t flags){
auto path = get_path(file_path);
//Special handling for opening the root
if(path.empty()){
return scheduler::register_new_handle(path);
}
auto last = path.back();
path.pop_back();
@ -157,8 +162,13 @@ int64_t vfs::stat(size_t fd, stat_info& info){
auto path = scheduler::get_handle(fd);
//Special handling for root
if(path.empty()){
return -std::ERROR_INVALID_FILE_PATH;
//TODO Add file system support for stat of the root directory
info.size = 4096;
info.flags = STAT_FLAG_DIRECTORY;
return 0;
}
auto last = path.back();
@ -241,10 +251,6 @@ int64_t vfs::entries(size_t fd, char* buffer, size_t size){
auto path = scheduler::get_handle(fd);
if(path.empty()){
return -std::ERROR_INVALID_FILE_PATH;
}
//TODO file search should be done entirely by the file system
auto files = fat32::ls(*disks::mounted_disk(), *disks::mounted_partition(), path);