From: Jeff King Date: Thu, 28 May 2015 08:03:01 +0000 (-0400) Subject: config.c: rewrite ENODEV into EISDIR when mmap fails X-Git-Tag: v2.4.5~7^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0e8771f1984c468b0f41a8c779c034ffc48530e5;p=thirdparty%2Fgit.git 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 Signed-off-by: Junio C Hamano --- diff --git a/config.c b/config.c index d348d792aa..6551de30db 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;