From: Junio C Hamano <gitster@pobox.com>
To: "Joachim Schmitz" <jojo@schmitz-digital.de>
Cc: "'Shawn Pearce'" <spearce@spearce.org>, <git@vger.kernel.org>,
<rsbecker@nexbridge.com>
Subject: Re: Porting git to HP NonStop
Date: Sun, 19 Aug 2012 10:23:09 -0700 [thread overview]
Message-ID: <7v628epzia.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <01a801cd7de8$b4c311a0$1e4934e0$@schmitz-digital.de> (Joachim Schmitz's message of "Sun, 19 Aug 2012 10:57:47 +0200")
"Joachim Schmitz" <jojo@schmitz-digital.de> writes:
> 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.
> 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.
> if (errno != EEXIST) {
> perror(dir);
> exit(1);
>
>
>
> Bye, Jojo
next prev parent reply other threads:[~2012-08-19 17:23 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-10 15:04 Porting git to HP NonStop Joachim Schmitz
2012-08-10 16:27 ` Shawn Pearce
2012-08-10 17:32 ` Joachim Schmitz
2012-08-10 17:38 ` Shawn Pearce
2012-08-19 8:57 ` Joachim Schmitz
2012-08-19 17:23 ` Junio C Hamano [this message]
2012-08-20 10:22 ` Joachim Schmitz
2012-08-20 14:41 ` Junio C Hamano
2012-08-20 16:09 ` Joachim Schmitz
2012-08-20 16:53 ` Junio C Hamano
2012-08-22 16:30 ` Joachim Schmitz
2012-08-22 17:00 ` Brandon Casey
2012-08-22 17:13 ` Brandon Casey
2012-08-22 17:18 ` Joachim Schmitz
2012-08-22 17:23 ` Brandon Casey
2012-08-22 17:30 ` Joachim Schmitz
2012-08-22 17:30 ` Junio C Hamano
2012-08-22 18:01 ` Joachim Schmitz
2012-08-22 18:24 ` Junio C Hamano
2012-08-22 18:52 ` Joachim Schmitz
2012-08-22 17:41 ` Johannes Sixt
2012-08-22 18:02 ` Joachim Schmitz
2012-08-22 18:09 ` Johannes Sixt
2012-08-22 18:18 ` Joachim Schmitz
2012-08-22 18:09 ` Brandon Casey
2012-08-22 18:24 ` Brandon Casey
2012-08-22 18:33 ` Junio C Hamano
2012-08-22 18:38 ` Brandon Casey
2012-08-22 20:18 ` Joachim Schmitz
2012-08-22 20:49 ` Junio C Hamano
2012-08-22 21:05 ` Joachim Schmitz
2012-08-22 21:12 ` Junio C Hamano
2012-08-22 21:22 ` Joachim Schmitz
2012-08-22 21:54 ` Junio C Hamano
2012-08-22 18:26 ` Junio C Hamano
2012-08-10 20:08 ` Joachim Schmitz
2012-08-11 8:20 ` Johannes Sixt
2012-08-14 7:05 ` Joachim Schmitz
2012-08-14 14:56 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7v628epzia.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jojo@schmitz-digital.de \
--cc=rsbecker@nexbridge.com \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).