Skip to content

Commit

Permalink
Final polishing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Krulis committed Jan 6, 2021
1 parent b49555f commit 08a97b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/helpers/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @param dest output arg which is filled in case of success
* @return true if the hardlink match is found
*/
bool find_matching_hadlink(std::map<fs::path, fs::path> &hardlinks, const fs::path &src, fs::path &dest)
bool find_matching_hardlink(std::map<fs::path, fs::path> &hardlinks, const fs::path &src, fs::path &dest)
{
for (auto& [s, d] : hardlinks) {
if (fs::equivalent(s, src)) { // both paths point to the same data on the disk (same hardlinks)
Expand Down Expand Up @@ -59,7 +59,7 @@ void copy_diretory_internal(const fs::path &src, const fs::path &dest, bool skip
// a file may be either copied or hardlinked
if (!fs::is_symlink(srcPath) && fs::hard_link_count(srcPath) > 1) {
fs::path destPathHardlink;
if (find_matching_hadlink(hardlinks, it->path(), destPathHardlink)) {
if (find_matching_hardlink(hardlinks, it->path(), destPathHardlink)) {
// another file refering to the same data already exists in dest directory
fs::create_hard_link(destPathHardlink, destPath);
continue; // move to next file, hardlink replaced copying
Expand All @@ -84,9 +84,9 @@ void helpers::copy_directory(const fs::path &src, const fs::path &dest, bool ski
{
/*
* Hardlinks map provide mapping between files in src and dest which have been harlinked.
* Everytime a file with > 1 hadlink count is copied from src to dest, it is registered here.
* Everytime a file with > 1 hardlink count is copied from src to dest, it is registered here.
* When files with > 1 hardlinks are encountered, this map is searched and if match is found
* the new file is hadlinked inside dest instead of coping it from src.
* the new file is hardlinked inside dest instead of coping it from src.
*/
std::map<fs::path, fs::path> hardlinks;
::copy_diretory_internal(src, dest, skip_symlinks, hardlinks);
Expand Down
8 changes: 4 additions & 4 deletions src/sandbox/isolate_sandbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,18 @@ void isolate_sandbox::isolate_init_child(int fd_0, int fd_1)
if (devnull == -1) { log_and_throw(logger_, "Cannot open /dev/null file for writing."); }
dup2(devnull, 2);

std::string boxIdArg("--box-id=" + std::to_string(id_));
std::string box_id_arg("--box-id=" + std::to_string(id_));

// disk quotas need to be set in initialization
auto disk_size_blocks = (limits_.disk_size * 1024) / BLOCK_SIZE;
std::string quotaArg("--quota=" + std::to_string(disk_size_blocks) + "," + std::to_string(limits_.disk_files));
std::string quota_arg("--quota=" + std::to_string(disk_size_blocks) + "," + std::to_string(limits_.disk_files));

// Exec isolate init command
const char *args[] {
isolate_binary_.c_str(),
"--cg",
boxIdArg.c_str(),
quotaArg.c_str(),
box_id_arg.c_str(),
quota_arg.c_str(),
"--init",
nullptr,
};
Expand Down

0 comments on commit 08a97b8

Please sign in to comment.