svn commit: r184789 - in head: lib/libc/amd64/sys lib/libc/arm/sys lib/libc/i386/sys lib/libc/ia64/sys lib/libc/mips/sys lib/libc/powerpc/sys lib/libc/sparc64/sys sys/amd64/linux32 sys/compat/freeb...

Ed Schouten ed at FreeBSD.org
Sun Nov 9 02:45:14 PST 2008


Author: ed
Date: Sun Nov  9 10:45:13 2008
New Revision: 184789
URL: http://svn.freebsd.org/changeset/base/184789

Log:
  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

Modified:
  head/lib/libc/amd64/sys/Makefile.inc
  head/lib/libc/arm/sys/Makefile.inc
  head/lib/libc/i386/sys/Makefile.inc
  head/lib/libc/ia64/sys/Makefile.inc
  head/lib/libc/mips/sys/Makefile.inc
  head/lib/libc/powerpc/sys/Makefile.inc
  head/lib/libc/sparc64/sys/Makefile.inc
  head/sys/amd64/linux32/syscalls.master
  head/sys/compat/freebsd32/syscalls.master
  head/sys/compat/linux/linux_misc.c
  head/sys/i386/linux/syscalls.master
  head/sys/kern/kern_xxx.c
  head/sys/kern/syscalls.master
  head/sys/sys/priv.h

Modified: head/lib/libc/amd64/sys/Makefile.inc
==============================================================================
--- head/lib/libc/amd64/sys/Makefile.inc	Sun Nov  9 09:24:01 2008	(r184788)
+++ head/lib/libc/amd64/sys/Makefile.inc	Sun Nov  9 10:45:13 2008	(r184789)
@@ -7,8 +7,7 @@ MDASM=	vfork.S brk.S cerror.S exect.S ge
 	reboot.S sbrk.S setlogin.S sigreturn.S
 
 # Don't generate default code for these syscalls:
-NOASM=	break.o exit.o getdomainname.o getlogin.o openbsd_poll.o \
-	setdomainname.o sstk.o uname.o vfork.o yield.o
+NOASM=	break.o exit.o getlogin.o openbsd_poll.o sstk.o vfork.o yield.o
 
 PSEUDO=	_getlogin.o _exit.o
 .if !defined(WITHOUT_SYSCALL_COMPAT)

Modified: head/lib/libc/arm/sys/Makefile.inc
==============================================================================
--- head/lib/libc/arm/sys/Makefile.inc	Sun Nov  9 09:24:01 2008	(r184788)
+++ head/lib/libc/arm/sys/Makefile.inc	Sun Nov  9 10:45:13 2008	(r184789)
@@ -3,8 +3,7 @@
 MDASM= Ovfork.S brk.S cerror.S pipe.S ptrace.S sbrk.S shmat.S sigreturn.S syscall.S
 
 # Don't generate default code for these syscalls:
-NOASM=	break.o exit.o getdomainname.o getlogin.o openbsd_poll.o \
-	setdomainname.o sstk.o uname.o vfork.o yield.o
+NOASM=	break.o exit.o getlogin.o openbsd_poll.o sstk.o vfork.o yield.o
 
 PSEUDO= _exit.o _getlogin.o
 .if !defined(WITHOUT_SYSCALL_COMPAT)

Modified: head/lib/libc/i386/sys/Makefile.inc
==============================================================================
--- head/lib/libc/i386/sys/Makefile.inc	Sun Nov  9 09:24:01 2008	(r184788)
+++ head/lib/libc/i386/sys/Makefile.inc	Sun Nov  9 10:45:13 2008	(r184789)
@@ -12,8 +12,7 @@ MDASM=	Ovfork.S brk.S cerror.S exect.S g
 	reboot.S sbrk.S setlogin.S sigreturn.S syscall.S
 
 # Don't generate default code for these syscalls:
-NOASM=	break.o exit.o getdomainname.o getlogin.o openbsd_poll.o \
-	setdomainname.o sstk.o uname.o vfork.o yield.o
+NOASM=	break.o exit.o getlogin.o openbsd_poll.o sstk.o vfork.o yield.o
 
 PSEUDO=	_getlogin.o _exit.o
 .if !defined(WITHOUT_SYSCALL_COMPAT)

Modified: head/lib/libc/ia64/sys/Makefile.inc
==============================================================================
--- head/lib/libc/ia64/sys/Makefile.inc	Sun Nov  9 09:24:01 2008	(r184788)
+++ head/lib/libc/ia64/sys/Makefile.inc	Sun Nov  9 10:45:13 2008	(r184789)
@@ -4,8 +4,7 @@ MDASM+=	Ovfork.S brk.S cerror.S exect.S 
 	sbrk.S setlogin.S sigreturn.S swapcontext.S
 
 # Don't generate default code for these syscalls:
-NOASM=	break.o exit.o getdomainname.o getlogin.o openbsd_poll.o \
-	setdomainname.o sstk.o uname.o vfork.o yield.o
+NOASM=	break.o exit.o getlogin.o openbsd_poll.o sstk.o vfork.o yield.o
 
 PSEUDO=	_getlogin.o _exit.o
 .if !defined(WITHOUT_SYSCALL_COMPAT)

Modified: head/lib/libc/mips/sys/Makefile.inc
==============================================================================
--- head/lib/libc/mips/sys/Makefile.inc	Sun Nov  9 09:24:01 2008	(r184788)
+++ head/lib/libc/mips/sys/Makefile.inc	Sun Nov  9 10:45:13 2008	(r184789)
@@ -4,9 +4,8 @@ MDASM=  Ovfork.S brk.S cerror.S exect.S 
 	fork.S pipe.S ptrace.S sbrk.S shmat.S syscall.S
 
 # Don't generate default code for these syscalls:
-NOASM=	break.o exit.o ftruncate.o getdomainname.o getlogin.o \
-	lseek.o mmap.o openbsd_poll.o pread.o \
-	pwrite.o setdomainname.o sstk.o truncate.o uname.o vfork.o yield.o
+NOASM=	break.o exit.o ftruncate.o getlogin.o lseek.o mmap.o \
+	openbsd_poll.o pread.o pwrite.o sstk.o truncate.o vfork.o yield.o
 
 PSEUDO= _exit.o _getlogin.o
 .if !defined(WITHOUT_SYSCALL_COMPAT)

Modified: head/lib/libc/powerpc/sys/Makefile.inc
==============================================================================
--- head/lib/libc/powerpc/sys/Makefile.inc	Sun Nov  9 09:24:01 2008	(r184788)
+++ head/lib/libc/powerpc/sys/Makefile.inc	Sun Nov  9 10:45:13 2008	(r184789)
@@ -3,8 +3,7 @@
 MDASM+=	brk.S cerror.S exect.S pipe.S ptrace.S sbrk.S setlogin.S
 
 # Don't generate default code for these syscalls:
-NOASM=	break.o exit.o getdomainname.o getlogin.o openbsd_poll.o \
-	setdomainname.o sstk.o uname.o yield.o
+NOASM=	break.o exit.o getlogin.o openbsd_poll.o sstk.o yield.o
 
 PSEUDO=	_getlogin.o _exit.o
 .if !defined(WITHOUT_SYSCALL_COMPAT)

Modified: head/lib/libc/sparc64/sys/Makefile.inc
==============================================================================
--- head/lib/libc/sparc64/sys/Makefile.inc	Sun Nov  9 09:24:01 2008	(r184788)
+++ head/lib/libc/sparc64/sys/Makefile.inc	Sun Nov  9 10:45:13 2008	(r184789)
@@ -18,8 +18,7 @@ CFLAGS+= -DSUN4V
 MDASM+=	brk.S cerror.S exect.S pipe.S ptrace.S sbrk.S setlogin.S sigaction.S
 
 # Don't generate default code for these syscalls:
-NOASM=	break.o exit.o getdomainname.o getlogin.o openbsd_poll.o \
-	setdomainname.o sstk.o uname.o yield.o
+NOASM=	break.o exit.o getlogin.o openbsd_poll.o sstk.o yield.o
 
 PSEUDO=	_getlogin.o _exit.o
 .if !defined(WITHOUT_SYSCALL_COMPAT)

Modified: head/sys/amd64/linux32/syscalls.master
==============================================================================
--- head/sys/amd64/linux32/syscalls.master	Sun Nov  9 09:24:01 2008	(r184788)
+++ head/sys/amd64/linux32/syscalls.master	Sun Nov  9 10:45:13 2008	(r184789)
@@ -216,7 +216,7 @@
 ; linux uses some strange calling convention here so we have to use the dummy arg
 120	AUE_RFORK	STD	{ int linux_clone(l_int flags, void *stack, \
 				    void *parent_tidptr, int dummy, void * child_tidptr); }
-121	AUE_SYSCTL	NOPROTO	{ int setdomainname(char *name, \
+121	AUE_SYSCTL	STD	{ int linux_setdomainname(char *name, \
 				    int len); }
 122	AUE_NULL	STD	{ int linux_newuname( \
 				    struct l_new_utsname *buf); }

Modified: head/sys/compat/freebsd32/syscalls.master
==============================================================================
--- head/sys/compat/freebsd32/syscalls.master	Sun Nov  9 09:24:01 2008	(r184788)
+++ head/sys/compat/freebsd32/syscalls.master	Sun Nov  9 10:45:13 2008	(r184789)
@@ -295,11 +295,9 @@
 160	AUE_LGETFH	UNIMPL	lgetfh
 161	AUE_NFS_GETFH	NOPROTO	{ int getfh(char *fname, \
 				    struct fhandle *fhp); }
-162	AUE_SYSCTL	NOPROTO	{ int getdomainname(char *domainname, \
-				    int len); }
-163	AUE_SYSCTL	NOPROTO	{ int setdomainname(char *domainname, \
-				    int len); }
-164	AUE_NULL	NOPROTO	{ int uname(struct utsname *name); }
+162	AUE_NULL	OBSOL	getdomainname
+163	AUE_NULL	OBSOL	setdomainname
+164	AUE_NULL	OBSOL	uname
 165	AUE_SYSARCH	NOPROTO	{ int sysarch(int op, char *parms); }
 166	AUE_RTPRIO	NOPROTO	{ int rtprio(int function, pid_t pid, \
 				    struct rtprio *rtp); }

Modified: head/sys/compat/linux/linux_misc.c
==============================================================================
--- head/sys/compat/linux/linux_misc.c	Sun Nov  9 09:24:01 2008	(r184788)
+++ head/sys/compat/linux/linux_misc.c	Sun Nov  9 10:45:13 2008	(r184789)
@@ -1682,6 +1682,7 @@ int
 linux_sethostname(struct thread *td, struct linux_sethostname_args *args)
 {
 	int name[2];
+	int error;
 
 #ifdef DEBUG
 	if (ldebug(sethostname))
@@ -1690,8 +1691,31 @@ linux_sethostname(struct thread *td, str
 
 	name[0] = CTL_KERN;
 	name[1] = KERN_HOSTNAME;
-	return (userland_sysctl(td, name, 2, 0, 0, 0, args->hostname,
-	    args->len, 0, 0));
+	mtx_lock(&Giant);
+	error = userland_sysctl(td, name, 2, 0, 0, 0, args->hostname,
+	    args->len, 0, 0);
+	mtx_unlock(&Giant);
+	return (error);
+}
+
+int
+linux_setdomainname(struct thread *td, struct linux_setdomainname_args *args)
+{
+	int name[2];
+	int error;
+
+#ifdef DEBUG
+	if (ldebug(setdomainname))
+		printf(ARGS(setdomainname, "*, %i"), args->len);
+#endif
+
+	name[0] = CTL_KERN;
+	name[1] = KERN_NISDOMAINNAME;
+	mtx_lock(&Giant);
+	error = userland_sysctl(td, name, 2, 0, 0, 0, args->name,
+	    args->len, 0, 0);
+	mtx_unlock(&Giant);
+	return (error);
 }
 
 int

Modified: head/sys/i386/linux/syscalls.master
==============================================================================
--- head/sys/i386/linux/syscalls.master	Sun Nov  9 09:24:01 2008	(r184788)
+++ head/sys/i386/linux/syscalls.master	Sun Nov  9 10:45:13 2008	(r184789)
@@ -217,7 +217,7 @@
 ; linux uses some strange calling convention here so we have to use the dummy arg
 120	AUE_RFORK	STD	{ int linux_clone(l_int flags, void *stack, \
 				    void *parent_tidptr, int dummy, void * child_tidptr); }
-121	AUE_SYSCTL	NOPROTO { int setdomainname(char *name, \
+121	AUE_SYSCTL	STD	{ int linux_setdomainname(char *name, \
 				    int len); }
 122	AUE_NULL	STD	{ int linux_newuname( \
 				    struct l_new_utsname *buf); }

Modified: head/sys/kern/kern_xxx.c
==============================================================================
--- head/sys/kern/kern_xxx.c	Sun Nov  9 09:24:01 2008	(r184788)
+++ head/sys/kern/kern_xxx.c	Sun Nov  9 10:45:13 2008	(r184789)
@@ -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);
-
-	domainnamelen = strlen(tmpdomainname) + 1;
-	if ((u_int)uap->len > domainnamelen)
-		uap->len = domainnamelen;
-	return (copyout(tmpdomainname, uap->domainname, uap->len));
+	int name[2];
+	int error;
+	size_t len = 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;
-
-	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);
-	}
+	int name[2];
+	int error;
+
+	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 */

Modified: head/sys/kern/syscalls.master
==============================================================================
--- head/sys/kern/syscalls.master	Sun Nov  9 09:24:01 2008	(r184788)
+++ head/sys/kern/syscalls.master	Sun Nov  9 10:45:13 2008	(r184789)
@@ -320,11 +320,11 @@
 				    struct fhandle *fhp); }
 161	AUE_NFS_GETFH	STD	{ int getfh(char *fname, \
 				    struct fhandle *fhp); }
-162	AUE_SYSCTL	STD	{ int getdomainname(char *domainname, \
+162	AUE_SYSCTL	COMPAT4	{ int getdomainname(char *domainname, \
 				    int len); }
-163	AUE_SYSCTL	STD	{ int setdomainname(char *domainname, \
+163	AUE_SYSCTL	COMPAT4	{ int setdomainname(char *domainname, \
 				    int len); }
-164	AUE_NULL	STD	{ int uname(struct utsname *name); }
+164	AUE_NULL	COMPAT4	{ int uname(struct utsname *name); }
 165	AUE_SYSARCH	STD	{ int sysarch(int op, char *parms); }
 166	AUE_RTPRIO	STD	{ int rtprio(int function, pid_t pid, \
 				    struct rtprio *rtp); }

Modified: head/sys/sys/priv.h
==============================================================================
--- head/sys/sys/priv.h	Sun Nov  9 09:24:01 2008	(r184788)
+++ head/sys/sys/priv.h	Sun Nov  9 10:45:13 2008	(r184789)
@@ -84,7 +84,6 @@
 #define	PRIV_CLOCK_SETTIME	17	/* Can call clock_settime. */
 #define	PRIV_SETTIMEOFDAY	18	/* Can call settimeofday. */
 #define	PRIV_SETHOSTID		19	/* Can call sethostid. */
-#define	PRIV_SETDOMAINNAME	20	/* Can call setdomainname. */
 
 /*
  * Audit subsystem privileges.


More information about the svn-src-head mailing list