MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pdinit

Function pdinit

freebsd/kern/kern_descrip.c:2173–2197  ·  view source on GitHub ↗

* Build a pwddesc structure from another. * Copy the current, root, and jail root vnode references. * * If pdp is not NULL, return with it shared locked. */

Source from the content-addressed store, hash-verified

2171 * If pdp is not NULL, return with it shared locked.
2172 */
2173struct pwddesc *
2174pdinit(struct pwddesc *pdp, bool keeplock)
2175{
2176 struct pwddesc *newpdp;
2177 struct pwd *newpwd;
2178
2179 newpdp = malloc(sizeof(*newpdp), M_PWDDESC, M_WAITOK | M_ZERO);
2180
2181 PWDDESC_LOCK_INIT(newpdp);
2182 refcount_init(&newpdp->pd_refcount, 1);
2183 newpdp->pd_cmask = CMASK;
2184
2185 if (pdp == NULL) {
2186 newpwd = pwd_alloc();
2187 smr_serialized_store(&newpdp->pd_pwd, newpwd, true);
2188 return (newpdp);
2189 }
2190
2191 PWDDESC_XLOCK(pdp);
2192 newpwd = pwd_hold_pwddesc(pdp);
2193 smr_serialized_store(&newpdp->pd_pwd, newpwd, true);
2194 if (!keeplock)
2195 PWDDESC_XUNLOCK(pdp);
2196 return (newpdp);
2197}
2198
2199static struct filedesc *
2200fdhold(struct proc *p)

Callers 4

fork_norfprocFunction · 0.85
do_forkFunction · 0.85
pdcopyFunction · 0.85
proc0_initFunction · 0.85

Calls 4

mallocFunction · 0.85
refcount_initFunction · 0.85
pwd_allocFunction · 0.85
pwd_hold_pwddescFunction · 0.85

Tested by

no test coverage detected