From 218511c98aeb9285f7c75e5492983c2f8c77ee06 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 2 Jul 2017 00:42:48 -0500 Subject: [PATCH 1/2] Fix mkdir not to overwrite an existing dir --- src/ox/fs/filesystem.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ox/fs/filesystem.hpp b/src/ox/fs/filesystem.hpp index 0854456e2..dcaf41a43 100644 --- a/src/ox/fs/filesystem.hpp +++ b/src/ox/fs/filesystem.hpp @@ -368,8 +368,12 @@ int FileSystemTemplate::stripDirectories() { template int FileSystemTemplate::mkdir(const char *path) { - Directory dir; - return write(path, &dir, sizeof(dir), FileType::FileType_Directory); + if (!stat(path).inode) { + Directory dir; + return write(path, &dir, sizeof(dir), FileType::FileType_Directory); + } else { + return 1; + } } template From 31af2167d6d0d4e1343afe2e7fa2e129f02e8ce8 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 28 Jul 2017 01:44:18 -0500 Subject: [PATCH 2/2] Add operator< for DirectoryListing --- src/ox/fs/filesystem.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ox/fs/filesystem.hpp b/src/ox/fs/filesystem.hpp index dcaf41a43..48efcc155 100644 --- a/src/ox/fs/filesystem.hpp +++ b/src/ox/fs/filesystem.hpp @@ -42,6 +42,11 @@ struct DirectoryListing { } }; +template +bool operator<(const DirectoryListing &a, const DirectoryListing &b) { + return a.name < b.name; +} + template struct __attribute__((packed)) DirectoryEntry { InodeId_t inode;