lxc/0032-link-proc-mounts-to-etc-mtab.patch

69 lines
1.6 KiB
Diff
Raw Normal View History

From e86ebe923f1ecc072d8a99949871b46fe8188ac9 Mon Sep 17 00:00:00 2001
2019-12-25 15:57:42 +08:00
From: wujing <wujing50@huawei.com>
Date: Wed, 15 Apr 2020 06:01:36 -0400
Subject: [PATCH 32/49] link proc mounts to etc mtab
2019-12-25 15:57:42 +08:00
Signed-off-by: wujing <wujing50@huawei.com>
---
src/lxc/conf.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
2019-12-25 15:57:42 +08:00
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 325e0c2..6856b1d 100644
2019-12-25 15:57:42 +08:00
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -3977,6 +3977,37 @@ struct oci_hook_conf {
int which;
};
2019-12-25 15:57:42 +08:00
+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");
2019-12-25 15:57:42 +08:00
}
}
+
2019-12-25 15:57:42 +08:00
+ // 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
2019-12-25 15:57:42 +08:00
if (!lxc_list_empty(&lxc_conf->keepcaps)) {
--
1.8.3.1
2019-12-25 15:57:42 +08:00