From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH 6/6] nsenter: fix indentation
Date: Sun, 20 Jan 2013 18:04:56 +0000 [thread overview]
Message-ID: <1358705096-21092-7-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1358705096-21092-1-git-send-email-kerolasa@iki.fi>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
include/namespace.h | 55 ++++++++++++++++++++++++++---------------------------
sys-utils/nsenter.c | 35 ++++++++++++++++++++--------------
2 files changed, 48 insertions(+), 42 deletions(-)
diff --git a/include/namespace.h b/include/namespace.h
index 8ccc3f6..3a219ce 100644
--- a/include/namespace.h
+++ b/include/namespace.h
@@ -1,43 +1,42 @@
/* Compat code so unshare and setns can be used with older libcs */
#ifndef UTIL_LINUX_NAMESPACE_H
-#define UTIL_LINUX_NAMESPACE_H
+# define UTIL_LINUX_NAMESPACE_H
-#include <sched.h>
+# include <sched.h>
-#ifndef CLONE_NEWSNS
-# define CLONE_NEWNS 0x00020000
-#endif
-#ifndef CLONE_NEWUTS
-# define CLONE_NEWUTS 0x04000000
-#endif
-#ifndef CLONE_NEWIPC
-# define CLONE_NEWIPC 0x08000000
-#endif
-#ifndef CLONE_NEWNET
-# define CLONE_NEWNET 0x40000000
-#endif
-#ifndef CLONE_NEWUSER
-# define CLONE_NEWUSER 0x10000000
-#endif
-#ifndef CLONE_NEWPID
-# define CLONE_NEWPID 0x20000000
-#endif
-
-#ifndef HAVE_UNSHARE
-# include <sys/syscall.h>
+# ifndef CLONE_NEWSNS
+# define CLONE_NEWNS 0x00020000
+# endif
+# ifndef CLONE_NEWUTS
+# define CLONE_NEWUTS 0x04000000
+# endif
+# ifndef CLONE_NEWIPC
+# define CLONE_NEWIPC 0x08000000
+# endif
+# ifndef CLONE_NEWNET
+# define CLONE_NEWNET 0x40000000
+# endif
+# ifndef CLONE_NEWUSER
+# define CLONE_NEWUSER 0x10000000
+# endif
+# ifndef CLONE_NEWPID
+# define CLONE_NEWPID 0x20000000
+# endif
+# ifndef HAVE_UNSHARE
+# include <sys/syscall.h>
static inline int unshare(int flags)
{
return syscall(SYS_unshare, flags);
}
-#endif
+# endif
-#ifndef HAVE_SETNS
-# include <sys/syscall.h>
+# ifndef HAVE_SETNS
+# include <sys/syscall.h>
static inline int setns(int fd, int nstype)
{
return syscall(SYS_setns, fd, nstype);
}
-#endif /* HAVE_SETNS */
+# endif
-#endif /* UTIL_LINUX_NAMESPACE_H */
+#endif /* UTIL_LINUX_NAMESPACE_H */
diff --git a/sys-utils/nsenter.c b/sys-utils/nsenter.c
index 0e1c8f4..04ac314 100644
--- a/sys-utils/nsenter.c
+++ b/sys-utils/nsenter.c
@@ -34,7 +34,7 @@
#include "closestream.h"
#include "namespace.h"
-static struct namespace_file{
+static struct namespace_file {
int nstype;
const char *name;
int fd;
@@ -91,12 +91,13 @@ static void open_target_fd(int *fd, const char *type, const char *path)
if (!path && namespace_target_pid) {
snprintf(pathbuf, sizeof(pathbuf), "/proc/%u/%s",
- namespace_target_pid, type);
+ namespace_target_pid, type);
path = pathbuf;
}
if (!path)
- errx(EXIT_FAILURE, _("neither filename nor target pid supplied for %s"),
- type);
+ errx(EXIT_FAILURE,
+ _("neither filename nor target pid supplied for %s"),
+ type);
if (*fd >= 0)
close(*fd);
@@ -147,8 +148,7 @@ static void continue_as_child(void)
/* Return the child's exit code if possible */
if (WIFEXITED(status)) {
exit(WEXITSTATUS(status));
- }
- else if (WIFSIGNALED(status)) {
+ } else if (WIFSIGNALED(status)) {
kill(getpid(), WTERMSIG(status));
}
exit(EXIT_FAILURE);
@@ -181,15 +181,18 @@ int main(int argc, char *argv[])
textdomain(PACKAGE);
atexit(close_stdout);
- while((c = getopt_long(argc, argv, "hVt:m::u::i::n::p::U::er::w::", longopts, NULL)) != -1) {
- switch(c) {
+ while ((c =
+ getopt_long(argc, argv, "hVt:m::u::i::n::p::U::er::w::",
+ longopts, NULL)) != -1) {
+ switch (c) {
case 'h':
usage(EXIT_SUCCESS);
case 'V':
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 't':
- namespace_target_pid = strtoul_or_err(optarg, _("failed to parse pid"));
+ namespace_target_pid =
+ strtoul_or_err(optarg, _("failed to parse pid"));
break;
case 'm':
open_namespace_fd(CLONE_NEWNS, optarg);
@@ -224,7 +227,7 @@ int main(int argc, char *argv[])
}
}
- if(optind >= argc)
+ if (optind >= argc)
usage(EXIT_FAILURE);
/*
@@ -234,7 +237,8 @@ int main(int argc, char *argv[])
if (nsfile->fd < 0)
continue;
if (setns(nsfile->fd, nsfile->nstype))
- err(EXIT_FAILURE, _("reassociate to namespace '%s' failed"),
+ err(EXIT_FAILURE,
+ _("reassociate to namespace '%s' failed"),
nsfile->name);
close(nsfile->fd);
nsfile->fd = -1;
@@ -244,13 +248,15 @@ int main(int argc, char *argv[])
if (root_fd >= 0 && wd_fd < 0) {
wd_fd = open(".", O_RDONLY);
if (wd_fd < 0)
- err(EXIT_FAILURE, _("cannot open current working directory"));
+ err(EXIT_FAILURE,
+ _("cannot open current working directory"));
}
/* Change the root directory */
if (root_fd >= 0) {
if (fchdir(root_fd) < 0)
- err(EXIT_FAILURE, _("change directory by root file descriptor failed"));
+ err(EXIT_FAILURE,
+ _("change directory by root file descriptor failed"));
if (chroot(".") < 0)
err(EXIT_FAILURE, _("chroot failed"));
@@ -262,7 +268,8 @@ int main(int argc, char *argv[])
/* Change the working directory */
if (wd_fd >= 0) {
if (fchdir(wd_fd) < 0)
- err(EXIT_FAILURE, _("change directory by working directory file descriptor failed"));
+ err(EXIT_FAILURE,
+ _("change directory by working directory file descriptor failed"));
close(wd_fd);
wd_fd = -1;
--
1.8.1.1
next prev parent reply other threads:[~2013-01-20 18:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-20 18:04 [PATCH 0/6] pull: nsenter: trivial adjustments Sami Kerola
2013-01-20 18:04 ` [PATCH 1/6] docs: align nsenter.1 man page with howto-man-page.txt Sami Kerola
2013-01-20 18:04 ` [PATCH 2/6] build-sys: add nsenter to gitignore Sami Kerola
2013-01-20 18:04 ` [PATCH 3/6] nsenter: adjust few error messages Sami Kerola
2013-01-20 18:04 ` [PATCH 4/6] nsenter: fix compiler warning Sami Kerola
2013-01-20 18:04 ` [PATCH 5/6] nsenter: drop core when impossible happens Sami Kerola
2013-01-20 18:04 ` Sami Kerola [this message]
2013-01-25 14:52 ` [PATCH 0/6] pull: nsenter: trivial adjustments Karel Zak
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=1358705096-21092-7-git-send-email-kerolasa@iki.fi \
--to=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox