diff --git a/kernel/include/fat32.hpp b/kernel/include/fat32.hpp index 6167970f..89dc57ad 100644 --- a/kernel/include/fat32.hpp +++ b/kernel/include/fat32.hpp @@ -109,6 +109,7 @@ public: fat32_file_system(size_t disk, size_t partition); ~fat32_file_system(); + size_t statfs(statfs_info& file); size_t read(const std::vector& file_path, std::string& content); size_t get_file(const std::vector& file_path, vfs::file& file); size_t ls(const std::vector& file_path, std::vector& contents); @@ -135,8 +136,6 @@ private: uint32_t find_free_cluster(); }; -uint64_t free_size(dd disk, const disks::partition_descriptor& partition); - } #endif diff --git a/kernel/include/file_system.hpp b/kernel/include/file_system.hpp index d913149d..590b8eff 100644 --- a/kernel/include/file_system.hpp +++ b/kernel/include/file_system.hpp @@ -8,6 +8,10 @@ #ifndef VFS_FILE_SYSTEM_H #define VFS_FILE_SYSTEM_H +#include +#include +#include + #include "file.hpp" namespace vfs { @@ -15,6 +19,7 @@ namespace vfs { struct file_system { virtual ~file_system(){}; + virtual size_t statfs(statfs_info& file) = 0; virtual size_t read(const std::vector& file_path, std::string& content) = 0; virtual size_t get_file(const std::vector& file_path, vfs::file& file) = 0; virtual size_t ls(const std::vector& file_path, std::vector& contents) = 0; diff --git a/kernel/src/fat32.cpp b/kernel/src/fat32.cpp index 9c106b6c..ff405120 100644 --- a/kernel/src/fat32.cpp +++ b/kernel/src/fat32.cpp @@ -403,10 +403,11 @@ size_t fat32::fat32_file_system::rm(const std::vector& file_path){ } } -//TODO This will be migrated to statfs -uint64_t fat32::free_size(dd disk, const disks::partition_descriptor& partition){ +size_t fat32::fat32_file_system::statfs(statfs_info& file){ + file.total_size = fat_bs->total_sectors_long * 512; + file.free_size = fat_is->free_clusters * fat_bs->sectors_per_cluster * 512; + return 0; - //TODO return fat_is->free_clusters * fat_bs->sectors_per_cluster * 512; } /* Private methods implementation */ diff --git a/tlib/include/statfs_info.hpp b/tlib/include/statfs_info.hpp new file mode 100644 index 00000000..dc80d229 --- /dev/null +++ b/tlib/include/statfs_info.hpp @@ -0,0 +1,18 @@ +//======================================================================= +// Copyright Baptiste Wicht 2013-2014. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +//======================================================================= + +#ifndef USER_STATFS_INFO_HPP +#define USER_STATFS_INFO_HPP + +#include + +struct statfs_info { + size_t total_size; + size_t free_size; +}; + +#endif