svn commit: trunk/busybox/debianutils

aldot at busybox.net aldot at busybox.net
Tue Oct 10 08:28:42 PDT 2006


Author: aldot
Date: 2006-10-10 08:28:41 -0700 (Tue, 10 Oct 2006)
New Revision: 16355

Log:
- add option -t
  mkinitrd and mkinitramfs both require -t.


Modified:
   trunk/busybox/debianutils/mktemp.c


Changeset:
Modified: trunk/busybox/debianutils/mktemp.c
===================================================================
--- trunk/busybox/debianutils/mktemp.c	2006-10-10 01:03:46 UTC (rev 16354)
+++ trunk/busybox/debianutils/mktemp.c	2006-10-10 15:28:41 UTC (rev 16355)
@@ -18,21 +18,31 @@
 
 int mktemp_main(int argc, char **argv)
 {
-	unsigned long flags = getopt32(argc, argv, "dq");
+	unsigned long flags = getopt32(argc, argv, "dqt");
+	char *chp;
 
 	if (optind + 1 != argc)
 		bb_show_usage();
 
+	chp = argv[optind];
+
+	if (flags & 4) {
+		char *dir = getenv("TMPDIR");
+		if (dir && *dir != '\0')
+			chp = concat_path_file(dir, chp);
+		else
+			chp = concat_path_file("/tmp/", chp);
+	}
+
 	if (flags & 1) {
-		if (mkdtemp(argv[optind]) == NULL)
+		if (mkdtemp(chp) == NULL)
 			return EXIT_FAILURE;
-	}
-	else {
-		if (mkstemp(argv[optind]) < 0)
+	} else {
+		if (mkstemp(chp) < 0)
 			return EXIT_FAILURE;
 	}
 
-	puts(argv[optind]);
+	puts(chp);
 
 	return EXIT_SUCCESS;
 }



More information about the busybox-cvs mailing list