From owner-freebsd-bugs Tue Nov 17 06:39:59 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id GAA19921 for freebsd-bugs-outgoing; Tue, 17 Nov 1998 06:39:59 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id GAA19914 for ; Tue, 17 Nov 1998 06:39:58 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id GAA28884; Tue, 17 Nov 1998 06:40:02 -0800 (PST) Received: from romberg.math.ntnu.no (romberg.math.ntnu.no [129.241.15.150]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id GAA18630 for ; Tue, 17 Nov 1998 06:31:17 -0800 (PST) (envelope-from arnej@math.ntnu.no) Received: (qmail 3396 invoked from network); 17 Nov 1998 14:30:35 -0000 Received: from fimfpc26.math.ntnu.no (129.241.15.26) by romberg.math.ntnu.no with SMTP; 17 Nov 1998 14:30:35 -0000 Received: (from arnej@localhost) by fimfpc26.math.ntnu.no (8.9.1/8.8.4) id PAA03497; Tue, 17 Nov 1998 15:30:35 +0100 (CET) Message-Id: <199811171430.PAA03497@fimfpc26.math.ntnu.no> Date: Tue, 17 Nov 1998 15:30:35 +0100 (CET) From: arnej@math.ntnu.no Reply-To: arnej@math.ntnu.no To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/8728: mk-amd-map has several bugs and doesn't work at all Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 8728 >Category: bin >Synopsis: mk-amd-map has several bugs and doesn't work at all >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Nov 17 06:40:02 PST 1998 >Last-Modified: >Originator: Arne Henrik Juul >Organization: Norwegian University of Technology and Science >Release: FreeBSD 3.0-CURRENT i386 >Environment: Running 3.0 current as of november 1998. >Description: The program mk-amd-map as imported (from NetBSD?) and modified doesn't work, and it can't have been tested as far as I can see. (I actually use it in daily operations, so I noticed at once when I upgraded to 3.0-current). There are some code to use mkstemp if available in here that's so completely bogus I just removed it, it would need a complete rethink. (As it was it opened the output database file *instead* of the input text file). Also, the conversion from .dir/.pag files to just a .db file wasn't really complete, and one error message was just wrong. >How-To-Repeat: Try to run mk-amd-map and check the resulting database, or run mk-amd-map -p and watch the resulting lossage. >Fix: Apply following patch: Index: contrib/amd/mk-amd-map/mk-amd-map.c =================================================================== RCS file: /usr/cvs/src/contrib/amd/mk-amd-map/mk-amd-map.c,v retrieving revision 1.4 diff -u -r1.4 mk-amd-map.c --- mk-amd-map.c 1998/08/27 07:25:25 1.4 +++ mk-amd-map.c 1998/11/17 14:03:44 @@ -263,16 +263,10 @@ perror("mk-amd-map: malloc"); exit(1); } -#ifdef HAVE_MKSTEMP - mapfd = mkstemp(maptmp); -#else /* not HAVE_MKSTEMP */ - map = mktemp(maptmp); - if (!maptmp) { + if (!mktemp(maptmp)) { fprintf(stderr, "cannot create temporary file\n"); exit(1); } - mapfd = open(map, O_RDONLY); -#endif /* not HAVE_MKSTEMP */ /* open DBM files */ sprintf(maptdb, "%s.db", maptmp); @@ -283,6 +277,7 @@ } } /* open and check if map file was opened OK */ + mapfd = open(map, O_RDONLY); mapf = fdopen(mapfd, "r"); if (mapf && !printit) mapd = dbm_open(maptmp, O_RDWR|O_CREAT, 0444); @@ -298,21 +293,14 @@ int error = read_file(mapf, map, mapd); (void) close(mapfd); (void) fclose(mapf); - dbm_close(mapd); - if (printit) { - if (error) { - fprintf(stderr, "Error creating ndbm map for %s\n", map); - rc = 1; - } - } else { - - if (error) { + if (error) { fprintf(stderr, "Error reading source file %s\n", map); rc = 1; - } else { + } + if (!printit) { + dbm_close(mapd); + if (!error) { sprintf(mapdb, "%s.db", map); - if (unlink(mapdb) == 0) - fprintf(stderr, "WARNING: existing map \"%s.db\" destroyed\n", map); if (rename(maptdb, mapdb) < 0) { fprintf(stderr, "Couldn't rename %s to ", maptdb); perror(mapdb); @@ -322,7 +310,6 @@ } } } - } else { fprintf(stderr, "Can't open \"%s.db\" for ", map); perror("writing"); >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message