Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Jan 2014 16:50:18 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r261030 - head/usr.sbin/services_mkdb
Message-ID:  <201401221650.s0MGoIkK029738@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Wed Jan 22 16:50:18 2014
New Revision: 261030
URL: http://svnweb.freebsd.org/changeset/base/261030

Log:
  Similar to cap_mkdb(1), add endianness support to services_mkdb(1)
  to support cross-builds once this is invoked during releases.

Modified:
  head/usr.sbin/services_mkdb/extern.h
  head/usr.sbin/services_mkdb/services_mkdb.8
  head/usr.sbin/services_mkdb/services_mkdb.c

Modified: head/usr.sbin/services_mkdb/extern.h
==============================================================================
--- head/usr.sbin/services_mkdb/extern.h	Wed Jan 22 15:58:43 2014	(r261029)
+++ head/usr.sbin/services_mkdb/extern.h	Wed Jan 22 16:50:18 2014	(r261030)
@@ -29,6 +29,6 @@
  * $FreeBSD$
  */
 
-extern const HASHINFO hinfo;
+extern HASHINFO hinfo;
 
 void uniq(const char *);

Modified: head/usr.sbin/services_mkdb/services_mkdb.8
==============================================================================
--- head/usr.sbin/services_mkdb/services_mkdb.8	Wed Jan 22 15:58:43 2014	(r261029)
+++ head/usr.sbin/services_mkdb/services_mkdb.8	Wed Jan 22 16:50:18 2014	(r261030)
@@ -37,6 +37,7 @@
 .Nd generate the services database
 .Sh SYNOPSIS
 .Nm
+.Op Fl b | l
 .Op Fl q
 .Op Fl o Ar database
 .Op Ar file
@@ -61,6 +62,10 @@ The file must be in the correct format (
 .Pp
 The options are as follows:
 .Bl -tag -width indent
+.It Fl b
+Use big-endian byte order for database metadata.
+.It Fl l
+Use little-endian byte order for database metadata.
 .It Fl o Ar database
 Put the output databases in the named file.
 .It Fl q
@@ -70,6 +75,13 @@ Print the services file to stdout, omitt
 .El
 .Pp
 The databases are used by the C library services routines (see
+.Pp
+The
+.Fl b
+and
+.Fl l
+flags are mutually exclusive.
+The default byte ordering is the current host order.
 .Xr getservent 3 ) .
 .Sh FILES
 .Bl -tag -width ".Pa /var/db/services.db.tmp" -compact

Modified: head/usr.sbin/services_mkdb/services_mkdb.c
==============================================================================
--- head/usr.sbin/services_mkdb/services_mkdb.c	Wed Jan 22 15:58:43 2014	(r261029)
+++ head/usr.sbin/services_mkdb/services_mkdb.c	Wed Jan 22 16:50:18 2014	(r261030)
@@ -67,7 +67,7 @@ static const char *getprotostr(StringLis
 static const char *mkaliases(StringList *, char *, size_t);
 static void	usage(void);
 
-const HASHINFO hinfo = {
+HASHINFO hinfo = {
 	.bsize = 256,
 	.ffactor = 4,
 	.nelem = 32768,
@@ -87,14 +87,21 @@ main(int argc, char *argv[])
 	int	 warndup = 1;
 	int	 unique = 0;
 	int	 otherflag = 0;
+	int	 byteorder = 0;
 	size_t	 cnt = 0;
 	StringList *sl, ***svc;
 	size_t port, proto;
 
 	setprogname(argv[0]);
 
-	while ((ch = getopt(argc, argv, "qo:u")) != -1)
+	while ((ch = getopt(argc, argv, "blo:qu")) != -1)
 		switch (ch) {
+		case 'b':
+		case 'l':
+			if (byteorder != 0)
+				usage();
+			byteorder = ch == 'b' ? 4321 : 1234;
+			break;
 		case 'q':
 			otherflag = 1;
 			warndup = 0;
@@ -119,6 +126,9 @@ main(int argc, char *argv[])
 	if (argc == 1)
 		fname = argv[0];
 
+	/* Set byte order. */
+	hinfo.lorder = byteorder;
+
 	if (unique)
 		uniq(fname);
 
@@ -423,7 +433,8 @@ out:
 static void
 usage(void)
 {
-	(void)fprintf(stderr, "Usage:\t%s [-q] [-o <db>] [<servicefile>]\n"
+	(void)fprintf(stderr,
+	    "Usage:\t%s [-b | -l] [-q] [-o <db>] [<servicefile>]\n"
 	    "\t%s -u [<servicefile>]\n", getprogname(), getprogname());
 	exit(1);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201401221650.s0MGoIkK029738>