diff options
author | ed <ed@FreeBSD.org> | 2008-11-09 10:45:13 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2008-11-09 10:45:13 +0000 |
commit | 9d3703b8426a4dbb7eb7244d73de96428caf1532 (patch) | |
tree | 54928970669608762abe861909dd03f729e065cb /sys/kern/kern_xxx.c | |
parent | 43e6672f4c8f60d63328221a5abc0cc13663d14f (diff) | |
download | FreeBSD-src-9d3703b8426a4dbb7eb7244d73de96428caf1532.zip FreeBSD-src-9d3703b8426a4dbb7eb7244d73de96428caf1532.tar.gz |
Mark uname(), getdomainname() and setdomainname() with COMPAT_FREEBSD4.
Looking at our source code history, it seems the uname(),
getdomainname() and setdomainname() system calls got deprecated
somewhere after FreeBSD 1.1, but they have never been phased out
properly. Because we don't have a COMPAT_FREEBSD1, just use
COMPAT_FREEBSD4.
Also fix the Linuxolator to build without the setdomainname() routine by
just making it call userland_sysctl on kern.domainname. Also replace the
setdomainname()'s implementation to use this approach, because we're
duplicating code with sysctl_domainname().
I wasn't able to keep these three routines working in our
COMPAT_FREEBSD32, because that would require yet another keyword for
syscalls.master (COMPAT4+NOPROTO). Because this routine is probably
unused already, this won't be a problem in practice. If it turns out to
be a problem, we'll just restore this functionality.
Reviewed by: rdivacky, kib
Diffstat (limited to 'sys/kern/kern_xxx.c')
-rw-r--r-- | sys/kern/kern_xxx.c | 63 |
1 files changed, 26 insertions, 37 deletions
diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c index aba4bbc..b894ae6 100644 --- a/sys/kern/kern_xxx.c +++ b/sys/kern/kern_xxx.c @@ -148,8 +148,9 @@ oquota(td, uap) } #endif /* COMPAT_43 */ +#ifdef COMPAT_FREEBSD4 /* - * This is the FreeBSD-1.1 compatable uname(2) interface. These days it is + * This is the FreeBSD-1.1 compatible uname(2) interface. These days it is * done in libc as a wrapper around a bunch of sysctl's. This must maintain * the old 1.1 binary ABI. */ @@ -163,9 +164,7 @@ struct uname_args { #endif /* ARGSUSED */ int -uname(td, uap) - struct thread *td; - struct uname_args *uap; +freebsd4_uname(struct thread *td, struct freebsd4_uname_args *uap) { int name[2], error; size_t len; @@ -242,22 +241,20 @@ struct getdomainname_args { #endif /* ARGSUSED */ int -getdomainname(td, uap) - struct thread *td; - struct getdomainname_args *uap; +freebsd4_getdomainname(struct thread *td, + struct freebsd4_getdomainname_args *uap) { - INIT_VPROCG(TD_TO_VPROCG(td)); - char tmpdomainname[MAXHOSTNAMELEN]; - int domainnamelen; - - mtx_lock(&hostname_mtx); - bcopy(V_domainname, tmpdomainname, sizeof(tmpdomainname)); - mtx_unlock(&hostname_mtx); + int name[2]; + int error; + size_t len = uap->len; - domainnamelen = strlen(tmpdomainname) + 1; - if ((u_int)uap->len > domainnamelen) - uap->len = domainnamelen; - return (copyout(tmpdomainname, uap->domainname, uap->len)); + name[0] = CTL_KERN; + name[1] = KERN_NISDOMAINNAME; + mtx_lock(&Giant); + error = userland_sysctl(td, name, 2, uap->domainname, &len, + 1, 0, 0, 0, 0); + mtx_unlock(&Giant); + return(error); } #ifndef _SYS_SYSPROTO_H_ @@ -268,26 +265,18 @@ struct setdomainname_args { #endif /* ARGSUSED */ int -setdomainname(td, uap) - struct thread *td; - struct setdomainname_args *uap; +freebsd4_setdomainname(struct thread *td, + struct freebsd4_setdomainname_args *uap) { - INIT_VPROCG(TD_TO_VPROCG(td)); - char tmpdomainname[MAXHOSTNAMELEN]; - int error, domainnamelen; + int name[2]; + int error; - error = priv_check(td, PRIV_SETDOMAINNAME); - if (error) - return (error); - if ((u_int)uap->len > sizeof(tmpdomainname) - 1) - return (EINVAL); - domainnamelen = uap->len; - error = copyin(uap->domainname, tmpdomainname, uap->len); - if (error == 0) { - tmpdomainname[domainnamelen] = 0; - mtx_lock(&hostname_mtx); - bcopy(tmpdomainname, V_domainname, sizeof(V_domainname)); - mtx_unlock(&hostname_mtx); - } + name[0] = CTL_KERN; + name[1] = KERN_NISDOMAINNAME; + mtx_lock(&Giant); + error = userland_sysctl(td, name, 2, 0, 0, 0, uap->domainname, + uap->len, 0, 0); + mtx_unlock(&Giant); return (error); } +#endif /* COMPAT_FREEBSD4 */ |