From owner-svn-src-all@FreeBSD.ORG Thu May 22 20:24:31 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6ACAEC01; Thu, 22 May 2014 20:24:31 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3DDD827D1; Thu, 22 May 2014 20:24:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4MKOVOS061189; Thu, 22 May 2014 20:24:31 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4MKOUnm061187; Thu, 22 May 2014 20:24:30 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201405222024.s4MKOUnm061187@svn.freebsd.org> From: Marcel Moolenaar Date: Thu, 22 May 2014 20:24:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r266556 - head/usr.bin/mkimg X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 May 2014 20:24:31 -0000 Author: marcel Date: Thu May 22 20:24:30 2014 New Revision: 266556 URL: http://svnweb.freebsd.org/changeset/base/266556 Log: Create our temporary file in $TMPDIR, if the environment variable is set. /tmp otherwise. Submitted by: Dan McGregor Modified: head/usr.bin/mkimg/image.c head/usr.bin/mkimg/mkimg.1 Modified: head/usr.bin/mkimg/image.c ============================================================================== --- head/usr.bin/mkimg/image.c Thu May 22 19:36:29 2014 (r266555) +++ head/usr.bin/mkimg/image.c Thu May 22 20:24:30 2014 (r266556) @@ -30,6 +30,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include #include #include @@ -38,7 +41,7 @@ __FBSDID("$FreeBSD$"); #define BUFFER_SIZE (1024*1024) -static char image_tmpfile[] = "/tmp/mkimg-XXXXXX"; +static char image_tmpfile[PATH_MAX]; static int image_fd = -1; static lba_t image_size; @@ -161,9 +164,14 @@ image_write(lba_t blk, void *buf, ssize_ int image_init(void) { + const char *tmpdir; if (atexit(cleanup) == -1) return (errno); + if ((tmpdir = getenv("TMPDIR")) == NULL || *tmpdir == '\0') + tmpdir = _PATH_TMP; + snprintf(image_tmpfile, sizeof(image_tmpfile), "%s/mkimg-XXXXXX", + tmpdir); image_fd = mkstemp(image_tmpfile); if (image_fd == -1) return (errno); Modified: head/usr.bin/mkimg/mkimg.1 ============================================================================== --- head/usr.bin/mkimg/mkimg.1 Thu May 22 19:36:29 2014 (r266555) +++ head/usr.bin/mkimg/mkimg.1 Thu May 22 20:24:30 2014 (r266556) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 27, 2014 +.Dd May 22, 2014 .Dt MKIMG 1 .Os .Sh NAME @@ -159,6 +159,11 @@ For partitioning schemes that feature pa utility supports assigning labels to the partitions specified. In the following example the file system partition is labeled as 'backup': .Dl % mkimg -s gpt -p freebsd-ufs/backup:=file-system.ufs -o gpt.img +.Sh ENVIRONMENT +.Bl -tag -width "TMPDIR" -compact +.It Ev TMPDIR +Directory to put temporary files in; default is +.Pa /tmp . .Sh SEE ALSO .Xr gpart 8 .Xr makefs 8