Description: fix "open() returns -EFAULT when program doesn't run ctor" Author: Roland Stigge Bug-Debian: https://bugs.debian.org/702711 Last-Update: 2014-08-31 --- a/libeatmydata/libeatmydata.c +++ b/libeatmydata/libeatmydata.c @@ -69,11 +69,13 @@ int LIBEATMYDATA_API msync(void *addr, size_t length, int flags); +static int initing = 0; void __attribute__ ((constructor)) eatmydata_init(void); void __attribute__ ((constructor)) eatmydata_init(void) { + initing = 1; ASSIGN_DLSYM_OR_DIE(open); ASSIGN_DLSYM_OR_DIE(open64); ASSIGN_DLSYM_OR_DIE(fsync); @@ -83,6 +85,7 @@ #ifdef HAVE_SYNC_FILE_RANGE ASSIGN_DLSYM_IF_EXIST(sync_file_range); #endif + initing = 0; } static int eatmydata_is_hungry(void) @@ -144,7 +147,7 @@ /* In pthread environments the dlsym() may call our open(). */ /* We simply ignore it because libc is already loaded */ - if (!libc_open) { + if (initing) { errno = EFAULT; return -1; }