All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
To: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: [PATCH 6/9] restart: rename 'ctx->tasks_arr' to 'ctx->tasks'
Date: Wed, 26 Jan 2011 11:19:05 -0500	[thread overview]
Message-ID: <1296058748-21418-7-git-send-email-orenl@cs.columbia.edu> (raw)
In-Reply-To: <1296058748-21418-1-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>

In preparation for next (super)-patch.

Signed-off-by: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
---
 restart.c |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/restart.c b/restart.c
index d998834..ca02383 100644
--- a/restart.c
+++ b/restart.c
@@ -140,7 +140,7 @@ struct ckpt_ctx {
 	struct ckpt_pids *copy_arr;
 	__s32 *vpids_arr;
 
-	struct task *tasks_arr;
+	struct task *tasks;
 	int tasks_nr;
 	int tasks_max;
 	int tasks_pid;
@@ -520,8 +520,8 @@ static void exit_ctx(struct ckpt_ctx *ctx)
 {
 	if (ctx->freezer)
 		free(ctx->freezer);
-	if (ctx->tasks_arr)
-		free(ctx->tasks_arr);
+	if (ctx->tasks)
+		free(ctx->tasks);
 	if (ctx->pids_arr)
 		free(ctx->pids_arr);
 	if (ctx->copy_arr)
@@ -640,13 +640,13 @@ int cr_restart(struct cr_restart_args *args)
 	 * setup devpts, root-dir and /proc if necessary, ...
 	 */
 	if (ctx.args->mnt_pty)
-		ctx.tasks_arr[0].flags |= TASK_NEWPTS;
+		ctx.tasks[0].flags |= TASK_NEWPTS;
 	if (ctx.args->mntns)
-		ctx.tasks_arr[0].flags |= TASK_NEWNS;
+		ctx.tasks[0].flags |= TASK_NEWNS;
 	if (ctx.args->root)
-		ctx.tasks_arr[0].flags |= TASK_NEWROOT;
+		ctx.tasks[0].flags |= TASK_NEWROOT;
 
-	if (ctx.args->pidns && ctx.tasks_arr[0].pid != 1) {
+	if (ctx.args->pidns && ctx.tasks[0].pid != 1) {
 		ckpt_dbg("new pidns without init\n");
 		if (global_send_sigint == -1)
 			global_send_sigint = SIGINT;
@@ -655,12 +655,12 @@ int cr_restart(struct cr_restart_args *args)
 		 * the coordinator should set up the filesystems and
 		 * not the first process in the application process tree.
 		 */
-		ctx.tasks_arr[0].flags &=
-			~(TASK_NEWPTS | TASK_NEWROOT |TASK_NEWNS);
+		ctx.tasks[0].flags &=
+			~(TASK_NEWPTS | TASK_NEWROOT | TASK_NEWNS);
 		ret = ckpt_coordinator_pidns(&ctx);
 	} else if (ctx.args->pidns) {
 		ckpt_dbg("new pidns with init\n");
-		ctx.tasks_arr[0].flags |= TASK_NEWPID | TASK_NEWNS;
+		ctx.tasks[0].flags |= TASK_NEWPID | TASK_NEWNS;
 		if (global_send_sigint == -1)
 			global_send_sigint = SIGKILL;
 		ret = ckpt_coordinator(&ctx);
@@ -1018,7 +1018,7 @@ static int ckpt_coordinator(struct ckpt_ctx *ctx)
 	pid_t root_pid;
 	int ret;
 
-	root_pid = ckpt_fork_child(ctx, &ctx->tasks_arr[0]);
+	root_pid = ckpt_fork_child(ctx, &ctx->tasks[0]);
 	if (root_pid < 0)
 		return -1;
 	global_child_pid = root_pid;
@@ -1055,7 +1055,7 @@ static int ckpt_coordinator(struct ckpt_ctx *ctx)
 
 	ret = 0;
 
-	if (ctx->args->pidns && ctx->tasks_arr[0].pid != 1) {
+	if (ctx->args->pidns && ctx->tasks[0].pid != 1) {
 		/* Report success/failure to the parent */
 		if (write(ctx->pipe_coord[1], &ret, sizeof(ret)) < 0) {
 			ckpt_perror("failed to report status");
@@ -1093,7 +1093,7 @@ static int ckpt_coordinator(struct ckpt_ctx *ctx)
 
 static inline struct task *ckpt_init_task(struct ckpt_ctx *ctx)
 {
-	return (&ctx->tasks_arr[0]);
+	return (&ctx->tasks[0]);
 }
 
 /*
@@ -1112,8 +1112,8 @@ static int ckpt_build_tree(struct ckpt_ctx *ctx)
 	 * placeholder tasks (each session id may have at most one)
 	 */
 	ctx->tasks_max = ctx->pids_nr * 4;
-	ctx->tasks_arr = malloc(sizeof(*ctx->tasks_arr) * ctx->tasks_max);
-	if (!ctx->tasks_arr) {
+	ctx->tasks = malloc(sizeof(*ctx->tasks) * ctx->tasks_max);
+	if (!ctx->tasks) {
 		ckpt_perror("malloc tasks array");
 		return -1;
 	}
@@ -1124,7 +1124,7 @@ static int ckpt_build_tree(struct ckpt_ctx *ctx)
 
 	/* assign a creator to each task */
 	for (i = 0; i < ctx->tasks_nr; i++) {
-		task = &ctx->tasks_arr[i];
+		task = &ctx->tasks[i];
 		if (task->creator)
 			continue;
 		if (ckpt_set_creator(ctx, task) < 0)
@@ -1134,7 +1134,7 @@ static int ckpt_build_tree(struct ckpt_ctx *ctx)
 #ifdef CHECKPOINT_DEBUG
 	ckpt_dbg("====== TASKS\n");
 	for (i = 0; i < ctx->tasks_nr; i++) {
-		task = &ctx->tasks_arr[i];
+		task = &ctx->tasks[i];
 		ckpt_dbg("\t[%d] pid %d ppid %d sid %d creator %d",
 			 i, task->pid, task->ppid, task->sid,
 			 task->creator->pid);
@@ -1169,7 +1169,7 @@ static int ckpt_setup_task(struct ckpt_ctx *ctx, pid_t pid, pid_t ppid)
 	if (hash_lookup(ctx, pid))  /* already handled */
 		return 0;
 
-	task = &ctx->tasks_arr[ctx->tasks_nr++];
+	task = &ctx->tasks[ctx->tasks_nr++];
 
 	task->flags = TASK_GHOST;
 
@@ -1294,7 +1294,7 @@ static int ckpt_init_tree(struct ckpt_ctx *ctx)
 
 	/* populate with known tasks */
 	for (i = 0; i < pids_nr; i++) {
-		task = &ctx->tasks_arr[i];
+		task = &ctx->tasks[i];
 
 		task->flags = 0;
 
@@ -1571,7 +1571,7 @@ static int ckpt_set_creator(struct ckpt_ctx *ctx, struct task *task)
 static int ckpt_placeholder_task(struct ckpt_ctx *ctx, struct task *task)
 {
 	struct task *session = hash_lookup(ctx, task->sid);
-	struct task *holder = &ctx->tasks_arr[ctx->tasks_nr++];
+	struct task *holder = &ctx->tasks[ctx->tasks_nr++];
 	pid_t pid;
 
 	if (ctx->tasks_nr > ctx->tasks_max) {
@@ -2481,7 +2481,7 @@ static int assign_vpids(struct ckpt_ctx *ctx)
 	}
 
 	for (tidx = 0, hidx = 0, vidx = 0; tidx < ctx->pids_nr; tidx++) {
-		task = &ctx->tasks_arr[tidx];
+		task = &ctx->tasks[tidx];
 		depth = ctx->pids_arr[tidx].depth;
 
 		task->vidx = vidx;
@@ -2521,7 +2521,7 @@ static int ckpt_read_vpids(struct ckpt_ctx *ctx)
 		if (ctx->pids_arr[i].depth < 0) {
 			ckpt_err("Invalid depth %d for pid %d",
 				 ctx->pids_arr[i].depth,
-				 ctx->tasks_arr[i].pid);
+				 ctx->tasks[i].pid);
 			errno = -EINVAL;
 			return -1;
 		}
-- 
1.7.1

  parent reply	other threads:[~2011-01-26 16:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-26 16:18 [PATCH 0/9] user-cr: support for pids as shared objects Oren Laadan
     [not found] ` <1296058748-21418-1-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2011-01-26 16:19   ` [PATCH 1/9] Initialize of args->{outfd, logfd, infd} in main c/r programs Oren Laadan
     [not found]     ` <1296058748-21418-2-git-send-email-orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2011-01-26 16:24       ` [PATCH 0/9] user-cr: support for pids as shared objects Oren Laadan
2011-01-26 16:19   ` [PATCH 2/9] Introduce ctx->error to improve error reporting Oren Laadan
2011-01-26 16:19   ` [PATCH 3/9] restart: cleanup setup/cleanup of freezer cgroups Oren Laadan
2011-01-26 16:19   ` [PATCH 4/9] restart: make feeder a proper child instead of a thread Oren Laadan
2011-01-26 16:19   ` [PATCH 5/9] restart: obtain pid_max from /proc/sys/kernel/pid_max Oren Laadan
2011-01-26 16:19   ` Oren Laadan [this message]
2011-01-26 16:19   ` [PATCH 7/9] udpate kernel headers: support for pids objects Oren Laadan
2011-01-26 16:19   ` [PATCH 8/9] ckptinfo: s/ckpt_pids/ckpt_task_pids/ after kerenl header update Oren Laadan
2011-01-26 16:19   ` [PATCH 9/9] restart: fix support for nested pid namespaces Oren Laadan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1296058748-21418-7-git-send-email-orenl@cs.columbia.edu \
    --to=orenl-eqauephvms7envbuuze7ea@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.