diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index 5c5fb3f3f0..279d84a451 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -2,7 +2,6 @@ #include "Task.h" #include "Syscall.h" #include "Console.h" -#include extern "C" void syscall_entry(); extern "C" void syscall_ISR(); @@ -100,7 +99,6 @@ DWORD handle(DWORD function, DWORD arg1, DWORD arg2, DWORD arg3) return current->sys$gethostname((char*)arg1, (size_t)arg2); case Syscall::PosixExit: cli(); - //locker.unlock(); current->sys$exit((int)arg1); ASSERT_NOT_REACHED(); return 0; diff --git a/VirtualFileSystem/Ext2FileSystem.cpp b/VirtualFileSystem/Ext2FileSystem.cpp index c8e03507ca..013d44604d 100644 --- a/VirtualFileSystem/Ext2FileSystem.cpp +++ b/VirtualFileSystem/Ext2FileSystem.cpp @@ -204,6 +204,7 @@ InodeMetadata Ext2FileSystem::inodeMetadata(InodeIdentifier inode) const metadata.majorDevice = (dev & 0xfff00) >> 8; metadata.minorDevice= (dev & 0xff) | ((dev >> 12) & 0xfff00); } + return metadata; } diff --git a/VirtualFileSystem/FileHandle.cpp b/VirtualFileSystem/FileHandle.cpp index 55b9f70cb7..ad1e1db336 100644 --- a/VirtualFileSystem/FileHandle.cpp +++ b/VirtualFileSystem/FileHandle.cpp @@ -25,8 +25,6 @@ bool additionWouldOverflow(Unix::off_t a, Unix::off_t b) int FileHandle::stat(Unix::stat* buffer) { - LOCKER(VirtualFileSystem::lock()); - if (!m_vnode) return -EBADF; diff --git a/VirtualFileSystem/SyntheticFileSystem.cpp b/VirtualFileSystem/SyntheticFileSystem.cpp index 743e10a3d5..6f91fa252a 100644 --- a/VirtualFileSystem/SyntheticFileSystem.cpp +++ b/VirtualFileSystem/SyntheticFileSystem.cpp @@ -56,15 +56,15 @@ auto SyntheticFileSystem::createDirectory(String&& name) -> OwnPtr return file; } -auto SyntheticFileSystem::createTextFile(String&& name, String&& text) -> OwnPtr +auto SyntheticFileSystem::createTextFile(String&& name, ByteBuffer&& contents, Unix::mode_t mode) -> OwnPtr { auto file = make(); - file->data = text.toByteBuffer(); + file->data = contents; file->name = move(name); file->metadata.size = file->data.size(); file->metadata.uid = 100; file->metadata.gid = 200; - file->metadata.mode = 0010644; + file->metadata.mode = mode; file->metadata.mtime = mepoch; return file; } diff --git a/VirtualFileSystem/SyntheticFileSystem.h b/VirtualFileSystem/SyntheticFileSystem.h index ed7a9d900e..b9e696587d 100644 --- a/VirtualFileSystem/SyntheticFileSystem.h +++ b/VirtualFileSystem/SyntheticFileSystem.h @@ -39,7 +39,7 @@ protected: }; OwnPtr createDirectory(String&& name); - OwnPtr createTextFile(String&& name, String&& text); + OwnPtr createTextFile(String&& name, ByteBuffer&&, Unix::mode_t = 0010644); OwnPtr createGeneratedFile(String&& name, Function&&, Unix::mode_t = 0100644); InodeIdentifier addFile(OwnPtr&&, InodeIndex parent = RootInodeIndex); diff --git a/VirtualFileSystem/VirtualFileSystem.cpp b/VirtualFileSystem/VirtualFileSystem.cpp index cf9fe49a87..23c2ef4ced 100644 --- a/VirtualFileSystem/VirtualFileSystem.cpp +++ b/VirtualFileSystem/VirtualFileSystem.cpp @@ -103,11 +103,9 @@ auto VirtualFileSystem::getOrCreateNode(InodeIdentifier inode) -> RetainPtr&& fileSystem, const String& path) { - kprintf("mount\n"); - LOCKER(VirtualFileSystem::lock()); ASSERT(fileSystem); int error; - auto inode = resolvePath(path, error, locker); + auto inode = resolvePath(path, error); if (!inode.isValid()) { kprintf("[VFS] mount can't resolve mount point '%s'\n", path.characters()); return false; @@ -360,10 +358,8 @@ void VirtualFileSystem::listDirectoryRecursively(const String& path) bool VirtualFileSystem::touch(const String& path) { - LOCKER(VirtualFileSystem::lock()); - int error; - auto inode = resolvePath(path, error, locker); + auto inode = resolvePath(path, error); if (!inode.isValid()) return false; return inode.fileSystem()->setModificationTime(inode, ktime(nullptr)); @@ -371,9 +367,7 @@ bool VirtualFileSystem::touch(const String& path) OwnPtr VirtualFileSystem::open(const String& path, int& error, int options, InodeIdentifier base) { - LOCKER(VirtualFileSystem::lock()); - - auto inode = resolvePath(path, error, locker, base, options); + auto inode = resolvePath(path, error, base, options); if (!inode.isValid()) return nullptr; auto vnode = getOrCreateNode(inode); @@ -384,8 +378,6 @@ OwnPtr VirtualFileSystem::open(const String& path, int& error, int o OwnPtr VirtualFileSystem::create(const String& path, InodeIdentifier base) { - LOCKER(VirtualFileSystem::lock()); - // FIXME: Do the real thing, not just this fake thing! (void) path; m_rootNode->fileSystem()->createInode(m_rootNode->fileSystem()->rootInode(), "empty", 0100644, 0); @@ -394,28 +386,25 @@ OwnPtr VirtualFileSystem::create(const String& path, InodeIdentifier OwnPtr VirtualFileSystem::mkdir(const String& path, InodeIdentifier base) { - LOCKER(VirtualFileSystem::lock()); // FIXME: Do the real thing, not just this fake thing! (void) path; m_rootNode->fileSystem()->makeDirectory(m_rootNode->fileSystem()->rootInode(), "mydir", 0400755); return nullptr; } -InodeIdentifier VirtualFileSystem::resolveSymbolicLink(InodeIdentifier base, InodeIdentifier symlinkInode, int& error, Locker& locker) +InodeIdentifier VirtualFileSystem::resolveSymbolicLink(InodeIdentifier base, InodeIdentifier symlinkInode, int& error) { - locker.unlock(); auto symlinkContents = symlinkInode.readEntireFile(); - locker.lock(); if (!symlinkContents) return { }; auto linkee = String((const char*)symlinkContents.pointer(), symlinkContents.size()); #ifdef VFS_DEBUG kprintf("linkee (%s)(%u) from %u:%u\n", linkee.characters(), linkee.length(), base.fileSystemID(), base.index()); #endif - return resolvePath(linkee, error, locker, base); + return resolvePath(linkee, error, base); } -String VirtualFileSystem::absolutePathInternal(InodeIdentifier inode, Locker& locker) +String VirtualFileSystem::absolutePath(InodeIdentifier inode) { if (!inode.isValid()) return String(); @@ -428,7 +417,7 @@ String VirtualFileSystem::absolutePathInternal(InodeIdentifier inode, Locker& lo else lineage.append(inode); if (inode.metadata().isDirectory()) { - inode = resolvePath("..", error, locker, inode); + inode = resolvePath("..", error, inode); } else inode = inode.fileSystem()->findParentOfInode(inode); ASSERT(inode.isValid()); @@ -448,13 +437,7 @@ String VirtualFileSystem::absolutePathInternal(InodeIdentifier inode, Locker& lo return builder.build(); } -String VirtualFileSystem::absolutePath(InodeIdentifier inode) -{ - LOCKER(VirtualFileSystem::lock()); - return absolutePathInternal(inode, locker); -} - -InodeIdentifier VirtualFileSystem::resolvePath(const String& path, int& error, Locker& locker, InodeIdentifier base, int options) +InodeIdentifier VirtualFileSystem::resolvePath(const String& path, int& error, InodeIdentifier base, int options) { if (path.isEmpty()) return { }; @@ -521,7 +504,7 @@ InodeIdentifier VirtualFileSystem::resolvePath(const String& path, int& error, L if (options & O_NOFOLLOW_NOERROR) return inode; } - inode = resolveSymbolicLink(parent, inode, error, locker); + inode = resolveSymbolicLink(parent, inode, error); if (!inode.isValid()) { kprintf("Symbolic link resolution failed :(\n"); return { }; diff --git a/VirtualFileSystem/VirtualFileSystem.h b/VirtualFileSystem/VirtualFileSystem.h index 2c47915ab7..183fba5a1c 100644 --- a/VirtualFileSystem/VirtualFileSystem.h +++ b/VirtualFileSystem/VirtualFileSystem.h @@ -104,11 +104,9 @@ public: private: friend class FileHandle; - String absolutePathInternal(InodeIdentifier, Locker&); - void enumerateDirectoryInode(InodeIdentifier, Function); - InodeIdentifier resolvePath(const String& path, int& error, Locker&, InodeIdentifier base = InodeIdentifier(), int options = 0); - InodeIdentifier resolveSymbolicLink(InodeIdentifier base, InodeIdentifier symlinkInode, int& error, Locker&); + InodeIdentifier resolvePath(const String& path, int& error, InodeIdentifier base = InodeIdentifier(), int options = 0); + InodeIdentifier resolveSymbolicLink(InodeIdentifier base, InodeIdentifier symlinkInode, int& error); RetainPtr allocateNode(); void freeNode(Node*);