Deleted Added
full compact
hash_page.c (189291) hash_page.c (190485)
1/*-
2 * Copyright (c) 1990, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Margo Seltzer.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#if defined(LIBC_SCCS) && !defined(lint)
34static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94";
35#endif /* LIBC_SCCS and not lint */
36#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1990, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Margo Seltzer.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#if defined(LIBC_SCCS) && !defined(lint)
34static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94";
35#endif /* LIBC_SCCS and not lint */
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/lib/libc/db/hash/hash_page.c 189291 2009-03-02 23:47:18Z delphij $");
37__FBSDID("$FreeBSD: head/lib/libc/db/hash/hash_page.c 190485 2009-03-28 05:57:27Z delphij $");
38
39/*
40 * PACKAGE: hashing
41 *
42 * DESCRIPTION:
43 * Page manipulation for hashing package.
44 *
45 * ROUTINES:
46 *
47 * External
48 * __get_page
49 * __add_ovflpage
50 * Internal
51 * overflow_page
52 * open_temp
53 */
54
55#include "namespace.h"
38
39/*
40 * PACKAGE: hashing
41 *
42 * DESCRIPTION:
43 * Page manipulation for hashing package.
44 *
45 * ROUTINES:
46 *
47 * External
48 * __get_page
49 * __add_ovflpage
50 * Internal
51 * overflow_page
52 * open_temp
53 */
54
55#include "namespace.h"
56#include <sys/types.h>
56#include <sys/param.h>
57
58#include <errno.h>
59#include <fcntl.h>
60#include <signal.h>
61#include <stdio.h>
62#include <stdlib.h>
63#include <string.h>
64#include <unistd.h>

--- 763 unchanged lines hidden (view full) ---

828 * Returns:
829 * 0 success
830 * -1 failure
831 */
832static int
833open_temp(HTAB *hashp)
834{
835 sigset_t set, oset;
57
58#include <errno.h>
59#include <fcntl.h>
60#include <signal.h>
61#include <stdio.h>
62#include <stdlib.h>
63#include <string.h>
64#include <unistd.h>

--- 763 unchanged lines hidden (view full) ---

828 * Returns:
829 * 0 success
830 * -1 failure
831 */
832static int
833open_temp(HTAB *hashp)
834{
835 sigset_t set, oset;
836 static char namestr[] = "_hashXXXXXX";
836 int len;
837 char *envtmp = NULL;
838 char path[MAXPATHLEN];
837
839
840 if (issetugid() == 0)
841 envtmp = getenv("TMPDIR");
842 len = snprintf(path,
843 sizeof(path), "%s/_hash.XXXXXX", envtmp ? envtmp : "/tmp");
844 if (len < 0 || len >= sizeof(path)) {
845 errno = ENAMETOOLONG;
846 return (-1);
847 }
848
838 /* Block signals; make sure file goes away at process exit. */
839 (void)sigfillset(&set);
840 (void)_sigprocmask(SIG_BLOCK, &set, &oset);
849 /* Block signals; make sure file goes away at process exit. */
850 (void)sigfillset(&set);
851 (void)_sigprocmask(SIG_BLOCK, &set, &oset);
841 if ((hashp->fp = mkstemp(namestr)) != -1) {
842 (void)unlink(namestr);
852 if ((hashp->fp = mkstemp(path)) != -1) {
853 (void)unlink(path);
843 (void)_fcntl(hashp->fp, F_SETFD, 1);
844 }
845 (void)_sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL);
846 return (hashp->fp != -1 ? 0 : -1);
847}
848
849/*
850 * We have to know that the key will fit, but the last entry on the page is

--- 62 unchanged lines hidden ---
854 (void)_fcntl(hashp->fp, F_SETFD, 1);
855 }
856 (void)_sigprocmask(SIG_SETMASK, &oset, (sigset_t *)NULL);
857 return (hashp->fp != -1 ? 0 : -1);
858}
859
860/*
861 * We have to know that the key will fit, but the last entry on the page is

--- 62 unchanged lines hidden ---