mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 09:10:28 +00:00
swapoff(2): replace special device name argument with a structure
For compatibility, add a placeholder pointer to the start of the added struct swapoff_new_args, and use it to distinguish old vs. new style of syscall invocation. Reviewed by: markj Discussed with: alc Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D33165
This commit is contained in:
parent
6df359449f
commit
a4e4132fa3
|
@ -2491,15 +2491,38 @@ sys_swapoff(struct thread *td, struct swapoff_args *uap)
|
|||
struct vnode *vp;
|
||||
struct nameidata nd;
|
||||
struct swdevt *sp;
|
||||
int error;
|
||||
struct swapoff_new_args sa;
|
||||
int error, probe_byte;
|
||||
|
||||
error = priv_check(td, PRIV_SWAPOFF);
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
/*
|
||||
* Detect old vs. new-style swapoff(2) syscall. The first
|
||||
* pointer in the memory pointed to by uap->name is NULL for
|
||||
* the new variant.
|
||||
*/
|
||||
probe_byte = fubyte(uap->name);
|
||||
switch (probe_byte) {
|
||||
case -1:
|
||||
return (EFAULT);
|
||||
case 0:
|
||||
error = copyin(uap->name, &sa, sizeof(sa));
|
||||
if (error != 0)
|
||||
return (error);
|
||||
if (sa.flags != 0)
|
||||
return (EINVAL);
|
||||
break;
|
||||
default:
|
||||
bzero(&sa, sizeof(sa));
|
||||
sa.name = uap->name;
|
||||
break;
|
||||
}
|
||||
|
||||
sx_xlock(&swdev_syscall_lock);
|
||||
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->name);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, sa.name);
|
||||
error = namei(&nd);
|
||||
if (error)
|
||||
goto done;
|
||||
|
|
|
@ -69,6 +69,14 @@ struct swdevt {
|
|||
#define SW_UNMAPPED 0x01
|
||||
#define SW_CLOSING 0x04
|
||||
|
||||
struct swapoff_new_args {
|
||||
const char *name_old_syscall;
|
||||
const char *name;
|
||||
u_int flags;
|
||||
u_int pad0;
|
||||
uintptr_t pad1[8];
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
extern int swap_pager_avail;
|
||||
|
|
Loading…
Reference in a new issue