diff options
author | Rob Landley <rob@landley.net> | 2013-03-11 22:23:46 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2013-03-11 22:23:46 -0500 |
commit | 25b043bff9de65abc0926c04053f3ba5ea8f30f7 (patch) | |
tree | ac418794a3072c1d8dc99c2ab11c7be902f9ccd0 | |
parent | 364d9ab6aa7fc6fb2b28147dd73d2183b15b45ae (diff) | |
download | toybox-25b043bff9de65abc0926c04053f3ba5ea8f30f7.tar.gz |
Compile time probe to fish O_NOFOLLOW out of linux headers when fcntl doesn't conform to posix-2008.0.4.4
-rw-r--r-- | lib/portability.h | 2 | ||||
-rwxr-xr-x | scripts/genconfig.sh | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/lib/portability.h b/lib/portability.h index feaf7894..745f8cd9 100644 --- a/lib/portability.h +++ b/lib/portability.h @@ -145,3 +145,5 @@ int clearenv(void); ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream); ssize_t getline(char **lineptr, size_t *n, FILE *stream); #endif + +#include "generated/portability.h" diff --git a/scripts/genconfig.sh b/scripts/genconfig.sh index dedfde4d..b1eb2a8e 100755 --- a/scripts/genconfig.sh +++ b/scripts/genconfig.sh @@ -49,5 +49,33 @@ genconfig() done } +headerprobes() +{ + ${CROSS_COMPILE}${CC} -xc -o /dev/null - 2>/dev/null << EOF + #include <fcntl.h> + #ifndef O_NOFOLLOW + #error posix 2008 was a while ago now + #endif +EOF + if [ $? -ne 0 ] + then + rm -f a.out + ${CROSS_COMPILE}${CC} -xc - 2>/dev/null << EOF + #include <stdio.h> + #include <sys/types.h> + #include <asm/fcntl.h> + + int main(int argc, char *argv[]) + { + printf("0x%x\n", O_NOFOLLOW); + } +EOF + X=$(./a.out) 2>/dev/null + rm -f a.out + echo "#define O_NOFOLLOW ${X:-0}" + fi +} + probeconfig > generated/Config.probed || rm generated/Config.probed genconfig > generated/Config.in || rm generated/Config.in +headerprobes > generated/portability.h || rm generated/portability.h |