From owner-freebsd-bugs@FreeBSD.ORG Sun Aug 12 15:30:02 2007 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE92C16A419 for ; Sun, 12 Aug 2007 15:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id BD6D413C478 for ; Sun, 12 Aug 2007 15:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id l7CFU1mP018027 for ; Sun, 12 Aug 2007 15:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l7CFU1ad018026; Sun, 12 Aug 2007 15:30:01 GMT (envelope-from gnats) Resent-Date: Sun, 12 Aug 2007 15:30:01 GMT Resent-Message-Id: <200708121530.l7CFU1ad018026@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Eugene Grosbein Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A9D4B16A418 for ; Sun, 12 Aug 2007 15:25:07 +0000 (UTC) (envelope-from eugen@grosbein.pp.ru) Received: from grosbein.pp.ru (grgw.svzserv.kemerovo.su [213.184.64.166]) by mx1.freebsd.org (Postfix) with ESMTP id E211B13C458 for ; Sun, 12 Aug 2007 15:25:05 +0000 (UTC) (envelope-from eugen@grosbein.pp.ru) Received: from grosbein.pp.ru (localhost [127.0.0.1]) by grosbein.pp.ru (8.14.1/8.14.1) with ESMTP id l7CFP0ST001929 for ; Sun, 12 Aug 2007 23:25:01 +0800 (KRAST) (envelope-from eugen@grosbein.pp.ru) Received: (from eugen@localhost) by grosbein.pp.ru (8.14.1/8.14.1/Submit) id l7CFP0Ll001925; Sun, 12 Aug 2007 23:25:00 +0800 (KRAST) (envelope-from eugen) Message-Id: <200708121525.l7CFP0Ll001925@grosbein.pp.ru> Date: Sun, 12 Aug 2007 23:25:00 +0800 (KRAST) From: Eugene Grosbein To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/115447: [patch] teach make(1) to respect TMPDIR environment variable X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Eugene Grosbein List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Aug 2007 15:30:02 -0000 >Number: 115447 >Category: bin >Synopsis: [patch] teach make(1) to respect TMPDIR environment variable >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Aug 12 15:30:01 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Eugene Grosbein >Release: FreeBSD 6.2-STABLE i386 >Organization: Svyaz-Service JSC >Environment: System: FreeBSD grosbein.pp.ru 6.2-STABLE FreeBSD 6.2-STABLE #0: Sat Aug 11 18:41:38 KRAST 2007 eu@grosbein.pp.ru:/home/obj/usr/local/src/sys/DADV i386 >Description: System make(1) uses hardcoded /tmp path for its temporary files. Let's teach it to use TMPDIR environment variable if it's set. Very often /tmp is located on root filesystem and often this filesystem has not softupdates flag set. Taking make's temporary directory out for such filesystem to memory disk descreases "make -j3 buildworld" real time to more than 3 minutes for my system (2xPentium-D 2.8Ghz, UDMA100 IDE HDD). >How-To-Repeat: Watch load of drive containing /tmp with "systat -vm 3" while "make buildworld" runs when /usr/src and /usr/obj are located on another device. make(1) makes high load on /tmp. >Fix: --- usr.bin/make/job.c.orig 2007-08-11 09:38:05.000000000 +0800 +++ usr.bin/make/job.c 2007-08-11 09:52:43.000000000 +0800 @@ -118,6 +118,7 @@ #include #include #include +#include #include #include #include @@ -141,7 +142,7 @@ #include "util.h" #include "var.h" -#define TMPPAT "/tmp/makeXXXXXXXXXX" +#define TMPPAT "makeXXXXXXXXXX" #ifndef USE_KQUEUE /* @@ -240,7 +241,7 @@ */ struct { /* Name of file to which shell output was rerouted */ - char of_outFile[sizeof(TMPPAT)]; + char of_outFile[PATH_MAX]; /* * Stream open to the output file. Used to funnel all @@ -1576,7 +1577,8 @@ Boolean noExec; /* Set true if we decide not to run the job */ int tfd; /* File descriptor for temp file */ LstNode *ln; - char tfile[sizeof(TMPPAT)]; + char tfile[PATH_MAX]; + char *tdir; if (interrupted) { JobPassSig(interrupted); @@ -1617,6 +1619,9 @@ cmdsOK = TRUE; } + if ( (tdir = getenv("TMPDIR")) == NULL ) + tdir = "/tmp"; + /* * If the -n flag wasn't given, we open up OUR (not the child's) * temporary file to stuff commands in it. The thing is rd/wr so we @@ -1632,7 +1637,7 @@ DieHorribly(); } - strcpy(tfile, TMPPAT); + snprintf(tfile, sizeof(tfile), "%s/%s", tdir, TMPPAT); if ((tfd = mkstemp(tfile)) == -1) Punt("Cannot create temp file: %s", strerror(errno)); job->cmdFILE = fdopen(tfd, "w+"); @@ -1811,7 +1816,7 @@ } else { fprintf(stdout, "Remaking `%s'\n", gn->name); fflush(stdout); - strcpy(job->outFile, TMPPAT); + snprintf(job->outFile, sizeof(job->outFile), "%s/%s", tdir, TMPPAT); if ((job->outFd = mkstemp(job->outFile)) == -1) Punt("cannot create temp file: %s", strerror(errno)); Eugene Grosbein >Release-Note: >Audit-Trail: >Unformatted: