Date: Sun, 15 Sep 2002 20:00:06 -0700 (PDT) From: ryan beasley <ryanb@goddamnbastard.org> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/36425: bump up SYS_NMLN in sys/utsname.h Message-ID: <200209160300.g8G306u8009377@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/36425; it has been noted by GNATS.
From: ryan beasley <ryanb@goddamnbastard.org>
To: freebsd-gnats-submit@FreeBSD.org,
Matthias Buelow <mkb@reiher.informatik.uni-wuerzburg.de>
Cc:
Subject: Re: kern/36425: bump up SYS_NMLN in sys/utsname.h
Date: Sun, 15 Sep 2002 20:08:13 -0500
--FeAIMMcddNRN4P4/
Content-Type: multipart/mixed; boundary="CGDBiGfvSTbxKZlW"
Content-Disposition: inline
--CGDBiGfvSTbxKZlW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
(Following up as I've seen this PR is still open.)
Not sure if you already caught this, but this was 'fixed' in -CURRENT
quite some time ago. Please refer to PR 4688 and revision 1.8 of
lib/libc/gen/uname.c.
I've generated the following patch that essentially merges the new
behavior into -STABLE; buildworld works flawlessly, and I no longer have
problems w/ truncated hostnames. (-CURRENT __xuname.c:1.9, uname.c:1.9
merge into 4.6.2-p2)
Committers: any chance of a MFC? (I'm assuming it was 'fixed' in
-CURRENT for a reason. <g>)
--=20
ryan beasley <ryanb@goddamnbastard.org>
professional fat bastard http://www.goddamnbastard.org
GPG ID 0x16EFBD48
--CGDBiGfvSTbxKZlW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="uname.patch"
Content-Transfer-Encoding: quoted-printable
Index: lib/libc/gen/Makefile.inc
diff -ruN lib/libc/gen/Makefile.inc.orig lib/libc/gen/Makefile.inc
--- lib/libc/gen/Makefile.inc.orig Sun Sep 15 14:24:21 2002
+++ lib/libc/gen/Makefile.inc Sun Sep 15 14:25:44 2002
@@ -4,7 +4,7 @@
# machine-independent gen sources
.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/gen ${.CURDIR}/../libc/gen
=20
-SRCS+=3D _rand48.c _spinlock_stub.c alarm.c arc4random.c assert.c \
+SRCS+=3D __xuname.c _rand48.c _spinlock_stub.c alarm.c arc4random.c asser=
t.c \
basename.c \
clock.c closedir.c confstr.c \
crypt.c ctermid.c daemon.c devname.c dirname.c disklabel.c \
Index: lib/libc/gen/__xuname.c
diff -ruN lib/libc/gen/__xuname.c.orig lib/libc/gen/__xuname.c
--- lib/libc/gen/__xuname.c.orig Wed Dec 31 18:00:00 1969
+++ lib/libc/gen/__xuname.c Sun Sep 15 14:23:53 2002
@@ -0,0 +1,132 @@
+/*-
+ * Copyright (c) 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP=
OSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENT=
IAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STR=
ICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY W=
AY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+/*static char sccsid[] =3D "From: @(#)uname.c 8.1 (Berkeley) 1/4/94";*/
+#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/__xuname.c,v 1.9 2002/02/01 00:57:29 =
obrien Exp $");
+
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/utsname.h>
+#include <errno.h>
+
+int
+__xuname(int namesize, void *namebuf)
+{
+ int mib[2], rval;
+ size_t len;
+ char *p;
+ int oerrno;
+ struct xutsname {
+ char sysname[namesize]; /* Name of this OS. */
+ char nodename[namesize]; /* Name of this network node. */
+ char release[namesize]; /* Release level. */
+ char version[namesize]; /* Version level. */
+ char machine[namesize]; /* Hardware type. */
+ } *name;
+
+ name =3D (struct xutsname *)namebuf;
+ rval =3D 0;
+
+ mib[0] =3D CTL_KERN;
+ mib[1] =3D KERN_OSTYPE;
+ len =3D sizeof(name->sysname);
+ oerrno =3D errno;
+ if (sysctl(mib, 2, &name->sysname, &len, NULL, 0) =3D=3D -1) {
+ if(errno =3D=3D ENOMEM)
+ errno =3D oerrno;
+ else
+ rval =3D -1;
+ }
+ name->sysname[sizeof(name->sysname) - 1] =3D '\0';
+
+ mib[0] =3D CTL_KERN;
+ mib[1] =3D KERN_HOSTNAME;
+ len =3D sizeof(name->nodename);
+ oerrno =3D errno;
+ if (sysctl(mib, 2, &name->nodename, &len, NULL, 0) =3D=3D -1) {
+ if(errno =3D=3D ENOMEM)
+ errno =3D oerrno;
+ else
+ rval =3D -1;
+ }
+ name->nodename[sizeof(name->nodename) - 1] =3D '\0';
+
+ mib[0] =3D CTL_KERN;
+ mib[1] =3D KERN_OSRELEASE;
+ len =3D sizeof(name->release);
+ oerrno =3D errno;
+ if (sysctl(mib, 2, &name->release, &len, NULL, 0) =3D=3D -1) {
+ if(errno =3D=3D ENOMEM)
+ errno =3D oerrno;
+ else
+ rval =3D -1;
+ }
+ name->release[sizeof(name->release) - 1] =3D '\0';
+
+ /* The version may have newlines in it, turn them into spaces. */
+ mib[0] =3D CTL_KERN;
+ mib[1] =3D KERN_VERSION;
+ len =3D sizeof(name->version);
+ oerrno =3D errno;
+ if (sysctl(mib, 2, &name->version, &len, NULL, 0) =3D=3D -1) {
+ if (errno =3D=3D ENOMEM)
+ errno =3D oerrno;
+ else
+ rval =3D -1;
+ }
+ name->version[sizeof(name->version) - 1] =3D '\0';
+ for (p =3D name->version; len--; ++p) {
+ if (*p =3D=3D '\n' || *p =3D=3D '\t') {
+ if (len > 1)
+ *p =3D ' ';
+ else
+ *p =3D '\0';
+ }
+ }
+
+ mib[0] =3D CTL_HW;
+ mib[1] =3D HW_MACHINE;
+ len =3D sizeof(name->machine);
+ oerrno =3D errno;
+ if (sysctl(mib, 2, &name->machine, &len, NULL, 0) =3D=3D -1) {
+ if (errno =3D=3D ENOMEM)
+ errno =3D oerrno;
+ else
+ rval =3D -1;
+ }
+ name->machine[sizeof(name->machine) - 1] =3D '\0';
+ return (rval);
+}
Index: lib/libc/gen/uname.c
diff -ruN lib/libc/gen/uname.c.orig lib/libc/gen/uname.c
--- lib/libc/gen/uname.c.orig Sun Sep 15 14:23:12 2002
+++ lib/libc/gen/uname.c Sun Sep 15 14:23:26 2002
@@ -32,94 +32,20 @@
*/
=20
#if defined(LIBC_SCCS) && !defined(lint)
-/*static char sccsid[] =3D "From: @(#)uname.c 8.1 (Berkeley) 1/4/94";*/
-static const char rcsid[] =3D
- "$FreeBSD: src/lib/libc/gen/uname.c,v 1.7 1999/08/27 23:59:06 peter Exp =
$";
+static char sccsid[] =3D "From: @(#)uname.c 8.1 (Berkeley) 1/4/94";
#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: src/lib/libc/gen/uname.c,v 1.9 2002/02/01 00:57:29 obr=
ien Exp $");
=20
+#define uname wrapped_uname
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/utsname.h>
#include <errno.h>
+#undef uname
=20
int
-uname(name)
- struct utsname *name;
+uname(struct utsname *name)
{
- int mib[2], rval;
- size_t len;
- char *p;
- int oerrno;
-
- rval =3D 0;
-
- mib[0] =3D CTL_KERN;
- mib[1] =3D KERN_OSTYPE;
- len =3D sizeof(name->sysname);
- oerrno =3D errno;
- if (sysctl(mib, 2, &name->sysname, &len, NULL, 0) =3D=3D -1) {
- if(errno =3D=3D ENOMEM)
- errno =3D oerrno;
- else
- rval =3D -1;
- }
- name->sysname[sizeof(name->sysname) - 1] =3D '\0';
-
- mib[0] =3D CTL_KERN;
- mib[1] =3D KERN_HOSTNAME;
- len =3D sizeof(name->nodename);
- oerrno =3D errno;
- if (sysctl(mib, 2, &name->nodename, &len, NULL, 0) =3D=3D -1) {
- if(errno =3D=3D ENOMEM)
- errno =3D oerrno;
- else
- rval =3D -1;
- }
- name->nodename[sizeof(name->nodename) - 1] =3D '\0';
-
- mib[0] =3D CTL_KERN;
- mib[1] =3D KERN_OSRELEASE;
- len =3D sizeof(name->release);
- oerrno =3D errno;
- if (sysctl(mib, 2, &name->release, &len, NULL, 0) =3D=3D -1) {
- if(errno =3D=3D ENOMEM)
- errno =3D oerrno;
- else
- rval =3D -1;
- }
- name->release[sizeof(name->release) - 1] =3D '\0';
-
- /* The version may have newlines in it, turn them into spaces. */
- mib[0] =3D CTL_KERN;
- mib[1] =3D KERN_VERSION;
- len =3D sizeof(name->version);
- oerrno =3D errno;
- if (sysctl(mib, 2, &name->version, &len, NULL, 0) =3D=3D -1) {
- if (errno =3D=3D ENOMEM)
- errno =3D oerrno;
- else
- rval =3D -1;
- }
- name->version[sizeof(name->version) - 1] =3D '\0';
- for (p =3D name->version; len--; ++p) {
- if (*p =3D=3D '\n' || *p =3D=3D '\t') {
- if (len > 1)
- *p =3D ' ';
- else
- *p =3D '\0';
- }
- }
-
- mib[0] =3D CTL_HW;
- mib[1] =3D HW_MACHINE;
- len =3D sizeof(name->machine);
- oerrno =3D errno;
- if (sysctl(mib, 2, &name->machine, &len, NULL, 0) =3D=3D -1) {
- if (errno =3D=3D ENOMEM)
- errno =3D oerrno;
- else
- rval =3D -1;
- }
- name->machine[sizeof(name->machine) - 1] =3D '\0';
- return (rval);
+ return __xuname(32, name);
}
Index: sys/sys/utsname.h
diff -ruN sys/sys/utsname.h.orig sys/sys/utsname.h
--- sys/sys/utsname.h.orig Sun Sep 15 14:22:32 2002
+++ sys/sys/utsname.h Sun Sep 15 14:22:53 2002
@@ -37,10 +37,17 @@
* $FreeBSD: src/sys/sys/utsname.h,v 1.7 1999/12/29 04:24:49 peter Exp $
*/
=20
+
#ifndef _SYS_UTSNAME_H
#define _SYS_UTSNAME_H
=20
-#define SYS_NMLN 32
+#ifdef _KERNEL
+#define SYS_NMLN 32 /* uname(2) for the FreeBSD 1.1 ABI. */
+#endif
+
+#ifndef SYS_NMLN
+#define SYS_NMLN 256 /* User can override. */
+#endif
=20
struct utsname {
char sysname[SYS_NMLN]; /* Name of this OS. */
@@ -50,20 +57,18 @@
char machine[SYS_NMLN]; /* Hardware type. */
};
=20
-
#include <sys/cdefs.h>
=20
-
#ifndef _KERNEL
-#ifdef __STDC__
__BEGIN_DECLS
-int uname __P((struct utsname *));
+int __xuname(int, void *); /* Variable record size. */
__END_DECLS
-#else
-extern int uname();
-#endif
-#else
-extern struct utsname utsname;
+
+static __inline int
+uname(struct utsname *name)
+{
+ return __xuname(SYS_NMLN, (void *)name);
+}
#endif /* _KERNEL */
=20
#endif /* !_SYS_UTSNAME_H */
--CGDBiGfvSTbxKZlW--
--FeAIMMcddNRN4P4/
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)
iD8DBQE9hS79skfdOxbvvUgRAsxfAJ9cfKOyktlGK0DCc26wYOfCeg6iwQCffEGg
V/HfpV4vWyHEd8BHkXJiEbQ=
=sB04
-----END PGP SIGNATURE-----
--FeAIMMcddNRN4P4/--
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209160300.g8G306u8009377>
