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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon May 17 17:57:04 CDT 2010


Author: tzafrir
Date: Mon May 17 17:57:01 2010
New Revision: 8660

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8660
Log:
accept symlinks with complete path, as long as the path ends with span number.

Modified:
    tools/team/tzafrir/sysfs/dahdi_cfg.c

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=8660&r1=8659&r2=8660
==============================================================================
--- tools/team/tzafrir/sysfs/dahdi_cfg.c (original)
+++ tools/team/tzafrir/sysfs/dahdi_cfg.c Mon May 17 17:57:01 2010
@@ -317,12 +317,13 @@
 {
 	char		path[PATH_MAX];
 	struct stat	stbuf;
-	char		spanstr[10];
+	char		spanstr[PATH_MAX];
 	int		span;
 
 	snprintf(path, sizeof(path), "/dev/dahdi/spanmap/%s", span_string);
 	if (lstat(path, &stbuf) >= 0) {
-		int n;
+		int	n;
+		char	*tmp;
 
 		if (! S_ISLNK(stbuf.st_mode)) {
 			error("span '%s' (%s) is not a symlink\n", span_string, path);
@@ -334,9 +335,21 @@
 			return -1;
 		}
 		spanstr[n] = '\0';
-		span_string = spanstr;
-	}
-	if (sscanf(span_string, "%i", &span) != 1) {
+		if((tmp = strrchr(spanstr, '/')) != NULL) {
+			tmp++;	/* skip the last slash */
+		} else {
+			tmp = spanstr;
+		}
+		if (debug & DEBUG_APPLY) {
+			printf("%s: map '%s' to '%s'\n", __func__, spanstr, tmp);
+		}
+		span_string = tmp;
+	} else {
+		if (debug & DEBUG_APPLY) {
+			printf("Failed lstat(%s): %s\n", path, strerror(errno));
+		}
+	}
+	if (sscanf(span_string, "%d", &span) != 1) {
 		error("Span number should be a valid span number, not '%s'\n", span_string);
 		return -1;
 	}




More information about the svn-commits mailing list