git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Porting git to HP NonStop

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 19, 2012, 17:23 UTC
Message-ID
<7v628epzia.fsf@alter.siamese.dyndns.org>
In-Reply-To
<01a801cd7de8$b4c311a0$1e4934e0$@schmitz-digital.de>
"Joachim Schmitz" <jojo@schmitz-digital.de> writes:
Show 14 quoted lines
> Found the problem: our mkdir(dir,flags) fails with ENOENT when dir ends with
> a '/'.
> Not sure whether this us a bug on out platform or just allowed by POSIX and
> as such a wrong assumption in git though?
>
> [shortly after]
> A bit of googleing revealed that there is a GNUlib solution for this, which
> claims that at least NetBSD 1.5.2 has the same problem.
> (http://www.opensource.apple.com/source/gpatch/gpatch-2/patch/mkdir.c)
>
> And apparently this has been discussed on the git mailing list too, 2 years
> ago:
> http://lists-archives.com/git/728359-git-s-use-of-mkdir-2.html, there's a
> patch too.

Given that newer BSDs have fixed libc to accept directory name with a trailing slash, and that we use mkdir(2) in many places, I think the right way to do so is still what I suggested in that old thread in the last paragraph of my message

  http://thread.gmane.org/gmane.comp.version-control.git/155812/focus=155876

That is, have compat/tandem.c and define a replacement mkdir(2) in a way similar to how MinGW does so.

Show 18 quoted lines
> For now I've fixed it like this:
> /usr/local/bin/diff -EBbu ./builtin/init-db.c.orig ./builtin/init-db.c
> --- ./builtin/init-db.c.orig    2012-08-19 03:55:50 -0500
> +++ ./builtin/init-db.c 2012-08-19 03:39:57 -0500
> @@ -25,7 +25,16 @@
>
>  static void safe_create_dir(const char *dir, int share)
>  {
> +#ifdef __TANDEM /* our mkdir() can't cope with a trailing '/' */
> +       char mydir[PATH_MAX];
> +
> +       strcpy(mydir,dir);
> +       if (dir[strlen(dir)-1] == '/')
> +               mydir[strlen(dir)-1] = '\0';
> +       if (mkdir(mydir, 0777) < 0) {
> +#else
>         if (mkdir(dir, 0777) < 0) {
> +#endif
Move that part inside #ifdef __TANDEM to define
	int tandem_mkdir(const char *dir, mode_t mode)
        {
		...
	}
in your new file compat/tandem.c, add
	#ifdef __TANDEM
        #define mkdir(a,b) tandem_mkdir((a), (b))
	#endif

to git-compat-util.h and then add compat/tandem.o to COMPAT_OBJS in the top-level Makefile.

That way we do not have to keep an ugly platform specific ifdef in the very generic codepath.

Show 7 quoted lines
>                 if (errno != EEXIST) {
>                         perror(dir);
>                         exit(1);
>
>
>
> Bye, Jojo 
Previous: Joachim SchmitzNext: Joachim Schmitz
Message 6 of 39 in “RE: Porting git to HP NonStop”
  1. Joachim SchmitzAug 10, 2012
  2. Shawn PearceAug 10, 2012
  3. Joachim SchmitzAug 10, 2012
  4. Shawn PearceAug 10, 2012
  5. Joachim SchmitzAug 19, 2012
  6. Junio C HamanoAug 19, 2012
  7. Joachim SchmitzAug 20, 2012
  8. Junio C HamanoAug 20, 2012
  9. Joachim SchmitzAug 20, 2012
  10. Junio C HamanoAug 20, 2012
  11. Joachim SchmitzAug 22, 2012
  12. Brandon CaseyAug 22, 2012
  13. Brandon CaseyAug 22, 2012
  14. Joachim SchmitzAug 22, 2012
  15. Brandon CaseyAug 22, 2012
  16. Joachim SchmitzAug 22, 2012
  17. Junio C HamanoAug 22, 2012
  18. Joachim SchmitzAug 22, 2012
  19. Junio C HamanoAug 22, 2012
  20. Joachim SchmitzAug 22, 2012
  21. Johannes SixtAug 22, 2012
  22. Joachim SchmitzAug 22, 2012
  23. Johannes SixtAug 22, 2012
  24. Joachim SchmitzAug 22, 2012
  25. Brandon CaseyAug 22, 2012
  26. Brandon CaseyAug 22, 2012
  27. Junio C HamanoAug 22, 2012
  28. Brandon CaseyAug 22, 2012
  29. Joachim SchmitzAug 22, 2012
  30. Junio C HamanoAug 22, 2012
  31. Joachim SchmitzAug 22, 2012
  32. Junio C HamanoAug 22, 2012
  33. Joachim SchmitzAug 22, 2012
  34. Junio C HamanoAug 22, 2012
  35. Junio C HamanoAug 22, 2012
  36. Joachim SchmitzAug 10, 2012
  37. Johannes SixtAug 11, 2012
  38. Joachim SchmitzAug 14, 2012
  39. Junio C HamanoAug 14, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.