Put the current inode space usage back into the spaceNeeded method

This commit is contained in:
2017-04-10 23:17:39 -05:00
parent 02b25ef882
commit 8eb73298f5
2 changed files with 6 additions and 8 deletions
+1 -6
View File
@@ -571,12 +571,7 @@ typename FileStore<Header>::StatInfo FileStore<Header>::stat(InodeId_t id) {
template<typename Header> template<typename Header>
typename Header::FsSize_t FileStore<Header>::spaceNeeded(InodeId_t id, typename Header::FsSize_t size) { typename Header::FsSize_t FileStore<Header>::spaceNeeded(InodeId_t id, typename Header::FsSize_t size) {
typename Header::FsSize_t needed = sizeof(Inode) + size;; return sizeof(Inode) + size;
auto inode = getInode(ptr<Inode*>(m_header.getRootInode()), id);
if (inode) {
needed -= inode->size();
}
return needed;
} }
template<typename Header> template<typename Header>
+5 -2
View File
@@ -30,8 +30,7 @@ const static auto usage = "usage:\n"
"\toxfs compact <FS file>\n" "\toxfs compact <FS file>\n"
"\toxfs version\n"; "\toxfs version\n";
char *loadFileBuff(const char *path, ::size_t *sizeOut = nullptr) { char *loadFileBuff(FILE *file, ::size_t *sizeOut = nullptr) {
auto file = fopen(path, "rb");
if (file) { if (file) {
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
const auto size = ftell(file); const auto size = ftell(file);
@@ -48,6 +47,10 @@ char *loadFileBuff(const char *path, ::size_t *sizeOut = nullptr) {
} }
} }
char *loadFileBuff(const char *path, ::size_t *sizeOut = nullptr) {
return loadFileBuff(fopen(path, "rb"), sizeOut);
}
size_t bytes(const char *str) { size_t bytes(const char *str) {
auto size = ::ox_strlen(str); auto size = ::ox_strlen(str);
const auto lastChar = str[size-1]; const auto lastChar = str[size-1];