repofs kinda working

This commit is contained in:
2023-06-08 23:54:49 +02:00
parent f7a5c4af48
commit a70ca528e0
4 changed files with 21 additions and 10 deletions

View File

@@ -9,5 +9,5 @@ CommandMount::CommandMount() : Command("mount") {
}
void CommandMount::run(Context ctx) {
RepoFS::start(ctx.repo, "./hi");
RepoFS::start(ctx.repo, ctx.repo->getConfig().getStr("to"));
}

View File

@@ -38,7 +38,7 @@ static int rfsGetattr(const char *path, struct stat *stbuf) {
e = getf(path);
if (e->isFakeDir || e->file->fileType == File::Type::Directory) {
stbuf->st_mode = S_IFDIR | 0755;
stbuf->st_nlink = 1;
stbuf->st_nlink = 2;
} else if (e->file->fileType == File::Type::Normal) {
stbuf->st_mode = S_IFREG | 0444;
stbuf->st_nlink = 1;
@@ -137,9 +137,9 @@ void RepoFS::start(Repository *repo, std::string path) {
for (auto const &f: a.files) {
auto file = Serialize::deserialize<File>(repo->getObject(f));
auto path = std::filesystem::u8path(file.name);
DirEntry *entry = &(root.children[r.first]);
DirEntry *entry = &(root.children[std::to_string(a.id)]);
entry->isFakeDir = true;
entry->name = a.name;
entry->name = std::to_string(a.id);
for (auto const &subp: path) {
entry = &entry->children[subp];
}