* Problem pushing to a Novell share
@ 2012-02-02 22:54 Rüdiger Kessel
2012-02-02 23:45 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Rüdiger Kessel @ 2012-02-02 22:54 UTC (permalink / raw
To: git
Hi
a push to an .git-repository on a Novell network-share using msysgit
fails with the following error message:
error: unable to create temporary sha1 filename : File exists
The problem has been found in git version 1.7.9
The problem is caused by a non-existing sub-directory in the file path
which is not automatically created on Novell shares.
A quick fix is to improve the create_tmpfile() function in sha1_file.c:
static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
{
static struct stat sb;
int fd, dirlen = directory_size(filename);
if (dirlen + 20 > bufsiz) {
errno = ENAMETOOLONG;
return -1;
}
memcpy(buffer, filename, dirlen);
buffer[dirlen-1] = 0;
if (stat(buffer, &sb) != 0 && errno == ENOENT) {
if (mkdir(buffer, 0777) || adjust_shared_perm(buffer))
return -1;
}
memcpy(buffer, filename, dirlen);
strcpy(buffer + dirlen, "tmp_obj_XXXXXX");
fd = git_mkstemp_mode(buffer, 0444);
return fd;
}
The function will create one missing directory level if it does not
exist prior to creating the tmp-file.
This method seems to work, but it works only if one directory level is
missing which might not be the case in general. A better solution
would be to create the whole directory tree if needed.
The best solution would be if MINGW would handle this issue.
I recommend including this patch into GIT since it does no harm on
posix systems but it improves compatibility on others.
Rüdiger
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem pushing to a Novell share
2012-02-02 22:54 Problem pushing to a Novell share Rüdiger Kessel
@ 2012-02-02 23:45 ` Junio C Hamano
[not found] ` <CAJ4nRM1K=sCy8_0PG-NADVn4T0XG1ELC7AvtQyW-Dc1cUMzEXQ@mail.gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2012-02-02 23:45 UTC (permalink / raw
To: Rüdiger Kessel; +Cc: git
Rüdiger Kessel <ruediger.kessel@gmail.com> writes:
> A quick fix is to improve the create_tmpfile() function in sha1_file.c:
>
> static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
> {
> static struct stat sb;
> int fd, dirlen = directory_size(filename);
>
> if (dirlen + 20 > bufsiz) {
> errno = ENAMETOOLONG;
> return -1;
> }
>
> memcpy(buffer, filename, dirlen);
> buffer[dirlen-1] = 0;
> if (stat(buffer, &sb) != 0 && errno == ENOENT) {
> if (mkdir(buffer, 0777) || adjust_shared_perm(buffer))
> return -1;
> }
>
> memcpy(buffer, filename, dirlen);
> strcpy(buffer + dirlen, "tmp_obj_XXXXXX");
> fd = git_mkstemp_mode(buffer, 0444);
> return fd;
> }
>
> The function will create one missing directory level if it does not
> exist prior to creating the tmp-file.
Please remove your modification above, and follow the code we have. We
try git_mkstemp_mode() first, because it is more common than not having
the leading directory and we do not want to waste an extra stat() every
tie we come here. Only when the first attempt fails by returning error
(i.e. fd < 0 and errno == ENOENT), we try mkdir() and then try again.
If you see "missing directory", it would be because on your system the
code somehow does not notice the failure from the first attempt. Why?
The breakage you are seeing could come from either:
- git_mkstemp_mode(), more specifically, the underlying mkstemp(), not
returning negative when it fails for some reason; or
- when the above fails, it fails to set errno to ENOENT.
and *that* is what needs to be fixed.
I think pessimizing create_tmpfile() like you did is not a fix; it is
sweeping the real problem under the rug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem pushing to a Novell share
[not found] ` <CAJ4nRM1K=sCy8_0PG-NADVn4T0XG1ELC7AvtQyW-Dc1cUMzEXQ@mail.gmail.com>
@ 2012-02-03 1:28 ` Junio C Hamano
[not found] ` <CAJ4nRM3xazYuNyDNE_Ff9ueGPCuH_dRtaE9s-8sLj+hhDFTY2w@mail.gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2012-02-03 1:28 UTC (permalink / raw
To: Rüdiger Kessel; +Cc: git
Rüdiger Kessel <ruediger.kessel@gmail.com> writes:
> Trying git_mkstemp_mode() first means trying more 16000 times to create a
> random file before realizing that something might be wrong.
Well, git_mkstemps_mode() does have such a 16k loop, and it tries to
create a unique, unused file this way:
fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode);
if (fd > 0)
return fd;
/*
* Fatal error (EPERM, ENOSPC etc).
* It doesn't make sense to loop.
*/
if (errno != EEXIST)
break;
If you do not have a directory D and try to create D/tmp_random here,
shouldn't you get an error that is _NOT_ EEXIST and trigger this break?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem pushing to a Novell share
[not found] ` <CAJ4nRM2+u9OcLgJBN7+_rv1OiXETGNhozAfvYtj=hVNTfCMxhQ@mail.gmail.com>
@ 2012-02-03 19:33 ` Junio C Hamano
0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2012-02-03 19:33 UTC (permalink / raw
To: git; +Cc: Rüdiger Kessel
[jc: just forwarding to the list --- the msysgit list might have been a
better place to forward to, but I know msysgit folks read this list too,
so...]
Rüdiger Kessel <ruediger.kessel@gmail.com> writes:
I have confimed that it is not a mingw problem. Direct calls to
CreateFile() in kernel32.dll show the same behaviour.
On a Novel share I get Error 80 "File exists" if a directory does not
exist, while I get Error 3 "Path not found" on a local drive
2012/2/3 Rüdiger Kessel <ruediger.kessel@gmail.com>:
Well, it is a Novell bug, but what can we do?
I studied it in detail and open() sets errno=EEXIST if the directory
is missing on a Novell share causing git_mkstemp_mode looping 16k
times and never creates the dir.
The correct errno would be ENOENT, but that not what the systems is sending.
So it is either using stat on the directory before trying to create
the tmp-file or GIT cannot be used with Novell shares. What is it
going to be?
Protocolling the mkdir error handling I saw that git creates quite a
number of new directories this way. Therefore my pessimistic approach
might be too costly at the end.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-03 19:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-02 22:54 Problem pushing to a Novell share Rüdiger Kessel
2012-02-02 23:45 ` Junio C Hamano
[not found] ` <CAJ4nRM1K=sCy8_0PG-NADVn4T0XG1ELC7AvtQyW-Dc1cUMzEXQ@mail.gmail.com>
2012-02-03 1:28 ` Junio C Hamano
[not found] ` <CAJ4nRM3xazYuNyDNE_Ff9ueGPCuH_dRtaE9s-8sLj+hhDFTY2w@mail.gmail.com>
[not found] ` <CAJ4nRM2+u9OcLgJBN7+_rv1OiXETGNhozAfvYtj=hVNTfCMxhQ@mail.gmail.com>
2012-02-03 19:33 ` Junio C Hamano
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).