]> Zhao Yanbai Git Server - minix.git/commitdiff
pax: workaround for mkstemp() and long filenames
authorBen Gras <ben@minix3.org>
Tue, 11 Dec 2012 02:50:04 +0000 (03:50 +0100)
committerBen Gras <ben@minix3.org>
Tue, 11 Dec 2012 11:00:37 +0000 (12:00 +0100)
. symptom: mkstemp() looping forever trying to find a unique
  filename
. reported by pikpik as "BSDTar Endless Extraction of
  NCurses' Distfiles"

bin/pax/file_subs.c

index e3707ca5ad6a2746d0a3f13227426fe4afdf39e1..ea7a66a8bd238fbc7bb3dbd82bd11dd8ddd4bcda 100644 (file)
@@ -160,8 +160,23 @@ file_creat(ARCHD *arcn, int write_to_hardlink)
                 * in the path until chk_path() finds that it cannot fix
                 * anything further.  if that happens we just give up.
                 */
+#ifdef __minix
+               {
+                       /* For minix, generate the temporary filename
+                        * conservatively - just write Xes into the last component.
+                        * There is space because of the malloc().
+                        */
+                       int cc;
+                       char *last_slash;
+                       strcpy(arcn->tmp_name, arcn->name);
+                       if(!(last_slash = strrchr(arcn->tmp_name, '/')))
+                               strcpy(arcn->tmp_name, "XXXXXX");
+                       else    strcpy(last_slash+1, "XXXXXX");
+               }
+#else
                (void)snprintf(arcn->tmp_name, arcn->nlen + 8, "%s.XXXXXX",
                    arcn->name);
+#endif
                fd = mkstemp(arcn->tmp_name);
                if (fd >= 0)
                        break;