[svn-commits] tzafrir: branch tools/tzafrir/sysfs r8703 - /tools/team/tzafrir/sysfs/xpp/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu May 27 08:39:07 CDT 2010


Author: tzafrir
Date: Thu May 27 08:39:06 2010
New Revision: 8703

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8703
Log:
pass UDEV information directly to symlink_span:

* Now symlink_span does not need to read attributes from sysfs
  (potentially racy).
* Also, remove each symlink before creating it (if there's previous garbage)
* Use dahdi_cfg changeset:7849 --
  - Try to configure only the current span (-S <spannum>)
  - Use keep-going (-k) so errors on specific channels/spans don't affect
    others

Modified:
    tools/team/tzafrir/sysfs/xpp/symlink_span

Modified: tools/team/tzafrir/sysfs/xpp/symlink_span
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/symlink_span?view=diff&rev=8703&r1=8702&r2=8703
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/symlink_span (original)
+++ tools/team/tzafrir/sysfs/xpp/symlink_span Thu May 27 08:39:06 2010
@@ -21,16 +21,38 @@
 # Our default is to throw it down the bit-bucket.
 #exec 2> /dev/console
 ## If you wish to trace this script:
-#exec 2> "/tmp/${me}" 1>&2
+#exec 2> "/tmp/${me}.$SPAN_NUM" 1>&2
 
 # Our directory in the beginning, so we can use local lab setup
 PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin"
 
 set -e
 
+sysfs_attr_clean() {
+	echo "$1" | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/.-' '_'
+}
+
+ARGS=`getopt -o "H:L:S:" -- "$@"`
+[ $? -eq 0 ] || {
+	echo "$0: getopt failed" >&2
+	exit 1
+}
+eval set -- "$ARGS"
+
+echo >&2 "$0: DEBUG($#): '$*'"
+
+while [ $# -gt 0 ]; do
+        case "$1" in
+                -H) export HARDWARE_ID="$2" ; shift 2 ;;
+                -L) export LOCATION="$2" ; shift 2 ;;
+                -S) export SPAN_ID="$2" ; shift 2 ;;
+                --) shift ; break ;;
+                *) echo 1>&2 "$0: Internal error!" ; exit 1 ;;
+        esac
+done
+
 dahdiconfdir=${dahdiconfdir:-/etc/dahdi}
 initfile="$dahdiconfdir/init.conf"
-
 
 [ -r "$initfile" ] && . "$initfile"
 
@@ -47,26 +69,28 @@
 create_links() {
 	mkdir -p "$SPANNAMES"
 
-	SPAN_ID=`cat "/sys${DEVPATH}/span_id" | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/.-' '_'`
-	if [ "$SPAN_ID" == '' ]; then
+	if [ "$SPAN_ID" = '' ]; then
 		echo >&2 "$0: Missing span_id attribute for '$DEVPATH'"
 		exit 1
 	fi
+	SPAN_ID=`sysfs_attr_clean "$SPAN_ID"`
 	ALIAS=''
-	HARDWARE_ID=`cat "/sys${DEVPATH}/hardware_id" | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/.-' '_'`
 	if [ "$HARDWARE_ID" != '' ]; then
+		HARDWARE_ID=`sysfs_attr_clean "$HARDWARE_ID"`
 		LINK="${SPANNAMES}/${HARDWARE_ID}($SPAN_ID)"
 		#echo "ln -s '$LINK_DEST' '$LINK'" 1>&2
-		ln -s "$LINK_DEST" "$LINK" 1>&2
+		rm -f "$LINK"
+		ln -s "$LINK_DEST" "$LINK"
 		ALIAS=`span_alias "$HARDWARE_ID"`
 	else
 		echo >&2 "$0: Missing hardware_id attribute for '$DEVPATH'"
 	fi
-	LOCATION=`cat "/sys${DEVPATH}/location" | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/.-' '_'`
 	if [ "$LOCATION" != '' ]; then
+		LOCATION=`sysfs_attr_clean "$LOCATION"`
 		LINK="${SPANNAMES}/@${LOCATION}($SPAN_ID)"
 		#echo "ln -s '$LINK_DEST' '$LINK'" 1>&2
-		ln -s "$LINK_DEST" "$LINK" 1>&2
+		rm -f "$LINK"
+		ln -s "$LINK_DEST" "$LINK"
 		if [ "$ALIAS" = '' ]; then
 			ALIAS=`span_alias "$LOCATION"`
 		fi
@@ -76,7 +100,8 @@
 	if [ "$ALIAS" != '' ]; then
 		ALIAS="${SPANNAMES}/$ALIAS($SPAN_ID)"
 		#echo "$0: alias: '$ALIAS'" 1>&2
-		ln -s "$LINK_DEST" "$ALIAS" 1>&2
+		rm -f "$ALIAS"
+		ln -s "$LINK_DEST" "$ALIAS"
 	fi
 }
 
@@ -100,7 +125,7 @@
 online)
 	(
 		create_links
-		dahdi_cfg -k -c "$dahdiconfdir/system.conf"
+		dahdi_cfg -c "$dahdiconfdir/system.conf" -S "$SPAN_NUM" -k
 	) 2>&1 | $LOGGER
 	;;
 offline)




More information about the svn-commits mailing list