From owner-svn-src-stable-9@FreeBSD.ORG Tue Mar 11 15:28:42 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D4CC98BE; Tue, 11 Mar 2014 15:28:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id BFB8F366; Tue, 11 Mar 2014 15:28:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2BFSgT8046282; Tue, 11 Mar 2014 15:28:42 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2BFSgCl046280; Tue, 11 Mar 2014 15:28:42 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201403111528.s2BFSgCl046280@svn.freebsd.org> From: John Baldwin Date: Tue, 11 Mar 2014 15:28:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r263028 - in stable: 10/usr.sbin/services_mkdb 9/usr.sbin/services_mkdb X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Mar 2014 15:28:43 -0000 Author: jhb Date: Tue Mar 11 15:28:41 2014 New Revision: 263028 URL: http://svnweb.freebsd.org/changeset/base/263028 Log: MFC 261030: Similar to cap_mkdb(1), add endianness support to services_mkdb(1) to support cross-builds once this is invoked during releases. Modified: stable/9/usr.sbin/services_mkdb/services_mkdb.8 stable/9/usr.sbin/services_mkdb/services_mkdb.c Directory Properties: stable/9/usr.sbin/services_mkdb/ (props changed) Changes in other areas also in this revision: Modified: stable/10/usr.sbin/services_mkdb/extern.h stable/10/usr.sbin/services_mkdb/services_mkdb.8 stable/10/usr.sbin/services_mkdb/services_mkdb.c Directory Properties: stable/10/ (props changed) Modified: stable/9/usr.sbin/services_mkdb/services_mkdb.8 ============================================================================== --- stable/9/usr.sbin/services_mkdb/services_mkdb.8 Tue Mar 11 15:20:47 2014 (r263027) +++ stable/9/usr.sbin/services_mkdb/services_mkdb.8 Tue Mar 11 15:28:41 2014 (r263028) @@ -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: stable/9/usr.sbin/services_mkdb/services_mkdb.c ============================================================================== --- stable/9/usr.sbin/services_mkdb/services_mkdb.c Tue Mar 11 15:20:47 2014 (r263027) +++ stable/9/usr.sbin/services_mkdb/services_mkdb.c Tue Mar 11 15:28:41 2014 (r263028) @@ -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 ] []\n" + (void)fprintf(stderr, + "Usage:\t%s [-b | -l] [-q] [-o ] []\n" "\t%s -u []\n", getprogname(), getprogname()); exit(1); }