From owner-svn-src-head@FreeBSD.ORG Wed Jan 22 16:50:19 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2C295911; Wed, 22 Jan 2014 16:50:19 +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 180121B01; Wed, 22 Jan 2014 16:50:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0MGoI7Y029743; Wed, 22 Jan 2014 16:50:18 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0MGoIkK029738; Wed, 22 Jan 2014 16:50:18 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201401221650.s0MGoIkK029738@svn.freebsd.org> From: John Baldwin Date: Wed, 22 Jan 2014 16:50:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r261030 - head/usr.sbin/services_mkdb X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jan 2014 16:50:19 -0000 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 ] []\n" + (void)fprintf(stderr, + "Usage:\t%s [-b | -l] [-q] [-o ] []\n" "\t%s -u []\n", getprogname(), getprogname()); exit(1); }