[5/7] kdat: Add test for ctty inheritance

Submitted by Cyrill Gorcunov on Feb. 15, 2018, 8:30 p.m.

Details

Message ID 20180215203030.7513-6-gorcunov@virtuozzo.com
State New
Series "criu: Add support for ctty inheritance"
Headers show

Commit Message

Cyrill Gorcunov Feb. 15, 2018, 8:30 p.m.
Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
---
 criu/include/kerndat.h |  1 +
 criu/kerndat.c         | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/include/kerndat.h b/criu/include/kerndat.h
index f3af32df1..a3fe7efd6 100644
--- a/criu/include/kerndat.h
+++ b/criu/include/kerndat.h
@@ -55,6 +55,7 @@  struct kerndat_s {
 	unsigned long files_stat_max_files;
 	bool can_map_vdso;
 	bool has_inotify_setnextwd;
+	bool ve_can_inherit_ctty;
 };
 
 extern struct kerndat_s kdat;
diff --git a/criu/kerndat.c b/criu/kerndat.c
index 5176c274f..064d14343 100644
--- a/criu/kerndat.c
+++ b/criu/kerndat.c
@@ -837,6 +837,22 @@  int kerndat_has_inotify_setnextwd(void)
 	return ret;
 }
 
+void kerndat_ve(void)
+{
+	static const char path[] = "/sys/fs/cgroup/ve/ve.ctty";
+
+	if (access(path, F_OK) < 0) {
+		if (errno == ENOENT) {
+			pr_debug("ve.ctty is disabled\n");
+			kdat.ve_can_inherit_ctty = false;
+		}
+		pr_perror("Unable to access %s", path);
+		return;
+	}
+
+	kdat.ve_can_inherit_ctty = true;
+}
+
 int kerndat_init(void)
 {
 	int ret;
@@ -883,6 +899,7 @@  int kerndat_init(void)
 	kerndat_lsm();
 	kerndat_mmap_min_addr();
 	kerndat_files_stat(false);
+	kerndat_ve();
 
 	if (!ret)
 		kerndat_save_cache();