Lines Matching refs:nsi

63 int nsinfo__init(struct nsinfo *nsi)  in nsinfo__init()  argument
79 if (asprintf(&newns, "/proc/%d/ns/mnt", nsi->pid) == -1) in nsinfo__init()
92 nsi->need_setns = true; in nsinfo__init()
93 nsi->mntns_path = newns; in nsinfo__init()
100 if (snprintf(spath, PATH_MAX, "/proc/%d/status", nsi->pid) >= PATH_MAX) in nsinfo__init()
110 nsi->tgid = (pid_t)strtol(strrchr(statln, '\t'), in nsinfo__init()
112 nsi->nstgid = nsi->tgid; in nsinfo__init()
117 nsi->nstgid = (pid_t)strtol(nspid, NULL, 10); in nsinfo__init()
121 nsi->in_pidns = (statln + sizeof("NStgid:") - 1) != nspid; in nsinfo__init()
137 struct nsinfo *nsi; in nsinfo__new() local
142 nsi = calloc(1, sizeof(*nsi)); in nsinfo__new()
143 if (nsi != NULL) { in nsinfo__new()
144 nsi->pid = pid; in nsinfo__new()
145 nsi->tgid = pid; in nsinfo__new()
146 nsi->nstgid = pid; in nsinfo__new()
147 nsi->need_setns = false; in nsinfo__new()
148 nsi->in_pidns = false; in nsinfo__new()
153 if (nsinfo__init(nsi) == -1) in nsinfo__new()
154 nsi->need_setns = false; in nsinfo__new()
156 refcount_set(&nsi->refcnt, 1); in nsinfo__new()
159 return nsi; in nsinfo__new()
162 struct nsinfo *nsinfo__copy(struct nsinfo *nsi) in nsinfo__copy() argument
166 if (nsi == NULL) in nsinfo__copy()
171 nnsi->pid = nsi->pid; in nsinfo__copy()
172 nnsi->tgid = nsi->tgid; in nsinfo__copy()
173 nnsi->nstgid = nsi->nstgid; in nsinfo__copy()
174 nnsi->need_setns = nsi->need_setns; in nsinfo__copy()
175 nnsi->in_pidns = nsi->in_pidns; in nsinfo__copy()
176 if (nsi->mntns_path) { in nsinfo__copy()
177 nnsi->mntns_path = strdup(nsi->mntns_path); in nsinfo__copy()
189 void nsinfo__delete(struct nsinfo *nsi) in nsinfo__delete() argument
191 zfree(&nsi->mntns_path); in nsinfo__delete()
192 free(nsi); in nsinfo__delete()
195 struct nsinfo *nsinfo__get(struct nsinfo *nsi) in nsinfo__get() argument
197 if (nsi) in nsinfo__get()
198 refcount_inc(&nsi->refcnt); in nsinfo__get()
199 return nsi; in nsinfo__get()
202 void nsinfo__put(struct nsinfo *nsi) in nsinfo__put() argument
204 if (nsi && refcount_dec_and_test(&nsi->refcnt)) in nsinfo__put()
205 nsinfo__delete(nsi); in nsinfo__put()
208 void nsinfo__mountns_enter(struct nsinfo *nsi, in nsinfo__mountns_enter() argument
222 if (!nsi || !nsi->need_setns) in nsinfo__mountns_enter()
236 newns = open(nsi->mntns_path, O_RDONLY); in nsinfo__mountns_enter()
279 char *nsinfo__realpath(const char *path, struct nsinfo *nsi) in nsinfo__realpath() argument
284 nsinfo__mountns_enter(nsi, &nsc); in nsinfo__realpath()
291 int nsinfo__stat(const char *filename, struct stat *st, struct nsinfo *nsi) in nsinfo__stat() argument
296 nsinfo__mountns_enter(nsi, &nsc); in nsinfo__stat()