[svn-commits] tzafrir: linux/trunk r10686 - /linux/trunk/drivers/dahdi/dahdi-base.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed May 23 07:39:12 CDT 2012


Author: tzafrir
Date: Wed May 23 07:39:07 2012
New Revision: 10686

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10686
Log:
dahdi_ioctl_spanstat() backward compat hack

Signed-off-by: Shaun Ruffell <sruffell at digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

Modified:
    linux/trunk/drivers/dahdi/dahdi-base.c

Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=10686&r1=10685&r2=10686
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Wed May 23 07:39:07 2012
@@ -4361,8 +4361,39 @@
 			sizeof(spaninfo.location));
 	}
 	if (s->spantype) {
-		strlcpy(spaninfo.spantype, dahdi_spantype2str(s->spantype),
-				  sizeof(spaninfo.spantype));
+		/*
+		 * The API is brain-damaged, returning fixed length
+		 * null terminated strings via ioctl() is...
+		 *
+		 * This field contain only 6 characters
+		 * (including null termination, 5 effective characters).
+		 *
+		 * For backward compatibility, massage this info for dahdi-scan
+		 * and friends, until:
+		 *    - They either learn to read the info from sysfs
+		 *    - Or this API is broken to return the enum value
+		 */
+		const char *st = dahdi_spantype2str(s->spantype);
+		switch (s->spantype) {
+		case SPANTYPE_DIGITAL_BRI_NT:
+			strlcpy(spaninfo.spantype, "NT",
+					sizeof(spaninfo.spantype));
+			break;
+		case SPANTYPE_DIGITAL_BRI_TE:
+			strlcpy(spaninfo.spantype, "TE",
+					sizeof(spaninfo.spantype));
+			break;
+		default:
+			/*
+			 * The rest are either short (FXS, FXO, E1, T1, J1)
+			 * Or new (BRI_SOFT, ANALOG_MIXED, INVALID),
+			 * so no backward compatibility for this
+			 * broken interface.
+			 */
+			strlcpy(spaninfo.spantype, st,
+					sizeof(spaninfo.spantype));
+			break;
+		}
 	}
 
 	if (copy_to_user((void __user *)data, &spaninfo, size_to_copy))




More information about the svn-commits mailing list