summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-05-28 08:03:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-05-28 18:34:06 (GMT)
commit0e8771f1984c468b0f41a8c779c034ffc48530e5 (patch)
tree34eee68c0e2ccf112c35efb8415ac975f4ba4fa8 /config.c
parent1570856b510e3722a3620063e7ba209106b75857 (diff)
downloadgit-0e8771f1984c468b0f41a8c779c034ffc48530e5.zip
git-0e8771f1984c468b0f41a8c779c034ffc48530e5.tar.gz
git-0e8771f1984c468b0f41a8c779c034ffc48530e5.tar.bz2
config.c: rewrite ENODEV into EISDIR when mmap fails
If we try to mmap a directory, we'll get ENODEV. This translates to "no such device" for the user, which is not very helpful. Since we've just fstat()'d the file, we can easily check whether the problem was a directory to give a better message. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/config.c b/config.c
index d348d79..6551de3 100644
--- a/config.c
+++ b/config.c
@@ -2051,6 +2051,8 @@ int git_config_set_multivar_in_file(const char *config_filename,
contents = xmmap_gently(NULL, contents_sz, PROT_READ,
MAP_PRIVATE, in_fd, 0);
if (contents == MAP_FAILED) {
+ if (errno == ENODEV && S_ISDIR(st.st_mode))
+ errno = EISDIR;
error("unable to mmap '%s': %s",
config_filename, strerror(errno));
ret = CONFIG_INVALID_FILE;