Date: Tue, 2 Dec 2014 08:13:19 -0800 From: Garrett Cooper <yaneurabeya@gmail.com> To: Benjamin Kaduk <kaduk@MIT.EDU> Cc: "freebsd-arch@freebsd.org" <arch@FreeBSD.org> Subject: Re: Disparity between /etc/services and /var/db/services.db Message-ID: <556364B6-EB7C-421F-B2FB-64A170611A56@gmail.com> In-Reply-To: <alpine.GSO.1.10.1412011428160.23489@multics.mit.edu> References: <6F3959BB-3B71-4515-B7BD-C1A640E8327A@gmail.com> <alpine.GSO.1.10.1412011428160.23489@multics.mit.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Dec 1, 2014, at 11:28, Benjamin Kaduk <kaduk@MIT.EDU> wrote:
> On Mon, 1 Dec 2014, Garrett Cooper wrote:
>
>> $ ls -l /scratch/2/etc/services /scratch/2/var/db/services.db
>> -rw-r--r-- 1 ngie wheel 86802 Nov 27 02:23 /scratch/2/etc/services
>> -rw-r--r-- 1 ngie wheel 2097920 Nov 27 02:23 /scratch/2/var/db/services.db
>
> One's a text file and the other a Berkeley DB file ... I wouldn't expect
> them to be the same size.
Shoot. I didn’t mean for this message to get sent out without a lot of context. For that I apologize...
Basically what I was going to comment on was the fact that the .db file was so large, and by adjusting the number of entries I was able to reduce the size of the file by 4 (it’s bloated by a couple thousand):
From usr.sbin/services_mkdb/services_mkdb.c:
70 HASHINFO hinfo = {
71 .bsize = 256,
72 .ffactor = 4,
73 .nelem = 32768,
74 .cachesize = 1024,
75 .hash = NULL,
76 .lorder = 0
77 };
There are a lot less items in the /etc/services file than 32k:
$ cat count_servents.c
#include <netdb.h>
#include <stdio.h>
int
main(void)
{
int i;
for (i = 0; getservent() != NULL; i++) ;
printf("Number of entries: %d\n", i);
return 0;
}
$ ~/count_servents
Number of entries: 2358
$
In the upstream [IANA] /etc/services file, there’s only 1k more or so.
I would understand if the database was trying to fill the service number range, but 32k != INT_MAX:
struct servent {
char *s_name; /* official name of service */
char **s_aliases; /* alias list */
int s_port; /* port service resides at */
char *s_proto; /* protocol to use */
};
Is there a reason why this? “Upstream” (NetBSD) doesn’t seem to comment much on this either…
Thanks!
PS I just found this thread by bapt from last year that comments about this issue from a different bend: https://lists.freebsd.org/pipermail/freebsd-hackers/2013-October/043661.html
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - https://gpgtools.org
iQEcBAEBCgAGBQJUfeUfAAoJEMZr5QU6S73eCPcIAJH0uawSZaPHDX+mUY+yRT+S
83KX9oYlY3raDPw0Oy7Zih2CsfAj7TXAmVf7WaKnWusLQ8kW8Flilk22fZ32dOxO
60jdbaGM99pO0Fl3BorEg3hzXj/MCa4mb/qNtFM5unu+C+ZXjz7FN5kP+2WmOumB
eaXIh0vtQsqWz5GXzi+pLPbOsn3ixXJN+fl8BY2cBh1ZeMosJzk/rweVduswHox2
7ItBqP8cBNaiOgbhMGLXx6iY2+YjQ2dOAQZj/2FpFD1/Mlk6q1sETcEI/yKqYNky
ucocpotAjufGXLdYba+Y69RLcewacegIVDXRsOkjCFxLqSiMX/V0uc7g8YnRgts=
=vgRZ
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?556364B6-EB7C-421F-B2FB-64A170611A56>
