Started on inode manager file.

This commit is contained in:
2016-06-27 21:21:01 -05:00
parent c3b9a9e9e0
commit 77059d4cdb
6 changed files with 76 additions and 4 deletions
+2
View File
@@ -4,12 +4,14 @@ add_library(
OxFS
filestore.cpp
filesystem.cpp
inodemgr.cpp
)
install(
FILES
filestore.hpp
filesystem.hpp
inodemgr.hpp
DESTINATION
include/ox/fs
)
+2 -2
View File
@@ -94,7 +94,7 @@ template<typename FileStore>
uint8_t *FileSystem<FileStore>::format(uint8_t *buffer, typename FileStore::FsSize_t size) {
buffer = FileStore::format(buffer, size);
char dirBuff[sizeof(Directory) + sizeof(Directory)];
Directory &dir = *((Directory*) dirBuff);
auto *dir = (Directory*) dirBuff;
DirectoryEntry entry;
entry.inode = INODE_ROOT_DIR;
entry.setName("/");
@@ -102,7 +102,7 @@ uint8_t *FileSystem<FileStore>::format(uint8_t *buffer, typename FileStore::FsSi
if (buffer) {
uint32_t err;
FileStore fs(buffer, buffer + size, &err);
dir.files();
dir->files();
}
return buffer;
+14
View File
@@ -0,0 +1,14 @@
/*
* Copyright 2015 - 2016 gtalent2@gmail.com
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "inodemgr.hpp"
namespace ox {
namespace fs {
}
}
+53
View File
@@ -0,0 +1,53 @@
/*
* Copyright 2015 - 2016 gtalent2@gmail.com
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
namespace ox {
namespace fs {
/**
* Used to track unused inodes.
*/
template<typename InodeId_t>
struct InodeFile {
InodeId_t length;
InodeId_t *inodes();
};
template<typename InodeId_t>
InodeId_t *InodeFile<InodeId_t>::inodes() {
return (InodeId_t*) (this + 1);
}
template<typename InodeId_t>
int generateInodeFile(InodeId_t *inodes, int count) {
const static InodeId_t endPoint = ~0;
auto it = count;
auto multiplier = 1;
auto current = endPoint / 2;
auto lowestNode = current;
inodes[0] = count;
while (it > 0) {
current = lowestNode * multiplier;
if (current < endPoint) {
inodes[it--] = current;
multiplier += 2;
} else {
multiplier = 1;
lowestNode /= 2;
}
}
return 0;
}
}
}
+2 -1
View File
@@ -9,10 +9,11 @@
#include <ox/fs/filestore.hpp>
using namespace ox::fs;
using namespace ox::std;
template<typename FileStore>
int test() {
const auto size = 65535;
const uint16_t size = ~0;
uint8_t volume[size];
char out[6];
uint32_t err;
+3 -1
View File
@@ -6,12 +6,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <ox/fs/filesystem.hpp>
#include <ox/fs/inodemgr.hpp>
using namespace ox::fs;
using namespace ox::std;
template<typename FileSystem>
int test() {
const auto size = 65535;
const uint16_t size = ~0;
uint8_t volume[size];
FileSystem::format(volume, size);
return 0;