Skip to content

Commit

Permalink
fix: Create soft link for the watch file
Browse files Browse the repository at this point in the history
在容器运行时给容器内的监听文件创建软链接。文件修改后也能获取到修改。

Log:
  • Loading branch information
chenchongbiao committed Jul 22, 2024
1 parent f7cac32 commit d7448b4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions libs/linglong/src/linglong/runtime/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,22 @@ Container::run(const ocppi::runtime::config::types::Process &process) noexcept
.uidMappings = {},
});

QStringList watchFilesPaths = {"localtime", "resolv.conf", "timezone"};
for (const QString &watchFile: watchFilesPaths) {
if (symlink("/run/host/monitor/"+watchFile.toUtf8(), bundle.absoluteFilePath(watchFile).toUtf8()) != 0) {
qCritical() << "Failed to create symlink for" << watchFile;
continue;
}
this->cfg.mounts->push_back(ocppi::runtime::config::types::Mount{
.destination = "/etc/"+watchFile.toStdString(),
.gidMappings = {},
.options = { { "rbind", "copy-symlink" } },
.source = bundle.absoluteFilePath(watchFile).toStdString(),
.type = "bind",
.uidMappings = {},
});
}

nlohmann::json json = this->cfg;

{
Expand Down

0 comments on commit d7448b4

Please sign in to comment.