* MPSAFE */ ARGSUSED */
| 2442 | */ |
| 2443 | /* ARGSUSED */ |
| 2444 | int |
| 2445 | sys_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); |
| 2477 | done: |
| 2478 | sx_xunlock(&swdev_syscall_lock); |
| 2479 | return (error); |
| 2480 | } |
| 2481 | |
| 2482 | static int |
| 2483 | swapoff_one(struct swdevt *sp, struct ucred *cred) |
nothing calls this directly
no test coverage detected