… | |
… | |
345 | |
345 | |
346 | #ifndef EIO_PATH_MIN |
346 | #ifndef EIO_PATH_MIN |
347 | # define EIO_PATH_MIN 8160 |
347 | # define EIO_PATH_MIN 8160 |
348 | #endif |
348 | #endif |
349 | |
349 | |
|
|
350 | #if defined(O_PATH) |
|
|
351 | # define EIO_O_PATH O_PATH |
|
|
352 | #elif defined(O_SEARCH) |
|
|
353 | # define EIO_O_PATH O_SEARCH |
|
|
354 | #else |
|
|
355 | # define EIO_O_PATH 0 |
|
|
356 | #endif |
|
|
357 | |
350 | #define EIO_PATH_MAX (PATH_MAX <= EIO_PATH_MIN ? EIO_PATH_MIN : PATH_MAX) |
358 | #define EIO_PATH_MAX (PATH_MAX <= EIO_PATH_MIN ? EIO_PATH_MIN : PATH_MAX) |
351 | |
359 | |
352 | /* buffer size for various temporary buffers */ |
360 | /* buffer size for various temporary buffers */ |
353 | #define EIO_BUFSIZE 65536 |
361 | #define EIO_BUFSIZE 65536 |
354 | |
362 | |
… | |
… | |
1414 | } |
1422 | } |
1415 | } |
1423 | } |
1416 | #else |
1424 | #else |
1417 | #if HAVE_AT |
1425 | #if HAVE_AT |
1418 | { |
1426 | { |
1419 | int fd = openat (WD2FD (req->wd), req->ptr1, O_CLOEXEC | O_SEARCH | O_DIRECTORY | O_NONBLOCK); |
1427 | int fd = openat (WD2FD (req->wd), req->ptr1, O_CLOEXEC | O_RDONLY | O_DIRECTORY | O_NONBLOCK); |
1420 | |
1428 | |
1421 | if (fd < 0) |
1429 | if (fd < 0) |
1422 | return; |
1430 | return; |
1423 | |
1431 | |
1424 | dirp = fdopendir (fd); |
1432 | dirp = fdopendir (fd); |
… | |
… | |
1677 | |
1685 | |
1678 | if (len < 0) |
1686 | if (len < 0) |
1679 | return EIO_INVALID_WD; |
1687 | return EIO_INVALID_WD; |
1680 | |
1688 | |
1681 | #if HAVE_AT |
1689 | #if HAVE_AT |
1682 | fd = openat (WD2FD (wd), path, O_CLOEXEC | O_SEARCH | O_DIRECTORY | O_NONBLOCK); |
1690 | fd = openat (WD2FD (wd), path, EIO_O_PATH | O_DIRECTORY | O_NONBLOCK | O_CLOEXEC); |
1683 | |
1691 | |
1684 | /* 0 is a valid fd, but we use it for EIO_CWD, so in the very unlikely */ |
1692 | /* 0 is a valid fd, but we use it for EIO_CWD, so in the very unlikely */ |
1685 | /* case of fd 0 being available (almost certainly an a pplication bug) */ |
1693 | /* case of fd 0 being available (almost certainly an a pplication bug) */ |
1686 | /* make sure we use another fd value */ |
1694 | /* make sure we use another fd value */ |
1687 | #if EIO_CWD |
1695 | #if EIO_CWD |
… | |
… | |
1766 | } |
1774 | } |
1767 | |
1775 | |
1768 | static int |
1776 | static int |
1769 | eio__statvfsat (int dirfd, const char *path, struct statvfs *buf) |
1777 | eio__statvfsat (int dirfd, const char *path, struct statvfs *buf) |
1770 | { |
1778 | { |
1771 | int fd = openat (dirfd, path, O_SEARCH | O_CLOEXEC | O_NONBLOCK); |
1779 | int fd = openat (dirfd, path, EIO_O_PATH | O_CLOEXEC | O_NONBLOCK); |
1772 | int res; |
1780 | int res; |
1773 | |
1781 | |
1774 | if (fd < 0) |
1782 | if (fd < 0) |
1775 | return fd; |
1783 | return fd; |
1776 | |
1784 | |