diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-03-30 14:07:15 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-30 14:07:15 -0700 |
commit | 49a8fe8e962ed929cf5bed5520e581025f5bfe9a (patch) | |
tree | ad3ea9fb0b4653e801eb51390c5695e26201de13 /strbuf.c | |
parent | 3736c925580f678f601d670983f7f6cda791d108 (diff) | |
parent | a54e938e5b53c76ebcd5c068a4f74739c1c68bac (diff) | |
download | git-49a8fe8e962ed929cf5bed5520e581025f5bfe9a.tar.gz |
Merge branch 'rs/freebsd-getcwd-workaround'
FreeBSD implementation of getcwd(3) behaved differently when an
intermediate directory is unreadable/unsearchable depending on the
length of the buffer provided, which our strbuf_getcwd() was not
aware of. strbuf_getcwd() has been taught to cope with it better.
* rs/freebsd-getcwd-workaround:
strbuf: support long paths w/o read rights in strbuf_getcwd() on FreeBSD
Diffstat (limited to 'strbuf.c')
-rw-r--r-- | strbuf.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -449,6 +449,17 @@ int strbuf_getcwd(struct strbuf *sb) strbuf_setlen(sb, strlen(sb->buf)); return 0; } + + /* + * If getcwd(3) is implemented as a syscall that falls + * back to a regular lookup using readdir(3) etc. then + * we may be able to avoid EACCES by providing enough + * space to the syscall as it's not necessarily bound + * to the same restrictions as the fallback. + */ + if (errno == EACCES && guessed_len < PATH_MAX) + continue; + if (errno != ERANGE) break; } |