mirror of
https://git.sr.ht/~cismonx/bookmarkfs
synced 2025-06-07 19:58:50 +00:00
all: fix build with musl libc
- Should not assume whether O_xxx macros are defined by checking feature test macros. - Workaround conflicting getdents() declaration.
This commit is contained in:
parent
1db61bc878
commit
c90c5f6fc7
4 changed files with 12 additions and 7 deletions
|
@ -97,9 +97,6 @@
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || (defined(__linux__) && defined(_GNU_SOURCE))
|
#if defined(__FreeBSD__) || (defined(__linux__) && defined(_GNU_SOURCE))
|
||||||
# define HAVE_PIPE2 1
|
# define HAVE_PIPE2 1
|
||||||
#else
|
|
||||||
# define O_DIRECT 0
|
|
||||||
# define O_PATH 0 // FreeBSD supports O_PATH since 13.1
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __FreeBSD__
|
#ifndef __FreeBSD__
|
||||||
|
|
|
@ -794,9 +794,11 @@ bm_open (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef O_DIRECT
|
||||||
if (flags & O_DIRECT) {
|
if (flags & O_DIRECT) {
|
||||||
fi->direct_io = 1;
|
fi->direct_io = 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#ifndef __FreeBSD__
|
#ifndef __FreeBSD__
|
||||||
// Cannot reliably keep cache on FreeBSD, we're unable to explicitly
|
// Cannot reliably keep cache on FreeBSD, we're unable to explicitly
|
||||||
// flush it. See comments for inval_inode().
|
// flush it. See comments for inval_inode().
|
||||||
|
|
|
@ -68,7 +68,7 @@ struct fsck_dir {
|
||||||
|
|
||||||
// Forward declaration start
|
// Forward declaration start
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
static ssize_t getdents (int, void *, size_t);
|
static ssize_t getdents_ (int, void *, size_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int next_subdir (struct fsck_ctx *, struct fsck_dir *,
|
static int next_subdir (struct fsck_ctx *, struct fsck_dir *,
|
||||||
|
@ -81,8 +81,11 @@ static void print_version (void);
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
|
||||||
|
// Some libc (e.g., musl) may declare a getdents() function
|
||||||
|
// in dirent.h with conflicting types.
|
||||||
|
#define getdents getdents_
|
||||||
static ssize_t
|
static ssize_t
|
||||||
getdents (
|
getdents_ (
|
||||||
int dirfd,
|
int dirfd,
|
||||||
void *buf,
|
void *buf,
|
||||||
size_t bufsize
|
size_t bufsize
|
||||||
|
|
|
@ -158,8 +158,11 @@ impl_rearm (
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(WATCHER_IMPL_KQUEUE)
|
#elif defined(WATCHER_IMPL_KQUEUE)
|
||||||
int wfd = openat(w->dirfd, w->name,
|
int open_flags = O_RDONLY | O_CLOEXEC | O_RESOLVE_BENEATH;
|
||||||
O_RDONLY | O_CLOEXEC | O_PATH | O_RESOLVE_BENEATH);
|
#ifdef O_PATH
|
||||||
|
open_flags |= O_PATH;
|
||||||
|
#endif
|
||||||
|
int wfd = openat(w->dirfd, w->name, open_flags);
|
||||||
if (wfd < 0) {
|
if (wfd < 0) {
|
||||||
log_printf("openat(): %s", xstrerror(errno));
|
log_printf("openat(): %s", xstrerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue