diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2016-03-21 15:29:13 +0100 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2016-03-21 15:29:13 +0100 |
commit | d6c8f4fee8392620dd7c33dc8e94ff1d84455633 (patch) | |
tree | 4c15f3964bf225ea7f980c5a692b2659b4de7c00 | |
parent | d6c2acd2902dd75e50d5d7a08f3708fa78f2eb43 (diff) | |
download | nq-d6c8f4fee8392620dd7c33dc8e94ff1d84455633.tar.gz nq-d6c8f4fee8392620dd7c33dc8e94ff1d84455633.tar.xz nq-d6c8f4fee8392620dd7c33dc8e94ff1d84455633.zip |
nq, fq: fall back on when O_DIRECTORY is not defined
-rw-r--r-- | fq.c | 8 | ||||
-rw-r--r-- | nq.c | 4 |
2 files changed, 11 insertions, 1 deletions
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); |