From 3908e7ef7ecaffd7b54228d09baeb1db83b0e45d Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 7 May 2024 13:34:19 -0400 Subject: build: Check for 1- and 2-argument getmntent() variants --- build/has/getmntent-1.c | 9 +++++++++ build/has/getmntent-2.c | 10 ++++++++++ build/header.mk | 2 ++ src/mtab.c | 4 ++-- 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 build/has/getmntent-1.c create mode 100644 build/has/getmntent-2.c diff --git a/build/has/getmntent-1.c b/build/has/getmntent-1.c new file mode 100644 index 0000000..9854dcd --- /dev/null +++ b/build/has/getmntent-1.c @@ -0,0 +1,9 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include +#include + +int main(void) { + return !getmntent(stdin); +} diff --git a/build/has/getmntent-2.c b/build/has/getmntent-2.c new file mode 100644 index 0000000..71f0220 --- /dev/null +++ b/build/has/getmntent-2.c @@ -0,0 +1,10 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +#include +#include + +int main(void) { + struct mnttab mnt; + return getmntent(stdin, &mnt); +} diff --git a/build/header.mk b/build/header.mk index 52dcb6a..da6de68 100644 --- a/build/header.mk +++ b/build/header.mk @@ -24,6 +24,8 @@ HEADERS := \ gen/has/getdents.h \ gen/has/getdents64.h \ gen/has/getdents64-syscall.h \ + gen/has/getmntent-1.h \ + gen/has/getmntent-2.h \ gen/has/getmntinfo.h \ gen/has/getprogname.h \ gen/has/getprogname-gnu.h \ diff --git a/src/mtab.c b/src/mtab.c index 9befde3..0377fea 100644 --- a/src/mtab.c +++ b/src/mtab.c @@ -13,11 +13,11 @@ #include #include -#if !defined(BFS_USE_MNTENT) && BFS_USE_MNTENT_H +#if !defined(BFS_USE_MNTENT) && BFS_HAS_GETMNTENT_1 # define BFS_USE_MNTENT true #elif !defined(BFS_USE_MNTINFO) && BFS_HAS_GETMNTINFO # define BFS_USE_MNTINFO true -#elif !defined(BFS_USE_MNTTAB) && __SVR4 +#elif !defined(BFS_USE_MNTTAB) && BFS_HAS_GETMNTENT_2 # define BFS_USE_MNTTAB true #endif -- cgit v1.2.3