All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] make uts_ns=n compile
@ 2010-03-15 22:50 Serge E. Hallyn
  0 siblings, 0 replies; only message in thread
From: Serge E. Hallyn @ 2010-03-15 22:50 UTC (permalink / raw)
  To: Oren Laadan; +Cc: Linux Containers

One of those unfortunate patches that turns out hard to read, but
it just moves the #ifdef'd part of do_restore_uts_ns into
ifdef'd helpers.

Signed-off-by: Serge E. Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 checkpoint/namespace.c |   50 +++++++++++++++++++++++++++++++----------------
 1 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/checkpoint/namespace.c b/checkpoint/namespace.c
index 4b3ac5a..3bd8e85 100644
--- a/checkpoint/namespace.c
+++ b/checkpoint/namespace.c
@@ -53,22 +53,17 @@ int checkpoint_uts_ns(struct ckpt_ctx *ctx, void *ptr)
 	return do_checkpoint_uts_ns(ctx, (struct uts_namespace *) ptr);
 }
 
-static struct uts_namespace *do_restore_uts_ns(struct ckpt_ctx *ctx)
+#ifdef CONFIG_UTS_NS
+static inline struct uts_namespace *ckpt_do_copy_uts_ns(struct ckpt_ctx *ctx,
+		struct ckpt_hdr_utsns *h)
 {
-	struct ckpt_hdr_utsns *h;
-	struct uts_namespace *uts_ns = NULL;
-	struct new_utsname *name;
-
-	h = ckpt_read_obj_type(ctx, sizeof(*h), CKPT_HDR_UTS_NS);
-	if (IS_ERR(h))
-		return (struct uts_namespace *) h;
+	struct new_utsname *name = NULL;
+	struct uts_namespace *uts_ns;
 
-#ifdef CONFIG_UTS_NS
 	uts_ns = create_uts_ns();
-	if (!uts_ns) {
-		uts_ns = ERR_PTR(-ENOMEM);
-		goto out;
-	}
+	if (!uts_ns)
+		return ERR_PTR(-ENOMEM);
+
 	down_read(&uts_sem);
 	name = &uts_ns->name;
 	memcpy(name->sysname, h->sysname, sizeof(name->sysname));
@@ -78,16 +73,37 @@ static struct uts_namespace *do_restore_uts_ns(struct ckpt_ctx *ctx)
 	memcpy(name->machine, h->machine, sizeof(name->machine));
 	memcpy(name->domainname, h->domainname, sizeof(name->domainname));
 	up_read(&uts_sem);
+	return uts_ns;
+}
 #else
+static inline struct uts_namespace *ckpt_do_copy_uts_ns(struct ckpt_ctx *ctx,
+		struct ckpt_hdr_utsns *h)
+{
+	struct uts_namespace *uts_ns;
+
 	/* complain if image contains multiple namespaces */
-	if (ctx->stats.uts_ns) {
-		uts_ns = ERR_PTR(-EEXIST);
-		goto out;
-	}
+	if (ctx->stats.uts_ns)
+		return ERR_PTR(-EEXIST);
+
 	uts_ns = current->nsproxy->uts_ns;
 	get_uts_ns(uts_ns);
+	return uts_ns;
+}
 #endif
 
+static struct uts_namespace *do_restore_uts_ns(struct ckpt_ctx *ctx)
+{
+	struct ckpt_hdr_utsns *h;
+	struct uts_namespace *uts_ns;
+
+	h = ckpt_read_obj_type(ctx, sizeof(*h), CKPT_HDR_UTS_NS);
+	if (IS_ERR(h))
+		return (struct uts_namespace *) h;
+
+	uts_ns = ckpt_do_copy_uts_ns(ctx, h);
+	if (IS_ERR(uts_ns))
+		goto out;
+
 	ctx->stats.uts_ns++;
  out:
 	ckpt_hdr_put(ctx, h);
-- 
1.6.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-03-15 22:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-15 22:50 [PATCH] make uts_ns=n compile Serge E. Hallyn

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.