summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pwd_mkdb
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pwd_mkdb')
-rw-r--r--usr.sbin/pwd_mkdb/pwd_mkdb.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c
index 35648a44721..37bc4c829cc 100644
--- a/usr.sbin/pwd_mkdb/pwd_mkdb.c
+++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pwd_mkdb.c,v 1.53 2015/11/05 15:10:11 semarie Exp $ */
+/* $OpenBSD: pwd_mkdb.c,v 1.54 2018/09/18 03:05:42 millert Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -188,8 +188,13 @@ main(int argc, char **argv)
/* Tweak openinfo values for large passwd files. */
if (st.st_size > (off_t)100*1024)
openinfo.cachesize = MINIMUM(st.st_size * 20, (off_t)12*1024*1024);
- if (st.st_size / 128 > openinfo.nelem)
- openinfo.nelem = st.st_size / 128;
+ /* Estimate number of elements based on a 128-byte average entry. */
+ if (st.st_size / 128 * 3 > openinfo.nelem)
+ openinfo.nelem = st.st_size / 128 * 3;
+
+ /* Use optimal filesystem block size. */
+ if (st.st_blksize > openinfo.bsize)
+ openinfo.bsize = st.st_blksize;
/* If only updating a single record, stash the old uid */
if (username) {