Date: Thu, 22 May 2014 09:45:50 -0600 From: Dan McGregor <danismostlikely@gmail.com> To: Alan Somers <asomers@freebsd.org>, marcelm@juniper.net Cc: "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org> Subject: Re: Patch to tech mkimg about the TMPDIR variable Message-ID: <CACS%2B7ZQ0Cs9W9zCJEJtcuBL20yzBE3bd3fMEWG1ofOK-cp3Lew@mail.gmail.com> In-Reply-To: <CACS%2B7ZTxgD_huJucS9TXKiOUJJMjQ=EV_AOySROmHDk_PiTaNA@mail.gmail.com> References: <CACS%2B7ZSsGXsCjx3oYPdbNrKOgyNqa2o-a3Z=m2ZRGeJ0ey-zGw@mail.gmail.com> <CAOtMX2iULkecTm40Yhif9DA_-HoyH0eYHtLSh-BnHUJdj1x9=g@mail.gmail.com> <CACS%2B7ZTxgD_huJucS9TXKiOUJJMjQ=EV_AOySROmHDk_PiTaNA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On 22 May 2014 09:31, Dan McGregor <danismostlikely@gmail.com> wrote:
> On 22 May 2014 09:21, Alan Somers <asomers@freebsd.org> wrote:
>
>> On Thu, May 22, 2014 at 9:09 AM, Dan McGregor <danismostlikely@gmail.com>
>> wrote:
>> > Hello everyone,
>> >
>> > I was running out of room in /tmp on my system while using mkimg getting
>> > this error:
>> >
>> > partition 1: starting block 16 ... mkimg: partition 1: No space left on
>> > device
>> >
>> > So, I patched mkimg to respect the TMPDIR variable.
>> >
>> > Thoughts?
>>
>> LGTM. Will you update the man page too?
>>
>>
> I hadn't thought of of that. I shall and post a new patch.
>
New patch, with man page updates as well.
[-- Attachment #2 --]
Index: usr.bin/mkimg/image.c
===================================================================
--- usr.bin/mkimg/image.c (révision 266543)
+++ usr.bin/mkimg/image.c (copie de travail)
@@ -30,6 +30,9 @@
#include <sys/types.h>
#include <assert.h>
#include <errno.h>
+#include <limits.h>
+#include <paths.h>
+#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -38,7 +41,7 @@
#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,13 @@
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);
Index: usr.bin/mkimg/mkimg.1
===================================================================
--- usr.bin/mkimg/mkimg.1 (révision 266543)
+++ usr.bin/mkimg/mkimg.1 (copie de travail)
@@ -159,6 +159,16 @@
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 FILES
+.Bl -tag -width "$TMPDIR/mkimg-*" -compact
+.It $TMPDIR/mkimg-*
+.Nm
+temporary files
.Sh SEE ALSO
.Xr gpart 8
.Xr makefs 8
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACS%2B7ZQ0Cs9W9zCJEJtcuBL20yzBE3bd3fMEWG1ofOK-cp3Lew>
