Skip to content

Commit f26f84a

Browse files
Marc Lehmannkindy
authored andcommitted
[sync]
1 parent 4d07e43 commit f26f84a

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

cvs-vers

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Changes:1.65
1+
Changes:1.67
22
LICENSE:1.1
33
Makefile.am:1.4
44
aclocal.m4:1.3
@@ -7,9 +7,9 @@ configure.ac:1.11
77
demo.c:1.4
88
ecb.h:1.28
99
eio.3:1.1
10-
eio.c:1.157
10+
eio.c:1.158
1111
eio.h:1.63
1212
eio.pod:1.36
1313
etp.c:1.14
14-
libeio.m4:1.32
14+
libeio.m4:1.33
1515
xthread.h:1.19

src/Changes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,8 @@ TODO: pthread_condattr_setclock(..., CLOCK_MONOTONIC) and clock_gettime(CLOCK_MO
9393
- use O_NONBLOCK when opening directories and in truncateat and statvfsat.
9494
- add EIO_MCL_ONFAULT.
9595
- add eio_mlockall_sync.
96+
- fix configure tests for readahead and sync_file_range, they were based on the
97+
manpages, which turned out to be wrong.
98+
- protect wd_open against fd being 0, which is used for the value of EIO_CWD.
9699

97100

src/eio.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* libeio implementation
33
*
4-
* Copyright (c) 2007,2008,2009,2010,2011,2012,2013,2016,2017,2018 Marc Alexander Lehmann <libeio@schmorp.de>
4+
* Copyright (c) 2007,2008,2009,2010,2011,2012,2013,2016,2017,2018,2019 Marc Alexander Lehmann <libeio@schmorp.de>
55
* All rights reserved.
66
*
77
* Redistribution and use in source and binary forms, with or without modifica-
@@ -1681,6 +1681,20 @@ eio__wd_open_sync (struct etp_tmpbuf *tmpbuf, eio_wd wd, const char *path)
16811681
#if HAVE_AT
16821682
fd = openat (WD2FD (wd), path, O_CLOEXEC | O_SEARCH | O_DIRECTORY | O_NONBLOCK);
16831683

1684+
/* 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) */
1686+
/* make sure we use another fd value */
1687+
#if EIO_CWD
1688+
error EIO_CWD must be 0
1689+
#endif
1690+
if (ecb_expect_false (fd == 0))
1691+
{
1692+
int fd2 = fcntl (fd, F_DUPFD_CLOEXEC ? F_DUPFD_CLOEXEC : F_DUPFD);
1693+
fcntl (fd2, F_SETFD, FD_CLOEXEC);
1694+
eio__close (fd);
1695+
fd = fd2;
1696+
}
1697+
16841698
if (fd < 0)
16851699
return EIO_INVALID_WD;
16861700
#endif

src/libeio.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ int main (void)
3939
test $ac_cv_futimes = yes && AC_DEFINE(HAVE_FUTIMES, 1, futimes(2) is available)
4040

4141
AC_CACHE_CHECK(for readahead, ac_cv_readahead, [AC_LINK_IFELSE([AC_LANG_SOURCE([
42+
#include <sys/types.h>
4243
#include <fcntl.h>
4344
int main (void)
4445
{
@@ -93,6 +94,7 @@ int main (void)
9394
test $ac_cv_sendfile = yes && AC_DEFINE(HAVE_SENDFILE, 1, sendfile(2) is available and supported)
9495

9596
AC_CACHE_CHECK(for sync_file_range, ac_cv_sync_file_range, [AC_LINK_IFELSE([AC_LANG_SOURCE([
97+
#include <sys/types.h>
9698
#include <fcntl.h>
9799
int main (void)
98100
{

0 commit comments

Comments
 (0)