Prepare statfs

This commit is contained in:
Baptiste Wicht 2014-03-01 17:38:32 +01:00
parent a31ccf17c4
commit 75b00e3301
4 changed files with 28 additions and 5 deletions

View File

@ -109,6 +109,7 @@ public:
fat32_file_system(size_t disk, size_t partition); fat32_file_system(size_t disk, size_t partition);
~fat32_file_system(); ~fat32_file_system();
size_t statfs(statfs_info& file);
size_t read(const std::vector<std::string>& file_path, std::string& content); size_t read(const std::vector<std::string>& file_path, std::string& content);
size_t get_file(const std::vector<std::string>& file_path, vfs::file& file); size_t get_file(const std::vector<std::string>& file_path, vfs::file& file);
size_t ls(const std::vector<std::string>& file_path, std::vector<vfs::file>& contents); size_t ls(const std::vector<std::string>& file_path, std::vector<vfs::file>& contents);
@ -135,8 +136,6 @@ private:
uint32_t find_free_cluster(); uint32_t find_free_cluster();
}; };
uint64_t free_size(dd disk, const disks::partition_descriptor& partition);
} }
#endif #endif

View File

@ -8,6 +8,10 @@
#ifndef VFS_FILE_SYSTEM_H #ifndef VFS_FILE_SYSTEM_H
#define VFS_FILE_SYSTEM_H #define VFS_FILE_SYSTEM_H
#include <statfs_info.hpp>
#include <vector.hpp>
#include <string.hpp>
#include "file.hpp" #include "file.hpp"
namespace vfs { namespace vfs {
@ -15,6 +19,7 @@ namespace vfs {
struct file_system { struct file_system {
virtual ~file_system(){}; virtual ~file_system(){};
virtual size_t statfs(statfs_info& file) = 0;
virtual size_t read(const std::vector<std::string>& file_path, std::string& content) = 0; virtual size_t read(const std::vector<std::string>& file_path, std::string& content) = 0;
virtual size_t get_file(const std::vector<std::string>& file_path, vfs::file& file) = 0; virtual size_t get_file(const std::vector<std::string>& file_path, vfs::file& file) = 0;
virtual size_t ls(const std::vector<std::string>& file_path, std::vector<vfs::file>& contents) = 0; virtual size_t ls(const std::vector<std::string>& file_path, std::vector<vfs::file>& contents) = 0;

View File

@ -403,10 +403,11 @@ size_t fat32::fat32_file_system::rm(const std::vector<std::string>& file_path){
} }
} }
//TODO This will be migrated to statfs size_t fat32::fat32_file_system::statfs(statfs_info& file){
uint64_t fat32::free_size(dd disk, const disks::partition_descriptor& partition){ file.total_size = fat_bs->total_sectors_long * 512;
file.free_size = fat_is->free_clusters * fat_bs->sectors_per_cluster * 512;
return 0; return 0;
//TODO return fat_is->free_clusters * fat_bs->sectors_per_cluster * 512;
} }
/* Private methods implementation */ /* Private methods implementation */

View File

@ -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 <types.hpp>
struct statfs_info {
size_t total_size;
size_t free_size;
};
#endif