… | |
… | |
329 | |
329 | |
330 | #ifndef O_CLOEXEC |
330 | #ifndef O_CLOEXEC |
331 | #define O_CLOEXEC 0 |
331 | #define O_CLOEXEC 0 |
332 | #endif |
332 | #endif |
333 | |
333 | |
|
|
334 | #ifndef O_NONBLOCK |
|
|
335 | #define O_NONBLOCK 0 |
|
|
336 | #endif |
|
|
337 | |
|
|
338 | #ifndef O_SEARCH |
|
|
339 | #define O_SEARCH O_RDONLY |
|
|
340 | #endif |
|
|
341 | |
|
|
342 | #ifndef O_DIRECTORY |
|
|
343 | #define O_DIRECTORY 0 |
|
|
344 | #endif |
|
|
345 | |
334 | #ifndef EIO_PATH_MIN |
346 | #ifndef EIO_PATH_MIN |
335 | # define EIO_PATH_MIN 8160 |
347 | # define EIO_PATH_MIN 8160 |
336 | #endif |
348 | #endif |
337 | |
349 | |
338 | #define EIO_PATH_MAX (PATH_MAX <= EIO_PATH_MIN ? EIO_PATH_MIN : PATH_MAX) |
350 | #define EIO_PATH_MAX (PATH_MAX <= EIO_PATH_MIN ? EIO_PATH_MIN : PATH_MAX) |
… | |
… | |
354 | struct etp_tmpbuf; |
366 | struct etp_tmpbuf; |
355 | |
367 | |
356 | #if _POSIX_VERSION >= 200809L |
368 | #if _POSIX_VERSION >= 200809L |
357 | #define HAVE_AT 1 |
369 | #define HAVE_AT 1 |
358 | #define WD2FD(wd) ((wd) ? (wd)->fd : AT_FDCWD) |
370 | #define WD2FD(wd) ((wd) ? (wd)->fd : AT_FDCWD) |
359 | #ifndef O_SEARCH |
|
|
360 | #define O_SEARCH O_RDONLY |
|
|
361 | #endif |
|
|
362 | #else |
371 | #else |
363 | #define HAVE_AT 0 |
372 | #define HAVE_AT 0 |
364 | static const char *wd_expand (struct etp_tmpbuf *tmpbuf, eio_wd wd, const char *path); |
373 | static const char *wd_expand (struct etp_tmpbuf *tmpbuf, eio_wd wd, const char *path); |
365 | #endif |
374 | #endif |
366 | |
375 | |
… | |
… | |
1396 | } |
1405 | } |
1397 | } |
1406 | } |
1398 | #else |
1407 | #else |
1399 | #if HAVE_AT |
1408 | #if HAVE_AT |
1400 | { |
1409 | { |
1401 | int fd = openat (WD2FD (req->wd), req->ptr1, O_CLOEXEC | O_SEARCH | O_DIRECTORY); |
1410 | int fd = openat (WD2FD (req->wd), req->ptr1, O_CLOEXEC | O_SEARCH | O_DIRECTORY | O_NONBLOCK); |
1402 | |
1411 | |
1403 | if (fd < 0) |
1412 | if (fd < 0) |
1404 | return; |
1413 | return; |
1405 | |
1414 | |
1406 | dirp = fdopendir (fd); |
1415 | dirp = fdopendir (fd); |
… | |
… | |
1659 | |
1668 | |
1660 | if (len < 0) |
1669 | if (len < 0) |
1661 | return EIO_INVALID_WD; |
1670 | return EIO_INVALID_WD; |
1662 | |
1671 | |
1663 | #if HAVE_AT |
1672 | #if HAVE_AT |
1664 | fd = openat (WD2FD (wd), path, O_CLOEXEC | O_SEARCH | O_DIRECTORY); |
1673 | fd = openat (WD2FD (wd), path, O_CLOEXEC | O_SEARCH | O_DIRECTORY | O_NONBLOCK); |
1665 | |
1674 | |
1666 | if (fd < 0) |
1675 | if (fd < 0) |
1667 | return EIO_INVALID_WD; |
1676 | return EIO_INVALID_WD; |
1668 | #endif |
1677 | #endif |
1669 | |
1678 | |
… | |
… | |
1720 | /* they forgot these */ |
1729 | /* they forgot these */ |
1721 | |
1730 | |
1722 | static int |
1731 | static int |
1723 | eio__truncateat (int dirfd, const char *path, off_t length) |
1732 | eio__truncateat (int dirfd, const char *path, off_t length) |
1724 | { |
1733 | { |
1725 | int fd = openat (dirfd, path, O_WRONLY | O_CLOEXEC); |
1734 | int fd = openat (dirfd, path, O_WRONLY | O_CLOEXEC | O_NONBLOCK); |
1726 | int res; |
1735 | int res; |
1727 | |
1736 | |
1728 | if (fd < 0) |
1737 | if (fd < 0) |
1729 | return fd; |
1738 | return fd; |
1730 | |
1739 | |
… | |
… | |
1734 | } |
1743 | } |
1735 | |
1744 | |
1736 | static int |
1745 | static int |
1737 | eio__statvfsat (int dirfd, const char *path, struct statvfs *buf) |
1746 | eio__statvfsat (int dirfd, const char *path, struct statvfs *buf) |
1738 | { |
1747 | { |
1739 | int fd = openat (dirfd, path, O_SEARCH | O_CLOEXEC); |
1748 | int fd = openat (dirfd, path, O_SEARCH | O_CLOEXEC | O_NONBLOCK); |
1740 | int res; |
1749 | int res; |
1741 | |
1750 | |
1742 | if (fd < 0) |
1751 | if (fd < 0) |
1743 | return fd; |
1752 | return fd; |
1744 | |
1753 | |