Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SHELL
- 0. Initialization
- 0a. Create shared memory buffer.
- 1. Reads user input.
- 2. Attempts to map user input to a command.
- 2a. Tokenize input string.
- 2b. Match initial token to process name.
- 3. If command can be matched to a process name
- 3a. Fork off child process, execute command.
- 3b. Wait for child process to complete.
- 4. Return to step 1.
- FAT HELPERS
- boolean readFATData(unsigned int, byte*)
- * Reads data mapped from the FAT to the data sector into a buffer.
- * Returns if the data was read successfully.
- boolean writeFATData(unsigned int, unsigned int, byte*)
- * Writes the given buffer with the given sector size to the given FAT chain, resizing if necessary.
- * Returns if the data was written successfully.
- boolean getNextFreeFAT(unsigned int*)
- * Writes the next free FAT entry into the given integer.
- * Returns if any FAT entries were free.
- boolean resizeFAT(unsigned int, unsigned int)
- * Resizes the given FAT chain to the given length.
- * Returns if it was able to do so.
- void clearFAT(unsigned int)
- * Clears the given FAT chain.
- ENVIRONMENT VARIABLES
- typedef byte EnvVarName
- * key indicating the environment variable to use.
- boolean envCreate()
- * Allocates a shared memory block to house our environment variables.
- * Returns if the block was successfully allocated.
- void envDestroy()
- * Deallocates the shared memory block.
- boolean envConnect()
- * Connects the given process to the shared memory block.
- * Returns if the connection was successfully made.
- boolean envGet(EnvVarName, char*)
- * Reads the contents of the given environment variable into a buffer.
- * Returns if the environment variable was successfully retrieved.
- void envSet(EnvVarName, char*)
- * Writes the contents of a buffer to the given environment variable.
- boolean envDefined(EnvVarName)
- * Returns if the given environment variable has been defined.
- void envUndefined(EnvVarName)
- * Clears the given environment variable.
- Memory Block Layout
- * Per Variable - 128 bytes
- * Accessing a variable: block[varName * 128]
- * If not defined, block[varName * 128] == '\0'
- Environment Variables
- * DISC - current data file
- * PWD - present working directory
- DIRECTORY ENTRIES
- struct directoryEntry_t
- * Maps to directory entry memory layout.
- directoryEntry_t* getDirectoryEntryFromIndex(unsigned int, byte*)
- * Retrieves the directory entry at the given index in the directory data.
- directoryEntry_t* getDirectoryEntryFromName(char*, byte*)
- * Retrieves the directory entry with the given name in the directory data.
- boolean getDirectoryEntryIsDeleted(unsigned int, byte*)
- * Returns if the given directory entry has been deleted.
- boolean getDirectoryEntryIsEmpty(unsigned int, byte*)
- * Returns if the given subdirectory entry is empty, or FALSE if the entry is not a subdirectory.
- unsigned int removeDirectoryEntryByIndex(unsigned int, unsigned int, byte*)
- * Removes the directory entry at the given index from the data.
- * Returns the number of sectors remaining
- PATH UTILS
- void resolvePath(char*);
- * Take in the relative path and add it to our current path from shared memory.
- COMMANDS
- cat x
- * Change the path to an absolute path if it is relative using resolvePath
- * Get the directory entry from the name argument using getDirectoryEntryFromName
- * Get the first logical cluster from the directory entry
- * Read the data using the read fat function
- cd x
- * If not given an argument change our shared current directory to a constant home directory
- * Change the path to an absolute path if it is relative using resolvePath
- * From name function to check if the directory exist
- * If it does exist change our current directory in shared memory to the resolved path.
- df
- *
- ls x
- * If there is no argument given set the argument to the current path from the shared memory
- * Change the path to an absolute path if it is relative using resolvePath
- * Get the directory entry from the name argument using getDirectoryEntryFromName
- * If the file is not a subdirectory we write out the data about the file from the directory entry
- * If the file is a subdirectory we retrieve the directory info for that subdirectory
- * All the valid directory entries within the subdirectory
- * Write out information about all of these entries
- pwd
- * print the current directory from shared memory
- rm x
- * If there is no argument or more then one argument print an error message and quit
- * Change the path to an absolute path if it is relative using resolvePath
- * Get the directory entry from the name argument using getDirectoryEntryFromName
- *
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement