Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions capio/server/include/storage/manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@ class StorageManager {
* @param tid The thread ID.
* @param fd The file descriptor number.
* @param path The path of the file being opened.
* @param register_open Whether this operation should also call open() on the CapioFile
* instance. defaults to true
* TODO: support flag CLONE_FILES which will directly affect the behaviour of
* register_open.
*/
void _addNewFdToStorage(pid_t tid, int fd, const std::filesystem::path &path);
void _addNewFdToStorage(pid_t tid, int fd, const std::filesystem::path &path,
bool register_open);

public:
/**
Expand Down Expand Up @@ -300,4 +305,4 @@ class StorageManager {
void updateDirectory(pid_t tid, const std::filesystem::path &file_path);
};

#endif // CAPIO_STORAGE_MANAGER_HPP
#endif // CAPIO_STORAGE_MANAGER_HPP
9 changes: 6 additions & 3 deletions capio/server/src/storage_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void StorageManager::clone(const pid_t parent_tid, const pid_t child_tid) {
const auto path = _opened_fd_map[parent_tid][fd]._path;
const auto offset = *_opened_fd_map[parent_tid][fd]._offset;

_addNewFdToStorage(child_tid, fd, path);
_addNewFdToStorage(child_tid, fd, path, false);
_addNewFdToMap(child_tid, fd, path, offset);
}
}
Expand Down Expand Up @@ -276,8 +276,11 @@ void StorageManager::_addNewFdToMap(const pid_t tid, const int fd,
}

void StorageManager::_addNewFdToStorage(const pid_t tid, const int fd,
const std::filesystem::path &path) {
_storage[path].open();
const std::filesystem::path &path,
const bool register_open = true) {
if (register_open) {
_storage[path].open();
}
_storage[path].add_fd(tid, fd);
}

Expand Down