Advertisement
Guest User

Untitled

a guest
Feb 1st, 2015
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. SHELL
  2.  
  3. 0. Initialization
  4. 0a. Create shared memory buffer.
  5.  
  6. 1. Reads user input.
  7.  
  8. 2. Attempts to map user input to a command.
  9. 2a. Tokenize input string.
  10. 2b. Match initial token to process name.
  11.  
  12. 3. If command can be matched to a process name
  13. 3a. Fork off child process, execute command.
  14. 3b. Wait for child process to complete.
  15.  
  16. 4. Return to step 1.
  17.  
  18. FAT HELPERS
  19.  
  20. boolean readFATData(unsigned int, byte*)
  21. * Reads data mapped from the FAT to the data sector into a buffer.
  22. * Returns if the data was read successfully.
  23.  
  24. boolean writeFATData(unsigned int, unsigned int, byte*)
  25. * Writes the given buffer with the given sector size to the given FAT chain, resizing if necessary.
  26. * Returns if the data was written successfully.
  27.  
  28. boolean getNextFreeFAT(unsigned int*)
  29. * Writes the next free FAT entry into the given integer.
  30. * Returns if any FAT entries were free.
  31.  
  32. boolean resizeFAT(unsigned int, unsigned int)
  33. * Resizes the given FAT chain to the given length.
  34. * Returns if it was able to do so.
  35.  
  36. void clearFAT(unsigned int)
  37. * Clears the given FAT chain.
  38.  
  39. ENVIRONMENT VARIABLES
  40.  
  41. typedef byte EnvVarName
  42. * key indicating the environment variable to use.
  43.  
  44. boolean envCreate()
  45. * Allocates a shared memory block to house our environment variables.
  46. * Returns if the block was successfully allocated.
  47.  
  48. void envDestroy()
  49. * Deallocates the shared memory block.
  50.  
  51. boolean envConnect()
  52. * Connects the given process to the shared memory block.
  53. * Returns if the connection was successfully made.
  54.  
  55. boolean envGet(EnvVarName, char*)
  56. * Reads the contents of the given environment variable into a buffer.
  57. * Returns if the environment variable was successfully retrieved.
  58.  
  59. void envSet(EnvVarName, char*)
  60. * Writes the contents of a buffer to the given environment variable.
  61.  
  62. boolean envDefined(EnvVarName)
  63. * Returns if the given environment variable has been defined.
  64.  
  65. void envUndefined(EnvVarName)
  66. * Clears the given environment variable.
  67.  
  68. Memory Block Layout
  69. * Per Variable - 128 bytes
  70. * Accessing a variable: block[varName * 128]
  71. * If not defined, block[varName * 128] == '\0'
  72.  
  73. Environment Variables
  74. * DISC - current data file
  75. * PWD - present working directory
  76.  
  77. DIRECTORY ENTRIES
  78.  
  79. struct directoryEntry_t
  80. * Maps to directory entry memory layout.
  81.  
  82. directoryEntry_t* getDirectoryEntryFromIndex(unsigned int, byte*)
  83. * Retrieves the directory entry at the given index in the directory data.
  84.  
  85. directoryEntry_t* getDirectoryEntryFromName(char*, byte*)
  86. * Retrieves the directory entry with the given name in the directory data.
  87.  
  88. boolean getDirectoryEntryIsDeleted(unsigned int, byte*)
  89. * Returns if the given directory entry has been deleted.
  90.  
  91. boolean getDirectoryEntryIsEmpty(unsigned int, byte*)
  92. * Returns if the given subdirectory entry is empty, or FALSE if the entry is not a subdirectory.
  93.  
  94. unsigned int removeDirectoryEntryByIndex(unsigned int, unsigned int, byte*)
  95. * Removes the directory entry at the given index from the data.
  96. * Returns the number of sectors remaining
  97.  
  98. PATH UTILS
  99.  
  100. void resolvePath(char*);
  101. * Take in the relative path and add it to our current path from shared memory.
  102.  
  103. COMMANDS
  104. cat x
  105. * Change the path to an absolute path if it is relative using resolvePath
  106. * Get the directory entry from the name argument using getDirectoryEntryFromName
  107. * Get the first logical cluster from the directory entry
  108. * Read the data using the read fat function
  109.  
  110. cd x
  111. * If not given an argument change our shared current directory to a constant home directory
  112. * Change the path to an absolute path if it is relative using resolvePath
  113. * From name function to check if the directory exist
  114. * If it does exist change our current directory in shared memory to the resolved path.
  115.  
  116. df
  117. *
  118.  
  119. ls x
  120. * If there is no argument given set the argument to the current path from the shared memory
  121. * Change the path to an absolute path if it is relative using resolvePath
  122. * Get the directory entry from the name argument using getDirectoryEntryFromName
  123. * If the file is not a subdirectory we write out the data about the file from the directory entry
  124. * If the file is a subdirectory we retrieve the directory info for that subdirectory
  125. * All the valid directory entries within the subdirectory
  126. * Write out information about all of these entries
  127.  
  128. pwd
  129. * print the current directory from shared memory
  130.  
  131. rm x
  132. * If there is no argument or more then one argument print an error message and quit
  133. * Change the path to an absolute path if it is relative using resolvePath
  134. * Get the directory entry from the name argument using getDirectoryEntryFromName
  135. *
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement