1 Star 0 Fork 43

gaohuatao / lxc

forked from src-openEuler / lxc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0032-link-proc-mounts-to-etc-mtab.patch 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
lifeng_isula 提交于 2020-04-23 11:50 . lxc: update lxc to 4.0.1
From e86ebe923f1ecc072d8a99949871b46fe8188ac9 Mon Sep 17 00:00:00 2001
From: wujing <wujing50@huawei.com>
Date: Wed, 15 Apr 2020 06:01:36 -0400
Subject: [PATCH 32/49] link proc mounts to etc mtab
Signed-off-by: wujing <wujing50@huawei.com>
---
src/lxc/conf.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 325e0c2..6856b1d 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -3977,6 +3977,37 @@ struct oci_hook_conf {
int which;
};
+static int create_mtab_link()
+{
+ ssize_t ret;
+ int mret;
+ struct stat sbuf;
+ const char *pathname = "/proc/mounts";
+ const char *slink = "/etc/mtab";
+
+ if (file_exists(slink)) {
+ return 0;
+ }
+
+ ret = stat(pathname, &sbuf);
+ if (ret < 0) {
+ SYSERROR("Failed to stat %s: %s", pathname, strerror(errno));
+ return -1;
+ }
+
+ mret = symlink(pathname, slink);
+ if (mret < 0 && errno != EEXIST) {
+ if (errno == EROFS) {
+ WARN("Failed to create link %s for target %s. Read-only filesystem", slink, pathname);
+ } else {
+ SYSERROR("Failed to create \"%s\"", slink);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
struct wait_conf {
pid_t pid;
unsigned long long startat;
@@ -4696,6 +4727,12 @@ int lxc_setup(struct lxc_handler *handler)
return log_error(-1, "failed to setup readonlypaths");
}
}
+
+ // isulad: create link /etc/mtab for /proc/mounts
+ if (create_mtab_link() != 0) {
+ ERROR("failed to create link /etc/mtab for target /proc/mounts");
+ goto on_error;
+ }
#endif
if (!lxc_list_empty(&lxc_conf->keepcaps)) {
--
1.8.3.1
1
https://gitee.com/gaohuatao/lxc.git
git@gitee.com:gaohuatao/lxc.git
gaohuatao
lxc
lxc
master

搜索帮助