[svn-commits] tzafrir: branch tools/tzafrir/sysfs r8749 - in /tools/team/tzafrir/sysfs: ./ ...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Jun 3 18:05:41 CDT 2010
Author: tzafrir
Date: Thu Jun 3 18:05:38 2010
New Revision: 8749
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8749
Log:
dahdi aliases now point directly to hardware names
* Organize span names in hierarchy under their hardware names:
/dev/dahdi/span-names/<hardware_id>/<span_id>
* New dahdi_aliases can:
- create
- delete
- showconf (from config file)
- active (from /dev/dahdi/span-aliases)
* dahdi_aliases (create), is called from /usr/share/dahdi/symlink_spans
if /dev/dahdi/span-aliases does not exist.
Added:
tools/team/tzafrir/sysfs/dahdi_aliases (with props)
Modified:
tools/team/tzafrir/sysfs/dahdi_cfg.c
tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm
tools/team/tzafrir/sysfs/xpp/symlink_span
Added: tools/team/tzafrir/sysfs/dahdi_aliases
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/dahdi_aliases?view=auto&rev=8749
==============================================================================
--- tools/team/tzafrir/sysfs/dahdi_aliases (added)
+++ tools/team/tzafrir/sysfs/dahdi_aliases Thu Jun 3 18:05:38 2010
@@ -1,0 +1,68 @@
+#! /bin/sh
+
+# dahdi_aliases: maintain DAHDI span aliases symlinks
+
+# Written by Oron Peled <oron at actcom.co.il>
+# Copyright (C) 2010, Xorcom
+#
+# All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+usage() {
+ echo >&2 "Usage: $0 {create|delete|active|showconf}"
+ exit 1
+}
+
+dahdiconfdir=${dahdiconfdir:-/etc/dahdi}
+dahdiconfdir=/root/xortel
+ALIASES_FILE="$dahdiconfdir/hardware_aliases"
+
+SPAN_NAMES="/dev/dahdi/span-names"
+SPAN_ALIASES="/dev/dahdi/span-aliases"
+
+clean_aliases() {
+ sed < "$ALIASES_FILE" \
+ -e 's/^#.*//' \
+ -e 's/[ ]*$//' \
+ -e '/^$/d' \
+ -e 's/[ ]\+/\t/'
+}
+
+case "$1" in
+create)
+ mkdir -p "$SPAN_ALIASES"
+ clean_aliases | while read hw_alias hw_id
+ do
+ ln -s "$SPAN_NAMES/$hw_id" "$SPAN_ALIASES/$hw_alias"
+ done
+ ;;
+delete)
+ rm -rf "$SPAN_ALIASES"
+ ;;
+active)
+ ls "$SPAN_ALIASES" | while read name
+ do
+ l=`readlink "$SPAN_ALIASES/$name" | sed "s,$SPAN_NAMES/*,,"`
+ printf "%s\t%s\n" "$name" "$l"
+ done
+ ;;
+showconf)
+ clean_aliases
+ ;;
+*)
+ usage
+ ;;
+esac
Propchange: tools/team/tzafrir/sysfs/dahdi_aliases
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tools/team/tzafrir/sysfs/dahdi_aliases
------------------------------------------------------------------------------
svn:executable = *
Propchange: tools/team/tzafrir/sysfs/dahdi_aliases
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: tools/team/tzafrir/sysfs/dahdi_aliases
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: tools/team/tzafrir/sysfs/dahdi_cfg.c
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/dahdi_cfg.c?view=diff&rev=8749&r1=8748&r2=8749
==============================================================================
--- tools/team/tzafrir/sysfs/dahdi_cfg.c (original)
+++ tools/team/tzafrir/sysfs/dahdi_cfg.c Thu Jun 3 18:05:38 2010
@@ -563,7 +563,7 @@
argstr = pname + 1;
str_replace(prefix, '!', '/');
pname = prefix;
- if (access(pname, R_OK | X_OK) < 0) {
+ if (access(pname, F_OK) < 0) {
error("Missing '%s'\n", pname);
return -1;
}
Modified: tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm?view=diff&rev=8749&r1=8748&r2=8749
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm (original)
+++ tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Span.pm Thu Jun 3 18:05:38 2010
@@ -311,7 +311,7 @@
my $hardware_id = $span->hardware_id;
my $location = $span->location;
my $name_base = '/dev/dahdi/span-aliases';
- my @names = glob "$name_base/*";
+ my @names = glob "$name_base/*/*";
$span->{ALIAS} = '';
foreach my $n (@names) {
next unless -l $n;
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=8749&r1=8748&r2=8749
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/symlink_span (original)
+++ tools/team/tzafrir/sysfs/xpp/symlink_span Thu Jun 3 18:05:38 2010
@@ -52,63 +52,48 @@
done
dahdiconfdir=${dahdiconfdir:-/etc/dahdi}
+export dahdiconfdir
+dahdiconfdir=/tmp/xortel/dahdi
initfile="$dahdiconfdir/init.conf"
[ -r "$initfile" ] && . "$initfile"
-SPANNAMES="/dev/dahdi/span-names"
-SPANALIASES="/dev/dahdi/span-aliases"
+SPAN_NAMES="/dev/dahdi/span-names"
+SPAN_ALIASES="/dev/dahdi/span-aliases"
LINK_DEST="/dev/dahdi/spans/${SPAN_NUM}"
-ALIASES_FILE="$dahdiconfdir/hardware_aliases"
-
-span_alias() {
- if [ -r "$ALIASES_FILE" ]; then
- awk -v span="$1" '$2 ~ span { print $1 }' "$ALIASES_FILE" 2> /dev/null
- fi
-}
create_links() {
- mkdir -p "$SPANNAMES"
- mkdir -p "$SPANALIASES"
+ mkdir -p "$SPAN_NAMES"
if [ "$SPAN_ID" = '' ]; then
echo >&2 "$0($ACTION): Missing span_id attribute for '$DEVPATH'"
exit 1
fi
SPAN_ID=`sysfs_attr_clean "$SPAN_ID"`
- ALIAS=''
if [ "$HARDWARE_ID" != '' ]; then
HARDWARE_ID=`sysfs_attr_clean "$HARDWARE_ID"`
- LINK="${SPANNAMES}/${HARDWARE_ID}($SPAN_ID)"
+ LINK="${SPAN_NAMES}/${HARDWARE_ID}/$SPAN_ID"
#echo "ln -s '$LINK_DEST' '$LINK'" 1>&2
+ mkdir -p "${SPAN_NAMES}/${HARDWARE_ID}"
rm -f "$LINK"
ln -s "$LINK_DEST" "$LINK"
- ALIAS=`span_alias "$HARDWARE_ID"`
else
echo >&2 "$0($ACTION): Missing hardware_id attribute for '$DEVPATH'"
fi
if [ "$LOCATION" != '' ]; then
LOCATION=`sysfs_attr_clean "$LOCATION"`
- LINK="${SPANNAMES}/@${LOCATION}($SPAN_ID)"
+ LINK="${SPAN_NAMES}/@${LOCATION}/$SPAN_ID"
#echo "ln -s '$LINK_DEST' '$LINK'" 1>&2
+ mkdir -p "${SPAN_NAMES}/@${LOCATION}"
rm -f "$LINK"
ln -s "$LINK_DEST" "$LINK"
- if [ "$ALIAS" = '' ]; then
- ALIAS=`span_alias "$LOCATION"`
- fi
else
echo >&2 "$0($ACTION): Missing location attribute for '$DEVPATH'"
- fi
- if [ "$ALIAS" != '' ]; then
- ALIAS="${SPANALIASES}/$ALIAS($SPAN_ID)"
- echo "$0($ACTION): alias: '$ALIAS'" 1>&2
- rm -f "$ALIAS"
- ln -s "$LINK_DEST" "$ALIAS"
fi
}
remove_links() {
- for i in "$SPANNAMES/"* "$SPANALIASES/"*
+ for i in "$SPAN_NAMES/"*
do
if [ -L "$i" ]; then
LINK_DEST=`readlink "$i"`
@@ -119,14 +104,16 @@
fi
fi
done
- #echo "$0($ACTION): Try to remove '$SPANNAMES'"
- rmdir "$SPANNAMES" 1>&2
- rmdir "$SPANALIASES" 1>&2
+ #echo "$0($ACTION): Try to remove '$SPAN_NAMES'"
+ rmdir "$SPAN_NAMES" 1>&2
}
case "$ACTION" in
add)
create_links 2>&1 | $LOGGER
+ if [ ! -d "$SPAN_ALIASES" ]; then
+ "$dir/dahdi_aliases" create
+ fi
;;
remove)
remove_links 2>&1 | $LOGGER
More information about the svn-commits
mailing list