The following diff adds support for sysconf(3) for the variable
_SC_HOST_NAME_MAX.

Based on bits from FreeBSD/NetBSD.

Run into this used by a few ports.

I took out the chunk with the minor bump since I heard there is
a major bump coming up.


Index: sys/sys/unistd.h
===================================================================
RCS file: /cvs/src/sys/sys/unistd.h,v
retrieving revision 1.17
diff -N -u -p sys/sys/unistd.h
--- sys/sys/unistd.h    15 Jan 2010 10:17:48 -0000      1.17
+++ sys/sys/unistd.h    25 Jun 2010 01:20:23 -0000
@@ -119,6 +119,7 @@
 #define        _SC_XOPEN_SHM           30
 #define        _SC_SEM_NSEMS_MAX       31
 #define        _SC_SEM_VALUE_MAX       32
+#define        _SC_HOST_NAME_MAX       33
 
 /* P1003.1c */
 #define _SC_GETGR_R_SIZE_MAX   100
Index: lib/libc/gen/sysconf.3
===================================================================
RCS file: /home/cvs/src/lib/libc/gen/sysconf.3,v
retrieving revision 1.27
diff -u -p -r1.27 sysconf.3
--- lib/libc/gen/sysconf.3      22 Feb 2010 17:54:52 -0000      1.27
+++ lib/libc/gen/sysconf.3      25 Jun 2010 01:19:12 -0000
@@ -172,6 +172,8 @@ The level of support for thread-safe (re
 The number of processors configured.
 .It Li _SC_NPROCESSORS_ONLN
 The number of processors online (capable of running processes).
+.It Li _SC_HOST_NAME_MAX
+The maximum size of a hostname, not counting NULL.
 .El
 .Sh RETURN VALUES
 If the call to
Index: lib/libc/gen/sysconf.c
===================================================================
RCS file: /home/cvs/src/lib/libc/gen/sysconf.c,v
retrieving revision 1.11
diff -u -p -r1.11 sysconf.c
--- lib/libc/gen/sysconf.c      15 Jan 2010 08:35:47 -0000      1.11
+++ lib/libc/gen/sysconf.c      25 Jun 2010 01:17:54 -0000
@@ -214,6 +214,10 @@ yesno:             if (sysctl(mib, namelen, &value,
                namelen = 3;
                break;
 
+/* Unsorted */
+       case _SC_HOST_NAME_MAX:
+               return (MAXHOSTNAMELEN - 1); /* does not include \0 */
+
 /* Extensions */
        case _SC_PHYS_PAGES:
        {

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Reply via email to