Skip to content

Commit 0e8771f

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1570856 commit 0e8771f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

config.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,6 +2051,8 @@ int git_config_set_multivar_in_file(const char *config_filename,
20512051
contents = xmmap_gently(NULL, contents_sz, PROT_READ,
20522052
MAP_PRIVATE, in_fd, 0);
20532053
if (contents == MAP_FAILED) {
2054+
if (errno == ENODEV && S_ISDIR(st.st_mode))
2055+
errno = EISDIR;
20542056
error("unable to mmap '%s': %s",
20552057
config_filename, strerror(errno));
20562058
ret = CONFIG_INVALID_FILE;

0 commit comments

Comments
 (0)