Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/disklabel Try $TMPDIR before resorting to _PATH_TMP.



details:   https://anonhg.NetBSD.org/src/rev/c040ff59cc43
branches:  trunk
changeset: 474813:c040ff59cc43
user:      kleink <kleink%NetBSD.org@localhost>
date:      Wed Jul 21 17:56:34 1999 +0000

description:
Try $TMPDIR before resorting to _PATH_TMP.

diffstat:

 sbin/disklabel/disklabel.c |  10 +++++++---
 sbin/disklabel/pathnames.h |   5 ++---
 2 files changed, 9 insertions(+), 6 deletions(-)

diffs (56 lines):

diff -r 900f7240e6f4 -r c040ff59cc43 sbin/disklabel/disklabel.c
--- a/sbin/disklabel/disklabel.c        Wed Jul 21 17:10:08 1999 +0000
+++ b/sbin/disklabel/disklabel.c        Wed Jul 21 17:56:34 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disklabel.c,v 1.73 1999/06/04 19:02:34 is Exp $        */
+/*     $NetBSD: disklabel.c,v 1.74 1999/07/21 17:56:34 kleink Exp $    */
 
 /*
  * Copyright (c) 1987, 1993
@@ -47,7 +47,7 @@
 static char sccsid[] = "@(#)disklabel.c        8.4 (Berkeley) 5/4/95";
 /* from static char sccsid[] = "@(#)disklabel.c        1.2 (Symmetric) 11/28/85"; */
 #else
-__RCSID("$NetBSD: disklabel.c,v 1.73 1999/06/04 19:02:34 is Exp $");
+__RCSID("$NetBSD: disklabel.c,v 1.74 1999/07/21 17:56:34 kleink Exp $");
 #endif
 #endif /* not lint */
 
@@ -103,7 +103,7 @@
 
 static char    *dkname;
 static char    *specname;
-static char    tmpfil[] = _PATH_TMP;
+static char    tmpfil[MAXPATHLEN];
 
 static char    namebuf[BBSIZE], *np = namebuf;
 static struct  disklabel lab;
@@ -1253,8 +1253,12 @@
 {
        int first, ch, fd;
        struct disklabel label;
+       const char *tmpdir;
        FILE *fp;
 
+       if ((tmpdir = getenv("TMPDIR")) == NULL)
+               tmpdir = _PATH_TMP;
+       (void)snprintf(tmpfil, sizeof (tmpfil), "%s/%s", tmpdir, TMPFILE);
        if ((fd = mkstemp(tmpfil)) == -1 || (fp = fdopen(fd, "w")) == NULL) {
                warn("%s", tmpfil);
                return (1);
diff -r 900f7240e6f4 -r c040ff59cc43 sbin/disklabel/pathnames.h
--- a/sbin/disklabel/pathnames.h        Wed Jul 21 17:10:08 1999 +0000
+++ b/sbin/disklabel/pathnames.h        Wed Jul 21 17:56:34 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pathnames.h,v 1.6 1995/03/18 14:54:43 cgd Exp $        */
+/*     $NetBSD: pathnames.h,v 1.7 1999/07/21 17:56:34 kleink Exp $     */
 
 /*
  * Copyright (c) 1989, 1993
@@ -38,5 +38,4 @@
 #include <paths.h>
 
 #define        _PATH_BOOTDIR   "/usr/mdec"
-#undef _PATH_TMP
-#define        _PATH_TMP       "/tmp/EdDk.aXXXXXX"
+#define        TMPFILE         "EdDk.aXXXXXX"



Home | Main Index | Thread Index | Old Index