Started on inode manager file.
This commit is contained in:
@@ -4,12 +4,14 @@ add_library(
|
|||||||
OxFS
|
OxFS
|
||||||
filestore.cpp
|
filestore.cpp
|
||||||
filesystem.cpp
|
filesystem.cpp
|
||||||
|
inodemgr.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
filestore.hpp
|
filestore.hpp
|
||||||
filesystem.hpp
|
filesystem.hpp
|
||||||
|
inodemgr.hpp
|
||||||
DESTINATION
|
DESTINATION
|
||||||
include/ox/fs
|
include/ox/fs
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ template<typename FileStore>
|
|||||||
uint8_t *FileSystem<FileStore>::format(uint8_t *buffer, typename FileStore::FsSize_t size) {
|
uint8_t *FileSystem<FileStore>::format(uint8_t *buffer, typename FileStore::FsSize_t size) {
|
||||||
buffer = FileStore::format(buffer, size);
|
buffer = FileStore::format(buffer, size);
|
||||||
char dirBuff[sizeof(Directory) + sizeof(Directory)];
|
char dirBuff[sizeof(Directory) + sizeof(Directory)];
|
||||||
Directory &dir = *((Directory*) dirBuff);
|
auto *dir = (Directory*) dirBuff;
|
||||||
DirectoryEntry entry;
|
DirectoryEntry entry;
|
||||||
entry.inode = INODE_ROOT_DIR;
|
entry.inode = INODE_ROOT_DIR;
|
||||||
entry.setName("/");
|
entry.setName("/");
|
||||||
@@ -102,7 +102,7 @@ uint8_t *FileSystem<FileStore>::format(uint8_t *buffer, typename FileStore::FsSi
|
|||||||
if (buffer) {
|
if (buffer) {
|
||||||
uint32_t err;
|
uint32_t err;
|
||||||
FileStore fs(buffer, buffer + size, &err);
|
FileStore fs(buffer, buffer + size, &err);
|
||||||
dir.files();
|
dir->files();
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,10 +9,11 @@
|
|||||||
#include <ox/fs/filestore.hpp>
|
#include <ox/fs/filestore.hpp>
|
||||||
|
|
||||||
using namespace ox::fs;
|
using namespace ox::fs;
|
||||||
|
using namespace ox::std;
|
||||||
|
|
||||||
template<typename FileStore>
|
template<typename FileStore>
|
||||||
int test() {
|
int test() {
|
||||||
const auto size = 65535;
|
const uint16_t size = ~0;
|
||||||
uint8_t volume[size];
|
uint8_t volume[size];
|
||||||
char out[6];
|
char out[6];
|
||||||
uint32_t err;
|
uint32_t err;
|
||||||
|
|||||||
@@ -6,12 +6,14 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
#include <ox/fs/filesystem.hpp>
|
#include <ox/fs/filesystem.hpp>
|
||||||
|
#include <ox/fs/inodemgr.hpp>
|
||||||
|
|
||||||
using namespace ox::fs;
|
using namespace ox::fs;
|
||||||
|
using namespace ox::std;
|
||||||
|
|
||||||
template<typename FileSystem>
|
template<typename FileSystem>
|
||||||
int test() {
|
int test() {
|
||||||
const auto size = 65535;
|
const uint16_t size = ~0;
|
||||||
uint8_t volume[size];
|
uint8_t volume[size];
|
||||||
FileSystem::format(volume, size);
|
FileSystem::format(volume, size);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user