/* * This file implements the File System object, which is the namespace for a * task's files. It tracks a task's root and current working directory. */ #include #include #include "namespace.h" static void file_system_new(Object *); static void file_system_copy(Object *, Object *); /* File System object type */ ObjectType fsType = { .size = sizeof(FileSystem), .new = file_system_new, .copy = file_system_copy, }; /* Create a new File System object */ static void file_system_new(Object *obj) { FileSystem *fs = (void *) obj; fs->cwdPath = create_list(&dirEntryType); } /* Copy a File System object */ static void file_system_copy(Object *a, Object *b) { FileSystem *parent = (void *) a, *child = (void *) b; child->cwd = get(parent->cwd); /* init cwd custody chain */ child->cwdPath = copy_list(parent->cwdPath); /* copy cwd custody chain */ child->root = get(parent->root); }