From d6c8f4fee8392620dd7c33dc8e94ff1d84455633 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Mon, 21 Mar 2016 15:29:13 +0100 Subject: nq, fq: fall back on when O_DIRECTORY is not defined --- fq.c | 8 +++++++- nq.c | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fq.c b/fq.c index 7364ba7..b92aa56 100644 --- a/fq.c +++ b/fq.c @@ -83,7 +83,11 @@ main(int argc, char *argv[]) if (!path) path = "."; +#ifdef O_DIRECTORY dirfd = open(path, O_RDONLY | O_DIRECTORY); +#else + dirfd = open(path, O_RDONLY); +#endif if (dirfd < 0) { perror("open dir"); exit(111); @@ -99,8 +103,10 @@ main(int argc, char *argv[]) optind = 0; dir = fdopendir(dirfd); - if (!dir) + if (!dir) { + perror("fdopendir"); exit(111); + } while ((d = readdir(dir))) { if (d->d_name[0] != ',') diff --git a/nq.c b/nq.c index 04223bd..67e3485 100644 --- a/nq.c +++ b/nq.c @@ -121,7 +121,11 @@ usage: } } +#ifdef O_DIRECTORY dirfd = open(path, O_RDONLY | O_DIRECTORY); +#else + dirfd = open(path, O_RDONLY); +#endif if (dirfd < 0) { perror("dir open"); exit(111); -- cgit 1.4.1