* 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. */
| 2171 | * If pdp is not NULL, return with it shared locked. |
| 2172 | */ |
| 2173 | struct pwddesc * |
| 2174 | pdinit(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 | |
| 2199 | static struct filedesc * |
| 2200 | fdhold(struct proc *p) |
no test coverage detected