Skip to content

Commit

Permalink
preload: Fix building with _FILE_OFFSET_BITS
Browse files Browse the repository at this point in the history
Unsetting `_FILE_OFFSET_BITS` causes time_t to be treated as 32-bit
instead of the 64-bit that we want with `-D_TIME_BITS=64`.

Fixes #216

Co-Authored-By: Steve Langasek <steve.langasek@canonical.com>
  • Loading branch information
2 people authored and martinpitt committed Mar 24, 2024
1 parent 8739472 commit 2127632
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/libumockdev-preload.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,25 @@
* along with umockdev; If not, see <http://www.gnu.org/licenses/>.
*/

/* override -D_FILE_OFFSET_BITS, it breaks us */
#undef _FILE_OFFSET_BITS

/* for getting stat64 */
#define _GNU_SOURCE

/* Remove gcc asm aliasing so that our interposed symbols work as expected */
#include <sys/cdefs.h>

#include <stddef.h>
extern int __REDIRECT_NTH (__ttyname_r_alias, (int __fd, char *__buf,
size_t __buflen), ttyname_r);

#ifdef __REDIRECT
#undef __REDIRECT
#endif
#define __REDIRECT(name, proto, alias) name proto
#ifdef __REDIRECT_NTH
#undef __REDIRECT_NTH
#endif
#define __REDIRECT_NTH(name, proto, alias) name proto __THROW

#include <assert.h>
#include <errno.h>
#include <dirent.h>
Expand Down Expand Up @@ -63,6 +76,12 @@
#include "utils.h"
#include "ioctl_tree.h"

/* Fixup for making a mess with __REDIRECT above */
#ifdef __USE_TIME_BITS64
#define clock_gettime __clock_gettime64
extern int clock_gettime(clockid_t clockid, struct timespec *tp);
#endif

/* fix missing O_TMPFILE on some systems */
#ifndef O_TMPFILE
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
Expand Down

0 comments on commit 2127632

Please sign in to comment.