summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-05-23 12:39:07 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-05-23 12:39:07 +0000
commit2084c82df834a4d9882a1878510577e1aa715ee3 (patch)
treeed5320b087679bb77da9a04963c5450211ec5537
parent94b80ba13567379ef2fc4e7efd7ac3d87515f242 (diff)
dahdi_ioctl_spanstat() backward compat hack
Signed-off-by: Shaun Ruffell <sruffell@digium.com> Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10686 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--drivers/dahdi/dahdi-base.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index 85dafd0..70edabc 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -4361,8 +4361,39 @@ static int dahdi_ioctl_spanstat(struct file *file, unsigned long data)
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))