summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/runqemu-gen-tapdevs16
1 files changed, 9 insertions, 7 deletions
diff --git a/scripts/runqemu-gen-tapdevs b/scripts/runqemu-gen-tapdevs
index 15bccd4484..2c1ff0eefb 100755
--- a/scripts/runqemu-gen-tapdevs
+++ b/scripts/runqemu-gen-tapdevs
@@ -23,7 +23,8 @@
23# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 24
25usage() { 25usage() {
26 echo "Usage: sudo $0 <gid> <num> <native-sysroot-basedir>" 26 echo "Usage: sudo $0 <uid> <gid> <num> <native-sysroot-basedir>"
27 echo "Where <uid> is the numeric user id the tap devices will be owned by"
27 echo "Where <gid> is the numeric group id the tap devices will be owned by" 28 echo "Where <gid> is the numeric group id the tap devices will be owned by"
28 echo "<num> is the number of tap devices to create (0 to remove all)" 29 echo "<num> is the number of tap devices to create (0 to remove all)"
29 echo "<native-sysroot-basedir> is the path to the build system's native sysroot" 30 echo "<native-sysroot-basedir> is the path to the build system's native sysroot"
@@ -35,14 +36,15 @@ if [ $EUID -ne 0 ]; then
35 exit 36 exit
36fi 37fi
37 38
38if [ $# -ne 3 ]; then 39if [ $# -ne 4 ]; then
39 echo "Error: Incorrect number of arguments" 40 echo "Error: Incorrect number of arguments"
40 usage 41 usage
41fi 42fi
42 43
43GID=$1 44TUID=$1
44COUNT=$2 45GID=$2
45SYSROOT=$3 46COUNT=$3
47SYSROOT=$4
46 48
47TUNCTL=$SYSROOT/usr/bin/tunctl 49TUNCTL=$SYSROOT/usr/bin/tunctl
48if [[ ! -x "$TUNCTL" || -d "$TUNCTL" ]]; then 50if [[ ! -x "$TUNCTL" || -d "$TUNCTL" ]]; then
@@ -73,10 +75,10 @@ for tap in `$IFCONFIG | grep ^tap | awk '{ print \$1 }'`; do
73 $TUNCTL -d $tap 75 $TUNCTL -d $tap
74done 76done
75 77
76echo "Creating $COUNT tap devices for GID $GID..." 78echo "Creating $COUNT tap devices for UID: $TUID GID: $GID..."
77for ((index=0; index < $COUNT; index++)); do 79for ((index=0; index < $COUNT; index++)); do
78 echo "Creating tap$index" 80 echo "Creating tap$index"
79 ifup=`$RUNQEMU_IFUP $GID $SYSROOT 2>&1` 81 ifup=`$RUNQEMU_IFUP $TUID $GID $SYSROOT 2>&1`
80 if [ $? -ne 0 ]; then 82 if [ $? -ne 0 ]; then
81 echo "Error running tunctl: $ifup" 83 echo "Error running tunctl: $ifup"
82 exit 1 84 exit 1