@@ -214,6 +214,20 @@ namespace tinykvm
214214 // / @return True if the socket address is allowed, false otherwise.
215215 bool validate_socket_address (const int socket_fd, struct sockaddr_storage & socket_address) const noexcept ;
216216
217+ // / @brief Set the current working directory. This is used in a few system
218+ // / calls, such as getcwd() and chdir().
219+ // / @param path The path to set as the current working directory.
220+ void set_current_working_directory (const std::string& path) noexcept {
221+ m_current_working_directory = path;
222+ }
223+
224+ // / @brief Get the current working directory. This is used in a few system
225+ // / calls, such as getcwd() and chdir().
226+ // / @return The current working directory.
227+ const std::string& current_working_directory () const noexcept {
228+ return m_current_working_directory;
229+ }
230+
217231 // / @brief Set verbose mode. This will print out information about
218232 // / file descriptor management.
219233 // / @param verbose True to enable verbose mode, false to disable it.
@@ -238,6 +252,7 @@ namespace tinykvm
238252 int m_next_file_fd = 0x1000 ;
239253 int m_next_socket_fd = 0x1000 | SOCKET_BIT;
240254 std::array<int , 3 > m_stdout_redirects { 0 , 1 , 2 };
255+ std::string m_current_working_directory;
241256 bool m_verbose = false ;
242257 open_readable_t m_open_readable;
243258 open_writable_t m_open_writable;
0 commit comments