aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-04-16 07:49:32 -0500
committerRob Landley <rob@landley.net>2014-04-16 07:49:32 -0500
commit76e1cb3ada7fb12f38e248a08c2deedc5c9ce888 (patch)
tree6ec1053bb0095adc78c6c5b0bc691e5a5c602b2c
parent15027d6de049fa139a193abc5a86e6578faf630d (diff)
downloadtoybox-76e1cb3ada7fb12f38e248a08c2deedc5c9ce888.tar.gz
Probe for the existence of FIFREEZE and make fsfreeze depend on it.
-rwxr-xr-xscripts/genconfig.sh25
-rw-r--r--toys/other/fsfreeze.c1
2 files changed, 20 insertions, 6 deletions
diff --git a/scripts/genconfig.sh b/scripts/genconfig.sh
index 8ab26dcc..41f1a173 100755
--- a/scripts/genconfig.sh
+++ b/scripts/genconfig.sh
@@ -7,20 +7,33 @@ mkdir -p generated
source configure
+# Probe for a single config symbol with a "compiles or not" test.
+# Symbol name is first argument, flags second, feed C file to stdin
+probesymbol()
+{
+ ${CROSS_COMPILE}${CC} $CFLAGS -xc -o /dev/null $2 - 2>/dev/null
+ [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n
+ rm a.out 2>/dev/null
+ echo -e "config $1\n\tbool" || exit 1
+ echo -e "\tdefault $DEFAULT\n" || exit 1
+}
+
probeconfig()
{
# Probe for container support on target
-
- echo -e "# container support\nconfig TOYBOX_CONTAINER\n\tbool" || return 1
- ${CROSS_COMPILE}${CC} $CFLAGS -xc -o /dev/null - 2>/dev/null << EOF
+ probesymbol TOYBOX_CONTAINER << EOF
#include <linux/sched.h>
int x=CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET;
int main(int argc, char *argv[]) { return unshare(x); }
EOF
- [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n
- rm a.out 2>/dev/null
- echo -e "\tdefault $DEFAULT\n" || return 1
+
+ probesymbol TOYBOX_FIFREEZE -c << EOF
+ #include <linux/fs.h>
+ #ifndef FIFREEZE
+ #error nope
+ #endif
+EOF
}
genconfig()
diff --git a/toys/other/fsfreeze.c b/toys/other/fsfreeze.c
index f7b8a946..e169554e 100644
--- a/toys/other/fsfreeze.c
+++ b/toys/other/fsfreeze.c
@@ -7,6 +7,7 @@ USE_FSFREEZE(NEWTOY(fsfreeze, "<1>1f|u|[!fu]", TOYFLAG_USR|TOYFLAG_SBIN))
config FSFREEZE
bool "fsfreeze"
default y
+ depends on TOYBOX_FIFREEZE
help
usage: fsfreeze {-f | -u} MOUNTPOINT