root / dev-utils / link_module_to_source.sh @ master
History | View | Annotate | Download (1.1 KB)
| 1 | if [ -z "$1" ] ; then |
|---|---|
| 2 | echo "must specify module name" |
| 3 | fi |
| 4 | if [ -z "$2" ] ; then |
| 5 | echo "must specify src dir" |
| 6 | exit; |
| 7 | fi |
| 8 | |
| 9 | |
| 10 | module_name="$1" |
| 11 | |
| 12 | #get absolute paths |
| 13 | current_dir=$(pwd) |
| 14 | cd $current_dir |
| 15 | cd $2 |
| 16 | src_dir=$(pwd) |
| 17 | cd $current_dir |
| 18 | |
| 19 | |
| 20 | module=$(ls -d $src_dir/build*/lin*/lin*/net/ipv4/netfilter/*$module_name.c 2>/dev/null) |
| 21 | deps=$(ls -d $src_dir/build*/lin*/lin*/net/ipv4/netfilter/$module_name"_deps" 2>/dev/null) |
| 22 | header=$(ls -d $src_dir/build*/lin*/lin*/include/linux/netfilter_ipv4/*$module_name.h 2>/dev/null) |
| 23 | extension=$(ls -d $src_dir/build*/lin*/iptables*/exten*/*$module_name.c 2>/dev/null) |
| 24 | |
| 25 | net_dir="$current_dir/netfilter-match-modules" |
| 26 | |
| 27 | if [ -n "$module" ] ; then |
| 28 | rm -rf "$module" |
| 29 | ln -s $net_dir/$module_name/module/ipt_$module_name.c "$module" |
| 30 | fi |
| 31 | if [ -n "$deps" ] ; then |
| 32 | rm -rf "$deps" |
| 33 | ln -s "$net_dir/$module_name/module/$module_name"_deps "$deps" |
| 34 | fi |
| 35 | if [ -n "$header" ] ; then |
| 36 | rm -rf "$header" |
| 37 | ln -s $net_dir/$module_name/header/ipt_$module_name.h "$header" |
| 38 | fi |
| 39 | if [ -n "$extension" ] ; then |
| 40 | rm -rf "$extension" |
| 41 | ln -s $net_dir/$module_name/extension/libipt_$module_name.c "$extension" |
| 42 | fi |
| 43 |