Don't refuse to create a hash database on 0 length files. Treat

them as new files the same way that the btree code does.  Note that
we do the fstat() after the open() instead of re-using the previous
result of the stat() to avoid races (we open with O_EXLOCK when we care).
This commit is contained in:
christos 2005-03-29 23:37:15 +00:00
parent 8b0967ff45
commit c4e3c4d493

View File

@ -1,4 +1,4 @@
/* $NetBSD: hash.c,v 1.20 2005/03/06 03:42:14 christos Exp $ */
/* $NetBSD: hash.c,v 1.21 2005/03/29 23:37:15 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)hash.c 8.9 (Berkeley) 6/16/94";
#else
__RCSID("$NetBSD: hash.c,v 1.20 2005/03/06 03:42:14 christos Exp $");
__RCSID("$NetBSD: hash.c,v 1.21 2005/03/29 23:37:15 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -139,6 +139,9 @@ __hash_open(file, flags, mode, info, dflags)
RETURN_ERROR(errno, error0);
if (fcntl(hashp->fp, F_SETFD, FD_CLOEXEC) == -1)
RETURN_ERROR(errno, error1);
if (fstat(hashp->fp, &statbuf) == -1)
RETURN_ERROR(errno, error1);
new_table |= statbuf.st_size == 0;
}
if (new_table) {
if (!(hashp = init_hash(hashp, file, info)))