summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr/src/tools/find_elf/find_elf.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/usr/src/tools/find_elf/find_elf.c b/usr/src/tools/find_elf/find_elf.c
index 7c31ccc685..4ece9ac44a 100644
--- a/usr/src/tools/find_elf/find_elf.c
+++ b/usr/src/tools/find_elf/find_elf.c
@@ -229,7 +229,18 @@ process_arg(char *arg)
err(EXIT_FAILURE, "not a file or directory: %s", arg);
}
+#ifndef O_DIRECTORY
+ struct stat tsb;
+ if (stat(dir, &tsb) == -1) {
+ err(EXIT_FAILURE, "failed to stat %s", dir);
+ }
+ if (!S_ISDIR(tsb.st_mode)) {
+ errx(EXIT_FAILURE, "not a directory: %s", dir);
+ }
+ rootfd = open(dir, O_RDONLY);
+#else
rootfd = open(dir, O_RDONLY|O_DIRECTORY);
+#endif
if (rootfd < 0) {
err(EXIT_FAILURE, "%s", dir);
}