12 #include <sys/types.h> 25 u64 link_info_size = ((
event ?
event->nr_namespaces : NR_NAMESPACES) *
26 sizeof(
struct perf_ns_link_info));
28 namespaces =
zalloc(
sizeof(
struct namespaces) + link_info_size);
60 if (asprintf(&newns,
"/proc/%d/ns/mnt", nsi->
pid) == -1)
63 if (stat(oldns, &old_stat) < 0)
66 if (stat(newns, &new_stat) < 0)
72 if (old_stat.st_ino != new_stat.st_ino) {
84 f = fopen(spath,
"r");
88 while (getline(&statln, &linesz, f) != -1) {
90 if (strstr(statln,
"Tgid:") != NULL) {
91 nsi->
tgid = (pid_t)strtol(strrchr(statln,
'\t'),
96 if (strstr(statln,
"NStgid:") != NULL) {
97 nsi->
nstgid = (pid_t)strtol(strrchr(statln,
'\t'),
119 nsi = calloc(1,
sizeof(*nsi));
132 refcount_set(&nsi->
refcnt, 1);
142 nnsi = calloc(1,
sizeof(*nnsi));
155 refcount_set(&nnsi->
refcnt, 1);
170 refcount_inc(&nsi->
refcnt);
176 if (nsi && refcount_dec_and_test(&nsi->
refcnt))
199 oldns = open(curpath, O_RDONLY);
207 if (
setns(newns, CLONE_NEWNS) < 0)
223 if (nc == NULL || nc->
oldns == -1 || nc->
newns == -1)
228 if (nc->
oldns > -1) {
233 if (nc->
newns > -1) {
245 rpath = realpath(path, NULL);
struct nsinfo * nsinfo__new(pid_t pid)
int setns(int fd, int nstype)
void nsinfo__mountns_enter(struct nsinfo *nsi, struct nscookie *nc)
void namespaces__free(struct namespaces *namespaces)
char * nsinfo__realpath(const char *path, struct nsinfo *nsi)
struct perf_ns_link_info link_info[]
int nsinfo__init(struct nsinfo *nsi)
struct perf_ns_link_info link_info[]
void nsinfo__mountns_exit(struct nscookie *nc)
struct namespaces * namespaces__new(struct namespaces_event *event)
x86 movsq based memcpy() in arch/x86/lib/memcpy_64.S") MEMCPY_FN(memcpy_erms
struct nsinfo * nsinfo__copy(struct nsinfo *nsi)
struct nsinfo * nsinfo__get(struct nsinfo *nsi)
void nsinfo__delete(struct nsinfo *nsi)
void nsinfo__put(struct nsinfo *nsi)
void static void * zalloc(size_t size)