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

Function sys_swapoff

freebsd/vm/swap_pager.c:2444–2480  ·  view source on GitHub ↗

* MPSAFE */ ARGSUSED */

Source from the content-addressed store, hash-verified

2442 */
2443/* ARGSUSED */
2444int
2445sys_swapoff(struct thread *td, struct swapoff_args *uap)
2446{
2447 struct vnode *vp;
2448 struct nameidata nd;
2449 struct swdevt *sp;
2450 int error;
2451
2452 error = priv_check(td, PRIV_SWAPOFF);
2453 if (error)
2454 return (error);
2455
2456 sx_xlock(&swdev_syscall_lock);
2457
2458 NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->name,
2459 td);
2460 error = namei(&nd);
2461 if (error)
2462 goto done;
2463 NDFREE(&nd, NDF_ONLY_PNBUF);
2464 vp = nd.ni_vp;
2465
2466 mtx_lock(&sw_dev_mtx);
2467 TAILQ_FOREACH(sp, &swtailq, sw_list) {
2468 if (sp->sw_vp == vp)
2469 break;
2470 }
2471 mtx_unlock(&sw_dev_mtx);
2472 if (sp == NULL) {
2473 error = EINVAL;
2474 goto done;
2475 }
2476 error = swapoff_one(sp, td->td_ucred);
2477done:
2478 sx_xunlock(&swdev_syscall_lock);
2479 return (error);
2480}
2481
2482static int
2483swapoff_one(struct swdevt *sp, struct ucred *cred)

Callers

nothing calls this directly

Calls 6

nameiFunction · 0.85
NDFREEFunction · 0.85
swapoff_oneFunction · 0.85
priv_checkFunction · 0.50
mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50

Tested by

no test coverage detected