diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-01-23 05:09:11 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-01-23 05:09:11 +0100 |
commit | 19104570cc286b608f6f8c22002ed4a8965b4648 (patch) | |
tree | 2b4951eb5b329ce2c44ed8ff1bbb357cf2fe1d9b | |
parent | e911caeb1026a2e49d96bdd9c0af24fb37b7d777 (diff) | |
download | serenity-19104570cc286b608f6f8c22002ed4a8965b4648.zip |
VFS: Remove remnants of standalone builds.
-rw-r--r-- | VirtualFileSystem/.gitignore | 2 | ||||
-rw-r--r-- | VirtualFileSystem/Makefile | 44 | ||||
-rw-r--r-- | VirtualFileSystem/small.fs | bin | 2048000 -> 0 bytes | |||
-rw-r--r-- | VirtualFileSystem/test.cpp | 249 |
4 files changed, 0 insertions, 295 deletions
diff --git a/VirtualFileSystem/.gitignore b/VirtualFileSystem/.gitignore index 5588753b2b..499a618326 100644 --- a/VirtualFileSystem/.gitignore +++ b/VirtualFileSystem/.gitignore @@ -1,4 +1,2 @@ -test *.o *.swp -AK diff --git a/VirtualFileSystem/Makefile b/VirtualFileSystem/Makefile deleted file mode 100644 index 9ea79d9604..0000000000 --- a/VirtualFileSystem/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -PROGRAM = test - -AK_OBJS = \ - ../AK/String.o \ - ../AK/StringImpl.o \ - ../AK/MappedFile.o \ - ../AK/TemporaryFile.o \ - ../AK/SimpleMalloc.o \ - ../AK/StringBuilder.o \ - ../AK/FileSystemPath.o \ - ../AK/kmalloc.o - -VFS_OBJS = \ - DiskDevice.o \ - FileBackedDiskDevice.o \ - FileSystem.o \ - Ext2FileSystem.o \ - VirtualFileSystem.o \ - FileDescriptor.o \ - DiskBackedFileSystem.o \ - SyntheticFileSystem.o \ - InodeIdentifier.o \ - CharacterDevice.o \ - ZeroDevice.o \ - NullDevice.o \ - FullDevice.o \ - RandomDevice.o \ - test.o - -OBJS = $(AK_OBJS) $(VFS_OBJS) - -CXXFLAGS = -std=c++17 -O0 -W -Wall -Wextra -Wconversion -I. -I.. -ggdb3 -Wno-class-memaccess - -all: $(PROGRAM) - -.cpp.o: - $(CXX) $(CXXFLAGS) -o $@ -c $< - -clean: - rm -f $(OBJS) $(PROGRAM) - -$(PROGRAM): $(OBJS) - $(CXX) $(LDFLAGS) -o $@ $(OBJS) - diff --git a/VirtualFileSystem/small.fs b/VirtualFileSystem/small.fs Binary files differdeleted file mode 100644 index 5d852a7478..0000000000 --- a/VirtualFileSystem/small.fs +++ /dev/null diff --git a/VirtualFileSystem/test.cpp b/VirtualFileSystem/test.cpp deleted file mode 100644 index f24a302eee..0000000000 --- a/VirtualFileSystem/test.cpp +++ /dev/null @@ -1,249 +0,0 @@ -#include "Ext2FileSystem.h" -#include "FileBackedDiskDevice.h" -#include "VirtualFileSystem.h" -#include "FileDescriptor.h" -#include "SyntheticFileSystem.h" -#include "ZeroDevice.h" -#include "NullDevice.h" -#include "FullDevice.h" -#include "RandomDevice.h" -#include <cstring> -#include <AK/FileSystemPath.h> -#include <AK/SimpleMalloc.h> -#include <AK/StdLib.h> -#include <AK/kmalloc.h> -#include <AK/ktime.h> - -static RetainPtr<FS> makeFileSystem(const char* imagePath); - -int main(int c, char** v) -{ - const char* filename = "small.fs"; - if (c >= 2) - filename = v[1]; - - VFS::initialize_globals(); - - VFS vfs; - - auto zero = make<ZeroDevice>(); - vfs.register_character_device(*zero); - - auto null = make<NullDevice>(); - vfs.register_character_device(*null); - - auto full = make<FullDevice>(); - vfs.register_character_device(*full); - - auto random = make<RandomDevice>(); - vfs.register_character_device(*random); - - if (!vfs.mount_root(makeFileSystem(filename))) { - printf("Failed to mount root :(\n"); - return 1; - } - -#if 0 - auto newFile = vfs.create("/empty"); - printf("vfs.create: %p\n", newFile.ptr()); -#endif -#if 1 - auto newDir = vfs.mkdir("/mydir"); - printf("vfs.mkdir: %p\n", newDir.ptr()); -#endif - //return 0; - - if (!strcmp(v[0], "./vcat")) { - int error; - auto descriptor = vfs.open(v[2], error); - if (!descriptor) { - printf("failed to open %s inside fs image\n", v[2]); - return 1; - } - auto contents = descriptor->read_entire_file(); - - FILE* fout = fopen(v[3], "w"); - if (!fout) { - printf("failed to open %s for output\n", v[3]); - return 1; - } - fwrite(contents.pointer(), sizeof(char), contents.size(), fout); - fclose(fout); - return 0; - } - - auto synthfs = SynthFS::create(); - bool success = static_cast<FS&>(*synthfs).initialize(); - printf("synth->initialize(): returned %u\n", success); - - vfs.mount(std::move(synthfs), "/syn"); - - vfs.listDirectory(".", vfs.root()->inode); - printf("list /syn:\n"); - vfs.listDirectory("/syn", vfs.root()->inode); - -#if 0 - auto descriptor = vfs.open("/home/andreas/../../home/./andreas/./file2"); - printf("descriptor = %p\n", handle.ptr()); - ASSERT(descriptor); - - auto contents = descriptor->readEntireFile(); - ASSERT(contents); - - printf("contents: '%s'\n", contents->pointer()); -#endif - - String currentDirectory = "/"; - - auto cwd = vfs.root()->inode; - - while (true) { - char cmdbuf[256]; - printf("::>"); - fflush(stdout); - fgets(cmdbuf, sizeof(cmdbuf), stdin); - - if (cmdbuf[strlen(cmdbuf) - 1] == '\n') - cmdbuf[strlen(cmdbuf) - 1] = '\0'; - - String command = cmdbuf; - auto parts = command.split(' '); - - if (parts.is_empty()) - continue; - - String cmd = parts[0]; - - if (cmd == "q") - break; - - if (cmd == "pwd") { - printf("%s\n", currentDirectory.characters()); - continue; - } - - if (cmd == "ls") { - vfs.listDirectory(".", cwd); - continue; - } - - if (cmd == "lr") { - vfs.listDirectoryRecursively(".", cwd); - continue; - } - - if (cmd == "cd" && parts.size() > 1) { - char buf[4096]; - sprintf(buf, "%s/%s", currentDirectory.characters(), parts[1].characters()); - FileSystemPath new_path(buf); - if (new_path.string() == "/") { - cwd = vfs.root()->inode; - continue; - } - int error; - auto new_cwd = vfs.open(new_path.string(), error, 0, cwd); - if (new_cwd && new_cwd->is_directory()) { - currentDirectory = new_path.string(); - cwd = new_cwd->metadata().inode; - } else { - printf("No such directory: %s\n", parts[1].characters()); - } - continue; - } - - if (cmd == "mt" && parts.size() > 1) { - char buf[1024]; - sprintf(buf, "%s/%s", currentDirectory.characters(), parts[1].characters()); - vfs.touch(buf); - continue; - } - - if (cmd == "stat" && parts.size() > 1) { - char buf[1024]; - sprintf(buf, "%s/%s", currentDirectory.characters(), parts[1].characters()); - int error; - auto descriptor = vfs.open(buf, error); - if (!descriptor) { - printf("Can't open '%s' :(\n", buf); - continue; - } - Unix::stat st; - int rc = descriptor->stat(&st); - if (rc < 0) { - printf("stat failed: %d\n", rc); - continue; - } - printf("st_dev: %u\n", st.st_dev); - printf("st_ino: %u\n", st.st_ino); - printf("st_mode: %o\n", st.st_mode); - printf("st_nlink: %u\n", st.st_nlink); - printf("st_uid: %u\n", st.st_uid); - printf("st_gid: %u\n", st.st_gid); - printf("st_rdev: %u\n", st.st_rdev); - printf("st_size: %lld\n", st.st_size); - printf("st_blksize: %u\n", st.st_blksize); - printf("st_blocks: %u\n", st.st_blocks); - printf("st_atime: %u - %s", st.st_atime, ctime(&st.st_atime)); - printf("st_mtime: %u - %s", st.st_mtime, ctime(&st.st_mtime)); - printf("st_ctime: %u - %s", st.st_ctime, ctime(&st.st_ctime)); - continue; - } - - if (cmd == "cat" && parts.size() > 1) { - char pathbuf[1024]; - sprintf(pathbuf, "%s/%s", currentDirectory.characters(), parts[1].characters()); - int error; - auto descriptor = vfs.open(pathbuf, error); - if (!descriptor) { - printf("failed to open %s\n", pathbuf); - continue; - } - auto contents = descriptor->read_entire_file(); - fwrite(contents.pointer(), sizeof(char), contents.size(), stdout); - continue; - } - - if (cmd == "kat" && parts.size() > 1) { - char pathbuf[1024]; - sprintf(pathbuf, "%s/%s", currentDirectory.characters(), parts[1].characters()); - int error; - auto descriptor = vfs.open(pathbuf, error); - if (!descriptor) { - printf("failed to open %s\n", pathbuf); - continue; - } - ssize_t nread; - byte buffer[512]; - for (;;) { - nread = descriptor->read(buffer, sizeof(buffer)); - if (nread <= 0) - break; - fwrite(buffer, 1, nread, stdout); - } - if (nread < 0) - printf("ERROR: %d\n", nread); - continue; - } - - if (cmd == "ma") { - SimpleMalloc::dump(); - continue; - } - } - - return 0; -} - -RetainPtr<FS> makeFileSystem(const char* imagePath) -{ - auto fsImage = FileBackedDiskDevice::create(imagePath, 512); - if (!fsImage->is_valid()) { - fprintf(stderr, "Failed to open fs image file '%s'\n", imagePath); - exit(1); - } - auto ext2 = Ext2FS::create(std::move(fsImage)); - - bool success = static_cast<FS&>(*ext2).initialize(); - printf("ext2->initialize(): returned %u\n", success); - return ext2; -} |