All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
To: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
Cc: Containers
	<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>
Subject: [RFC][PATCH 4/6][usercr] Move checkpoint() into restart.c
Date: Tue, 13 Apr 2010 17:52:54 -0700	[thread overview]
Message-ID: <20100414005254.GD13532@us.ibm.com> (raw)
In-Reply-To: <20100414004927.GA13012-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>


From: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Date: Tue, 13 Apr 2010 14:35:32 -0700
Subject: [RFC][PATCH 4/6][usercr] Move checkpoint() into restart.c

checkpoint() function is pretty small and the file checkpoint.c mostly
has includes/declarations that are common to restart.c. We could just
fold both checkpoint() and restart() into a single file.

To keep the diff simple, this patch just does the move and the next
patch renames 'restart.c' to 'cr_checkpoint.c'.

Signed-off-by: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
---
 Makefile     |   10 ++++++--
 checkpoint.c |   62 ----------------------------------------------------------
 restart.c    |   35 ++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 65 deletions(-)
 delete mode 100644 checkpoint.c

diff --git a/Makefile b/Makefile
index afe144f..674b112 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ CKPT_HEADERS = include/linux/checkpoint.h \
 		include/linux/checkpoint_hdr.h \
 		include/asm/checkpoint_hdr.h
 
-CR_OBJS = checkpoint.o checkpoint-main.o restart.o restart-main.o
+CR_OBJS = restart.o checkpoint-main.o restart-main.o
 
 # detect architecture (for eclone)
 SUBARCH ?= $(patsubst i%86,x86_32,$(shell uname -m))
@@ -32,7 +32,7 @@ PREFIX ?= /usr/local
 BIN_INSTALL_DIR := $(PREFIX)/bin
 LIB_INSTALL_DIR := $(PREFIX)/lib
 
-ECLONE_PROGS = restart nsexec
+ECLONE_PROGS = checkpoint restart nsexec
 PROGS =	checkpoint ckptinfo $(ECLONE_PROGS)
 LIB_ECLONE = libeclone.a
 
@@ -55,8 +55,10 @@ restart: CFLAGS += -D__REENTRANT -pthread
 $(CR_OBJS): common.h cr_checkpoint.h
 
 restart: restart.o restart-main.o
+	$(CC) -o $@ $^
 
-checkpoint: checkpoint.o checkpoint-main.o
+checkpoint: restart.o checkpoint-main.o
+	$(CC) -o $@ $^
 
 # eclone() is architecture specific
 ifneq ($(SUBARCH),)
@@ -77,6 +79,8 @@ ASFLAGS += -m64
 $(LIB_ECLONE): clone_$(SUBARCH)_.o
 endif
 
+restart.o: $(LIB_ECLONE)
+
 # ckptinfo dependencies
 ckptinfo: ckptinfo_types.o
 
diff --git a/checkpoint.c b/checkpoint.c
deleted file mode 100644
index 90d4d35..0000000
--- a/checkpoint.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- *  checkpoint.c: checkpoint one or multiple processes
- *
- *  Copyright (C) 2008-2009 Oren Laadan
- *
- *  This file is subject to the terms and conditions of the GNU General Public
- *  License.  See the file COPYING in the main directory of the Linux
- *  distribution for more details.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <getopt.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-
-#include <linux/checkpoint.h>
-
-#include "cr_checkpoint.h"
-#include "common.h"
-
-static int global_uerrfd = -1;
-
-inline static int checkpoint(pid_t pid, int fd, unsigned long flags, int logfd)
-{
-	return syscall(__NR_checkpoint, pid, fd, flags, logfd);
-}
-
-int cr_checkpoint(int pid, struct cr_checkpoint_args *args)
-{
-	int ret;
-	unsigned long flags;
-
-	global_uerrfd = args->uerrfd;
-
-	/* output file descriptor (default: stdout) */
-	if (args->outfd < 0)
-		args->outfd = STDOUT_FILENO;
-
-	/* output file descriptor (default: none) */
-	if (args->logfd < 0)
-		args->logfd = CHECKPOINT_FD_NONE;
-
-	if (!args->container)
-		flags |= CHECKPOINT_SUBTREE;
-
-	ret = checkpoint(pid, args->outfd, flags, args->logfd);
-
-	if (ret < 0) {
-		ckpt_perror("checkpoint");
-		ckpt_err("(you may use 'ckptinfo -e' for more info)\n"); 
-	} else if (args->verbose) {
-		ckpt_err("checkpoint id %d\n", ret);
-	}
-
-	return ret;
-}
diff --git a/restart.c b/restart.c
index 11628e0..e01c08e 100644
--- a/restart.c
+++ b/restart.c
@@ -232,6 +232,11 @@ static inline pid_t _getpid(void)
 	return syscall(__NR_getpid);
 }
 
+inline static int checkpoint(pid_t pid, int fd, unsigned long flags, int logfd)
+{
+	return syscall(__NR_checkpoint, pid, fd, flags, logfd);
+}
+
 static inline int restart(pid_t pid, int fd, unsigned long flags, int klogfd)
 {
 	return syscall(__NR_restart, pid, fd, flags, klogfd);
@@ -2582,3 +2587,33 @@ static void *hash_lookup(struct ckpt_ctx *ctx, long key)
 	}
 	return NULL;
 }
+
+int cr_checkpoint(int pid, struct cr_checkpoint_args *args)
+{
+	int ret;
+	unsigned long flags;
+
+	global_uerrfd = args->uerrfd;
+
+	/* output file descriptor (default: stdout) */
+	if (args->outfd < 0)
+		args->outfd = STDOUT_FILENO;
+
+	/* log file descriptor (default: none) */
+	if (args->logfd < 0)
+		args->logfd = CHECKPOINT_FD_NONE;
+
+	if (!args->container)
+		flags |= CHECKPOINT_SUBTREE;
+
+	ret = checkpoint(pid, args->outfd, flags, args->logfd);
+
+	if (ret < 0) {
+		ckpt_perror("checkpoint");
+		ckpt_err("(you may use 'ckptinfo -e' for more info)\n"); 
+	} else if (args->verbose) {
+		ckpt_err("checkpoint id %d\n", ret);
+	}
+
+	return ret;
+}
-- 
1.6.6.1

  parent reply	other threads:[~2010-04-14  0:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-14  0:49 [RFC][PATCH 0/6][usercr]: Rename/reorg usercr code Sukadev Bhattiprolu
     [not found] ` <20100414004927.GA13012-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-04-14  0:52   ` [RFC][PATCH 1/6][usercr] Change API prefix to cr_ Sukadev Bhattiprolu
2010-04-14  0:52   ` [RFC][PATCH 2/6][usercr] Remove flags parameter to cr_checkpoint() Sukadev Bhattiprolu
2010-04-14  0:52   ` [RFC][PATCH 3/6][usercr] Minor reorg of restart.c Sukadev Bhattiprolu
2010-04-14  0:52   ` Sukadev Bhattiprolu [this message]
2010-04-14  0:53   ` [RFC][PATCH 5/6][usercr] Rename restart.c to cr_checkpoint.c Sukadev Bhattiprolu
2010-04-14  0:53   ` [RFC][PATCH 6/6][usercr] Rename common.h to cr_log.h Sukadev Bhattiprolu
2010-04-20 18:07   ` [RFC][PATCH 0/6][usercr]: Rename/reorg usercr code Sukadev Bhattiprolu
     [not found]     ` <20100420180733.GA13874-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-04-25 20:24       ` Oren Laadan
     [not found]         ` <4BD4A501.6070106-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2010-04-26 17:16           ` Sukadev Bhattiprolu
     [not found]             ` <20100426171603.GB27542-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-04-26 18:46               ` Oren Laadan
2010-06-14 21:31           ` 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=20100414005254.GD13532@us.ibm.com \
    --to=sukadev-23vcf4htsmix0ybbhkvfkdbpr1lh4cv8@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=orenl-eQaUEPhvms7ENvBUuze7eA@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.