[svn-commits] tzafrir: branch linux/tzafrir/sysfs r8392 - in /linux/team/tzafrir/sysfs: ./ ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Mar 23 06:47:13 CDT 2010


Author: tzafrir
Date: Tue Mar 23 06:47:10 2010
New Revision: 8392

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8392
Log:
udev rules and scriptary to generate persitant logical device names.

Added:
    linux/team/tzafrir/sysfs/dahdi_symlinks   (with props)
Modified:
    linux/team/tzafrir/sysfs/README
    linux/team/tzafrir/sysfs/build_tools/genudevrules

Modified: linux/team/tzafrir/sysfs/README
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/README?view=diff&rev=8392&r1=8391&r2=8392
==============================================================================
--- linux/team/tzafrir/sysfs/README (original)
+++ linux/team/tzafrir/sysfs/README Tue Mar 23 06:47:10 2010
@@ -434,17 +434,34 @@
 with major number 196) . Those device files can be generated statically
 or dynamically through the udev system.
 
+
+Channel Device Files
+^^^^^^^^^^^^^^^^^^^^
+DAHDI will dynamically allocate a separate major number and create a
+device file under /dev/dahdi per channel. Its name is the name of the
+channel. It could be used to reading from the chanel and writing to it,
+as well as applying various control operations using ioctl().
+
+The minor number of that file is the same as those of the device.
+
+It is possible, and recommended, to use udev to generate more logical
+names to those channel device files. See the script dahdi_symlinks on
+how to maintain more logical names for DAHDI channels.
+
+(This interface was originally limited with up to channel no. 249, and
+hence using /dev/dahdi/channel was preffered).
+
+
+Control Device Files
+^^^^^^^^^^^^^^^^^^^^
 * /dev/dahdi/ctl (196:0) - a general device file for various information and
-  control operations on the DAHDI channels.
-* /dev/dahdi/NNN (196:NNN) - for NNN in the range 1-249. A device file for
-  DAHDI channel NNN. It can be used to read data from the channel
-  and write data to the channel.
+  control operations on the DAHDI channels. Many of the control
+  operations can be applied through either the channel or the ctl file.
 * /dev/dahdi/transcode (196:250) - Used to connect to a DAHDI transcoding
   device.
 * /dev/dahdi/timer (196:253) - Allows setting timers. Used anywhere?
 * /dev/dahdi/channel (196:254) - Can be used to open an arbitrary DAHDI
-  channel. This is an alternative to /dev/dahdi/NNN that is not limited to
-  249 channels.
+  channel. This is an alternative to /dev/dahdi/NNN.
 * /dev/dahdi/pseudo (196:255) - A timing-only device. Every time you open
   it, a new DAHDI channel is created. That DAHDI channel is "pseudo" -
   DAHDI receives no data in it, and only sends garbage data with the

Modified: linux/team/tzafrir/sysfs/build_tools/genudevrules
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/build_tools/genudevrules?view=diff&rev=8392&r1=8391&r2=8392
==============================================================================
--- linux/team/tzafrir/sysfs/build_tools/genudevrules (original)
+++ linux/team/tzafrir/sysfs/build_tools/genudevrules Tue Mar 23 06:47:10 2010
@@ -37,4 +37,5 @@
 
 # DAHDI devices with ownership/permissions for running as non-root
 SUBSYSTEM${match}"dahdi",  OWNER="asterisk", GROUP="asterisk", MODE="0660"
+SUBSYSTEM${match}"dahdi",  PROGRAM="/usr/share/dahdi/dahdi_symlinks" SYMLINK+="\$result"
 EOF

Added: linux/team/tzafrir/sysfs/dahdi_symlinks
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/dahdi_symlinks?view=auto&rev=8392
==============================================================================
--- linux/team/tzafrir/sysfs/dahdi_symlinks (added)
+++ linux/team/tzafrir/sysfs/dahdi_symlinks Tue Mar 23 06:47:10 2010
@@ -1,0 +1,70 @@
+#! /bin/sh
+
+# a wrapper to kernel-doc from the kernel source tree
+#
+# Copyright (C) 2010 by Xorcom <support at xorcom.com>
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+# dahdy_symlinks: list of symlinks to point to a device of a DAHDI channel
+#
+# This script is to be used by udevd through udev rules. It should
+# output a list of symbolic links that should point to the channel.
+# This is used at startup to generate those links and at shutdown to
+# remove them.
+#
+# Having an extra directory element in this script is perfectly OK.
+#
+# The names are directory names that default to the content of the
+# span's 'location' field, but may ibe further mapped using a simple
+# mapping script.
+#
+# Inside the directory, file names are based on the 'chanpos', that is,
+# the number of the channel in the span (1-based).
+#
+# An example /etc/dahdi/span_aliases:
+#
+# #! /bin/sed -f
+# # Alias a single wcfxo:
+# s/^PCI_Bus_01_Slot_10/wildcard/
+# # Alias a single Astribank: Each xpd (span) gets a separate subdir under
+# # /dev/dahdi/ab-lab5/
+# s/^usb-0000:00:1d_7-3/ab-lab5/
+
+set -e
+
+#exec 2> /tmp/dahdi-symlinks-$$.env
+#env 1>&2
+#set -x
+
+# DEVPATH: The path under /sys with the node of the channel's device.
+#          Set by the kernel when emmiting an event. 
+
+# LOCATION: The 'location' field of the channel's span with special
+#           characters replaced by a '_' except '!' that is replaced by
+#           '/'.
+LOCATION=`cat "/sys/$DEVPATH/device/location" | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/:-' '_' | /etc/dahdi/span_aliases`
+if [ "$LOCATION" == '' ]; then
+	echo >&2 "$0: Missing location attribute"
+	exit 1
+fi
+CHANPOS=`cat "/sys/$DEVPATH/chanpos"`
+if [ "$CHANPOS" == '' ]; then
+	echo >&2 "$0: Missing chanpos attribute"
+	exit 1
+fi
+LINKTO="dahdi/$LOCATION/$CHANPOS"
+#echo "$LINKTO" 1>&2
+echo "$LINKTO"

Propchange: linux/team/tzafrir/sysfs/dahdi_symlinks
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: linux/team/tzafrir/sysfs/dahdi_symlinks
------------------------------------------------------------------------------
    svn:executable = *

Propchange: linux/team/tzafrir/sysfs/dahdi_symlinks
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: linux/team/tzafrir/sysfs/dahdi_symlinks
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the svn-commits mailing list