Fix SAR support for overlay.d

This commit is contained in:
topjohnwu
2020-04-25 23:19:36 -07:00
parent 2aede97754
commit c7ed0ef5eb
6 changed files with 48 additions and 19 deletions

View File

@@ -13,10 +13,13 @@
#include <unistd.h>
#include <syscall.h>
#include <random>
#include <string>
#include <logging.hpp>
#include <utils.hpp>
using namespace std;
int fork_dont_care() {
int pid = xfork();
if (pid) {
@@ -214,3 +217,12 @@ int switch_mnt_ns(int pid) {
close(fd);
return ret;
}
string &replace_all(string &str, string_view from, string_view to) {
size_t pos = 0;
while((pos = str.find(from, pos)) != string::npos) {
str.replace(pos, from.length(), to);
pos += to.length();
}
return str;
}