Lines Matching refs:nsi
45 int nsinfo__init(struct nsinfo *nsi) in nsinfo__init() argument
60 if (asprintf(&newns, "/proc/%d/ns/mnt", nsi->pid) == -1) in nsinfo__init()
73 nsi->need_setns = true; in nsinfo__init()
74 nsi->mntns_path = newns; in nsinfo__init()
81 if (snprintf(spath, PATH_MAX, "/proc/%d/status", nsi->pid) >= PATH_MAX) in nsinfo__init()
91 nsi->tgid = (pid_t)strtol(strrchr(statln, '\t'), in nsinfo__init()
93 nsi->nstgid = nsi->tgid; in nsinfo__init()
97 nsi->nstgid = (pid_t)strtol(strrchr(statln, '\t'), in nsinfo__init()
114 struct nsinfo *nsi; in nsinfo__new() local
119 nsi = calloc(1, sizeof(*nsi)); in nsinfo__new()
120 if (nsi != NULL) { in nsinfo__new()
121 nsi->pid = pid; in nsinfo__new()
122 nsi->tgid = pid; in nsinfo__new()
123 nsi->nstgid = pid; in nsinfo__new()
124 nsi->need_setns = false; in nsinfo__new()
129 if (nsinfo__init(nsi) == -1) in nsinfo__new()
130 nsi->need_setns = false; in nsinfo__new()
132 refcount_set(&nsi->refcnt, 1); in nsinfo__new()
135 return nsi; in nsinfo__new()
138 struct nsinfo *nsinfo__copy(struct nsinfo *nsi) in nsinfo__copy() argument
142 if (nsi == NULL) in nsinfo__copy()
147 nnsi->pid = nsi->pid; in nsinfo__copy()
148 nnsi->tgid = nsi->tgid; in nsinfo__copy()
149 nnsi->nstgid = nsi->nstgid; in nsinfo__copy()
150 nnsi->need_setns = nsi->need_setns; in nsinfo__copy()
151 if (nsi->mntns_path) { in nsinfo__copy()
152 nnsi->mntns_path = strdup(nsi->mntns_path); in nsinfo__copy()
164 void nsinfo__delete(struct nsinfo *nsi) in nsinfo__delete() argument
166 zfree(&nsi->mntns_path); in nsinfo__delete()
167 free(nsi); in nsinfo__delete()
170 struct nsinfo *nsinfo__get(struct nsinfo *nsi) in nsinfo__get() argument
172 if (nsi) in nsinfo__get()
173 refcount_inc(&nsi->refcnt); in nsinfo__get()
174 return nsi; in nsinfo__get()
177 void nsinfo__put(struct nsinfo *nsi) in nsinfo__put() argument
179 if (nsi && refcount_dec_and_test(&nsi->refcnt)) in nsinfo__put()
180 nsinfo__delete(nsi); in nsinfo__put()
183 void nsinfo__mountns_enter(struct nsinfo *nsi, in nsinfo__mountns_enter() argument
196 if (!nsi || !nsi->need_setns) in nsinfo__mountns_enter()
206 newns = open(nsi->mntns_path, O_RDONLY); in nsinfo__mountns_enter()
242 char *nsinfo__realpath(const char *path, struct nsinfo *nsi) in nsinfo__realpath() argument
247 nsinfo__mountns_enter(nsi, &nsc); in nsinfo__realpath()