#define _GNU_SOURCE
#endif
+#include "signal-helper.hpp"
+#include "utils.h"
+
+#include <common/compat/tid.hpp>
+#include <common/macros.hpp>
+
+#include <inttypes.h>
#include <popt.h>
#include <sched.h>
#include <stdarg.h>
#include <sys/types.h>
#include <unistd.h>
-#include <common/compat/tid.h>
-#include <common/macros.h>
-
-#include "signal-helper.h"
-#include "utils.h"
-
#define TRACEPOINT_DEFINE
#include "tp.h"
* but that use a libc that doesn't define its associated clone flag.
*/
#ifndef CLONE_NEWNS
-#define CLONE_NEWNS 0x00020000
+#define CLONE_NEWNS 0x00020000
#endif
#ifndef CLONE_NEWCGROUP
#define CLONE_NEWCGROUP 0x02000000
#endif
#ifndef CLONE_NEWUTS
-#define CLONE_NEWUTS 0x04000000
+#define CLONE_NEWUTS 0x04000000
#endif
#ifndef CLONE_NEWIPC
-#define CLONE_NEWIPC 0x08000000
+#define CLONE_NEWIPC 0x08000000
#endif
#ifndef CLONE_NEWUSER
-#define CLONE_NEWUSER 0x10000000
+#define CLONE_NEWUSER 0x10000000
#endif
#ifndef CLONE_NEWPID
-#define CLONE_NEWPID 0x20000000
+#define CLONE_NEWPID 0x20000000
#endif
#ifndef CLONE_NEWNET
-#define CLONE_NEWNET 0x40000000
+#define CLONE_NEWNET 0x40000000
#endif
#ifndef CLONE_NEWTIME
-#define CLONE_NEWTIME 0x00000080
+#define CLONE_NEWTIME 0x00000080
#endif
static int nr_iter = 100;
static int debug = 0;
-static char *ns_opt = NULL;
-static char *after_unshare_file_path = NULL;
-static char *before_second_event_file_path = NULL;
+static char *ns_opt = nullptr;
+static char *after_unshare_file_path = nullptr;
+static char *before_second_event_file_path = nullptr;
-static
-struct poptOption opts[] = {
+static struct poptOption opts[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
- { "debug", 'd', POPT_ARG_NONE, &debug, 0, "Enable debug output", NULL },
- { "ns", 'n', POPT_ARG_STRING, &ns_opt, 0, "Namespace short identifier", NULL },
- { "iter", 'i', POPT_ARG_INT, &nr_iter, 0, "Number of tracepoint iterations", NULL },
- { "after", 'a', POPT_ARG_STRING, &after_unshare_file_path, 0, "after_unshare_file_path,", NULL },
- { "before", 'b', POPT_ARG_STRING, &before_second_event_file_path, 0, "before_second_event_file_path,", NULL },
- POPT_AUTOHELP
- { NULL, 0, 0, NULL, 0 }
+ { "debug", 'd', POPT_ARG_NONE, &debug, 0, "Enable debug output", nullptr },
+ { "ns", 'n', POPT_ARG_STRING, &ns_opt, 0, "Namespace short identifier", nullptr },
+ { "iter", 'i', POPT_ARG_INT, &nr_iter, 0, "Number of tracepoint iterations", nullptr },
+ { "after",
+ 'a',
+ POPT_ARG_STRING,
+ &after_unshare_file_path,
+ 0,
+ "after_unshare_file_path,",
+ nullptr },
+ { "before",
+ 'b',
+ POPT_ARG_STRING,
+ &before_second_event_file_path,
+ 0,
+ "before_second_event_file_path,",
+ nullptr },
+ POPT_AUTOHELP{ nullptr, 0, 0, nullptr, 0 }
};
-static ATTR_FORMAT_PRINTF(1, 2)
-void debug_printf(const char *format, ...)
+static ATTR_FORMAT_PRINTF(1, 2) void debug_printf(const char *format, ...)
{
va_list args;
va_start(args, format);
/*
* /proc/thread-self was introduced in kernel v3.17
*/
- if (snprintf(proc_ns_path, LTTNG_PROC_NS_PATH_MAX,
- "/proc/thread-self/ns/%s", ns) >= 0) {
+ if (snprintf(proc_ns_path, LTTNG_PROC_NS_PATH_MAX, "/proc/thread-self/ns/%s", ns) >= 0) {
if (stat(proc_ns_path, &sb) == 0) {
*ns_inum = sb.st_ino;
ret = 0;
goto end;
}
- if (snprintf(proc_ns_path, LTTNG_PROC_NS_PATH_MAX,
- "/proc/self/task/%d/%s/net", lttng_gettid(), ns) >= 0) {
+ if (snprintf(proc_ns_path,
+ LTTNG_PROC_NS_PATH_MAX,
+ "/proc/self/task/%d/%s/net",
+ lttng_gettid(),
+ ns) >= 0) {
if (stat(proc_ns_path, &sb) == 0) {
*ns_inum = sb.st_ino;
ret = 0;
ret = get_ns_inum(ns_str, &ns1);
if (ret) {
- debug_printf("Failed to get ns inode number for namespace %s",
- ns_str);
+ debug_printf("Failed to get ns inode number for namespace %s", ns_str);
ret = -1;
goto end;
}
- debug_printf("Initial %s ns inode number: %lu\n", ns_str, ns1);
+ debug_printf("Initial %s ns inode number: %" PRIuMAX "\n", ns_str, (uintmax_t) ns1);
for (i = 0; nr_iter < 0 || i < nr_iter; i++) {
tracepoint(tp, tptest, ns1);
ret = get_ns_inum(ns_str, &ns2);
if (ret) {
- debug_printf("Failed to get ns inode number for namespace %s",
- ns_str);
+ debug_printf("Failed to get ns inode number for namespace %s", ns_str);
ret = -1;
goto end;
}
- debug_printf("Post unshare %s ns inode number: %lu\n", ns_str, ns2);
+ debug_printf("Post unshare %s ns inode number: %" PRIuMAX "\n", ns_str, (uintmax_t) ns2);
/*
* Signal that we emited the first event group and that the
int ret = EXIT_SUCCESS;
poptContext pc;
- pc = poptGetContext(NULL, argc, argv, opts, 0);
+ pc = poptGetContext(nullptr, argc, argv, opts, 0);
poptReadDefaultConfig(pc, 0);
if (argc < 2) {
if (opt < -1) {
/* An error occurred during option processing. */
poptPrintUsage(pc, stderr, 0);
- fprintf(stderr, "%s: %s\n",
- poptBadOption(pc, POPT_BADOPTION_NOALIAS),
- poptStrerror(opt));
+ fprintf(stderr,
+ "%s: %s\n",
+ poptBadOption(pc, POPT_BADOPTION_NOALIAS),
+ poptStrerror(opt));
ret = EXIT_FAILURE;
goto end;
}
- if (ns_opt == NULL) {
+ if (ns_opt == nullptr) {
poptPrintUsage(pc, stderr, 0);
ret = EXIT_FAILURE;
goto end;