* [PATCH] sha1_file: avoid bogus "file exists" error message
@ 2008-11-20 18:56 Joey Hess
2008-11-26 18:19 ` Joey Hess
0 siblings, 1 reply; 4+ messages in thread
From: Joey Hess @ 2008-11-20 18:56 UTC (permalink / raw
To: Git List
This avoids the following misleading error message:
error: unable to create temporary sha1 filename ./objects/15: File exists
mkstemp can fail for many reasons, one of which, ENOENT, can occur if
the directory for the temp file doesn't exist. create_tmpfile tried to
handle this case by always trying to mkdir the directory, even if it
already existed. This caused errno to be clobbered, so one cannot tell
why mkstemp really failed, and it truncated the buffer to just the
directory name, resulting in the strange error message shown above.
Note that in both occasions that I've seen this failure, it has not been
due to a missing directory, or bad permissions, but some other, unknown
mkstemp failure mode that did not occur when I ran git again. This code
could perhaps be made more robust by retrying mkstemp, in case it was a
transient failure.
Signed-off-by: Joey Hess <joey@kitenet.net>
---
sha1_file.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index ab2b520..927fb64 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2231,7 +2231,7 @@ static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
memcpy(buffer, filename, dirlen);
strcpy(buffer + dirlen, "tmp_obj_XXXXXX");
fd = mkstemp(buffer);
- if (fd < 0 && dirlen) {
+ if (fd < 0 && dirlen && errno == ENOENT) {
/* Make sure the directory exists */
memcpy(buffer, filename, dirlen);
buffer[dirlen-1] = 0;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] sha1_file: avoid bogus "file exists" error message
2008-11-20 18:56 [PATCH] sha1_file: avoid bogus "file exists" error message Joey Hess
@ 2008-11-26 18:19 ` Joey Hess
2008-11-27 17:41 ` Ian Hilt
0 siblings, 1 reply; 4+ messages in thread
From: Joey Hess @ 2008-11-26 18:19 UTC (permalink / raw
To: Git List
[-- Attachment #1: Type: text/plain, Size: 294 bytes --]
Joey Hess wrote:
> Note that in both occasions that I've seen this failure, it has not been
> due to a missing directory, or bad permissions
Actually, it was due to bad permissions. :-) Once git was fixed to
actually say that, I figured out where to look to fix them.
--
see shy jo
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sha1_file: avoid bogus "file exists" error message
2008-11-26 18:19 ` Joey Hess
@ 2008-11-27 17:41 ` Ian Hilt
2008-11-28 17:00 ` Joey Hess
0 siblings, 1 reply; 4+ messages in thread
From: Ian Hilt @ 2008-11-27 17:41 UTC (permalink / raw
To: Joey Hess; +Cc: Git List
On Wed, 26 Nov 2008, Joey Hess wrote:
> Joey Hess wrote:
> > Note that in both occasions that I've seen this failure, it has not been
> > due to a missing directory, or bad permissions
>
> Actually, it was due to bad permissions. :-) Once git was fixed to
> actually say that, I figured out where to look to fix them.
This is strange since write_loose_object() which calls create_tmpfile()
checks for EPERM. Perhaps this should be done in create_tmpfile()?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sha1_file: avoid bogus "file exists" error message
2008-11-27 17:41 ` Ian Hilt
@ 2008-11-28 17:00 ` Joey Hess
0 siblings, 0 replies; 4+ messages in thread
From: Joey Hess @ 2008-11-28 17:00 UTC (permalink / raw
To: Ian Hilt; +Cc: Git List
[-- Attachment #1: Type: text/plain, Size: 773 bytes --]
Ian Hilt wrote:
> On Wed, 26 Nov 2008, Joey Hess wrote:
> > Joey Hess wrote:
> > > Note that in both occasions that I've seen this failure, it has not been
> > > due to a missing directory, or bad permissions
> >
> > Actually, it was due to bad permissions. :-) Once git was fixed to
> > actually say that, I figured out where to look to fix them.
>
> This is strange since write_loose_object() which calls create_tmpfile()
> checks for EPERM. Perhaps this should be done in create_tmpfile()?
errno is clobbered by the mkdir in create_tmpfile(), that's what my patch
corrects.
I suspect that in my case, mkstemp failed with EACCES, not EPERM. git
was running as a group that did not have write access to (some) object
directories.
--
see shy jo
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-11-28 17:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-20 18:56 [PATCH] sha1_file: avoid bogus "file exists" error message Joey Hess
2008-11-26 18:19 ` Joey Hess
2008-11-27 17:41 ` Ian Hilt
2008-11-28 17:00 ` Joey Hess
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).