.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | | - * This program is free software; you can redistribute it and/or modify |
---|
3 | | - * it under the terms of the GNU General Public License, version 2, as |
---|
4 | | - * published by the Free Software Foundation. |
---|
5 | 3 | * |
---|
6 | 4 | * Copyright (C) 2017 Hari Bathini, IBM Corporation |
---|
7 | 5 | */ |
---|
8 | 6 | |
---|
9 | 7 | #include "namespaces.h" |
---|
10 | | -#include "util.h" |
---|
11 | 8 | #include "event.h" |
---|
| 9 | +#include "get_current_dir_name.h" |
---|
12 | 10 | #include <sys/types.h> |
---|
13 | 11 | #include <sys/stat.h> |
---|
14 | 12 | #include <fcntl.h> |
---|
.. | .. |
---|
19 | 17 | #include <string.h> |
---|
20 | 18 | #include <unistd.h> |
---|
21 | 19 | #include <asm/bug.h> |
---|
| 20 | +#include <linux/kernel.h> |
---|
| 21 | +#include <linux/zalloc.h> |
---|
22 | 22 | |
---|
23 | | -struct namespaces *namespaces__new(struct namespaces_event *event) |
---|
| 23 | +static const char *perf_ns__names[] = { |
---|
| 24 | + [NET_NS_INDEX] = "net", |
---|
| 25 | + [UTS_NS_INDEX] = "uts", |
---|
| 26 | + [IPC_NS_INDEX] = "ipc", |
---|
| 27 | + [PID_NS_INDEX] = "pid", |
---|
| 28 | + [USER_NS_INDEX] = "user", |
---|
| 29 | + [MNT_NS_INDEX] = "mnt", |
---|
| 30 | + [CGROUP_NS_INDEX] = "cgroup", |
---|
| 31 | +}; |
---|
| 32 | + |
---|
| 33 | +const char *perf_ns__name(unsigned int id) |
---|
| 34 | +{ |
---|
| 35 | + if (id >= ARRAY_SIZE(perf_ns__names)) |
---|
| 36 | + return "UNKNOWN"; |
---|
| 37 | + return perf_ns__names[id]; |
---|
| 38 | +} |
---|
| 39 | + |
---|
| 40 | +struct namespaces *namespaces__new(struct perf_record_namespaces *event) |
---|
24 | 41 | { |
---|
25 | 42 | struct namespaces *namespaces; |
---|
26 | 43 | u64 link_info_size = ((event ? event->nr_namespaces : NR_NAMESPACES) * |
---|