[PATCH] rlimit: Allocate and free appropriate Core entry

Cyrill Gorcunov gorcunov at openvz.org
Thu Mar 13 05:57:14 PDT 2014


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 pstree.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/pstree.c b/pstree.c
index eba0c30c8592..a63c042e736c 100644
--- a/pstree.c
+++ b/pstree.c
@@ -29,8 +29,14 @@ CoreEntry *core_entry_alloc(int th, int tsk)
 	void *m;
 
 	sz = sizeof(CoreEntry);
-	if (tsk)
+	if (tsk) {
 		sz += sizeof(TaskCoreEntry) + TASK_COMM_LEN;
+		if (th) {
+			sz += sizeof(TaskRlimitsEntry);
+			sz += RLIM_NLIMITS * sizeof(RlimitEntry);
+			sz += RLIM_NLIMITS * sizeof(RlimitEntry *);
+		}
+	}
 	if (th)
 		sz += sizeof(ThreadCoreEntry) + sizeof(ThreadSasEntry);
 
@@ -45,6 +51,23 @@ CoreEntry *core_entry_alloc(int th, int tsk)
 			task_core_entry__init(core->tc);
 			core->tc->comm = xptr_pull_s(&m, TASK_COMM_LEN);
 			memzero(core->tc->comm, TASK_COMM_LEN);
+
+			if (th) {
+				TaskRlimitsEntry *task_rlimits;
+				size_t i;
+
+				task_rlimits = xptr_pull(&m, TaskRlimitsEntry);
+				task_rlimits_entry__init(task_rlimits);
+				core->task_rlimits = task_rlimits;
+
+				task_rlimits->n_rlimits = RLIM_NLIMITS;
+				task_rlimits->rlimits = xptr_pull_s(&m, sizeof(RlimitEntry *) * RLIM_NLIMITS);
+
+				for (i = 0; i < RLIM_NLIMITS; i++) {
+					task_rlimits->rlimits[i] = xptr_pull(&m, RlimitEntry);
+					rlimit_entry__init(task_rlimits->rlimits[i]);
+				}
+			}
 		}
 
 		if (th) {
-- 
1.8.3.1


--4jXrM3lyYWu4nBt5--


More information about the CRIU mailing list