Merged revisions 125327 via svnmerge from
authorKevin P. Fleming <kpfleming@digium.com>
Thu, 26 Jun 2008 15:50:07 +0000 (15:50 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Thu, 26 Jun 2008 15:50:07 +0000 (15:50 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r125327 | kpfleming | 2008-06-26 10:30:33 -0500 (Thu, 26 Jun 2008) | 5 lines

ensure that (whenever possible) if we generate a log message because an ioctl() call to DAHDI/Zaptel failed, that we include the reason it failed by including the stringified error number

(issue AST-80)

........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@125333 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_dahdi.c

index 804d272..61fdf46 100644 (file)
@@ -1153,13 +1153,13 @@ static int alloc_sub(struct dahdi_pvt *p, int x)
                bi.numbufs = numbufs;
                res = ioctl(p->subs[x].zfd, DAHDI_SET_BUFINFO, &bi);
                if (res < 0) {
-                       ast_log(LOG_WARNING, "Unable to set buffer policy on channel %d\n", x);
+                       ast_log(LOG_WARNING, "Unable to set buffer policy on channel %d: %s\n", x, strerror(errno));
                }
        } else 
-               ast_log(LOG_WARNING, "Unable to check buffer policy on channel %d\n", x);
+               ast_log(LOG_WARNING, "Unable to check buffer policy on channel %d: %s\n", x, strerror(errno));
 
        if (ioctl(p->subs[x].zfd, DAHDI_CHANNO, &p->subs[x].chan) == 1) {
-               ast_log(LOG_WARNING, "Unable to get channel number for pseudo channel on FD %d\n", p->subs[x].zfd);
+               ast_log(LOG_WARNING, "Unable to get channel number for pseudo channel on FD %d: %s\n", p->subs[x].zfd, strerror(errno));
                dahdi_close(p->subs[x].zfd);
                p->subs[x].zfd = -1;
                return -1;
@@ -1251,7 +1251,7 @@ static int dahdi_digit_begin(struct ast_channel *chan, char digit)
                zo.dialstr[1] = digit;
                zo.dialstr[2] = '\0';
                if ((res = ioctl(pvt->subs[SUB_REAL].zfd, DAHDI_DIAL, &zo)))
-                       ast_log(LOG_WARNING, "Couldn't dial digit %c\n", digit);
+                       ast_log(LOG_WARNING, "Couldn't dial digit %c: %s\n", digit, strerror(errno));
                else
                        pvt->dialing = 1;
        } else {
@@ -1462,7 +1462,7 @@ static int conf_add(struct dahdi_pvt *p, struct dahdi_subchannel *c, int index,
        if (c->zfd < 0)
                return 0;
        if (ioctl(c->zfd, DAHDI_SETCONF, &zi)) {
-               ast_log(LOG_WARNING, "Failed to add %d to conference %d/%d\n", c->zfd, zi.confmode, zi.confno);
+               ast_log(LOG_WARNING, "Failed to add %d to conference %d/%d: %s\n", c->zfd, zi.confmode, zi.confno, strerror(errno));
                return -1;
        }
        if (slavechannel < 1) {
@@ -1498,7 +1498,7 @@ static int conf_del(struct dahdi_pvt *p, struct dahdi_subchannel *c, int index)
        zi.confno = 0;
        zi.confmode = 0;
        if (ioctl(c->zfd, DAHDI_SETCONF, &zi)) {
-               ast_log(LOG_WARNING, "Failed to drop %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
+               ast_log(LOG_WARNING, "Failed to drop %d from conference %d/%d: %s\n", c->zfd, c->curconf.confmode, c->curconf.confno, strerror(errno));
                return -1;
        }
        ast_debug(1, "Removed %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
@@ -1558,7 +1558,7 @@ static int reset_conf(struct dahdi_pvt *p)
        memset(&p->subs[SUB_REAL].curconf, 0, sizeof(p->subs[SUB_REAL].curconf));
        if (p->subs[SUB_REAL].zfd > -1) {
                if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_SETCONF, &zi))
-                       ast_log(LOG_WARNING, "Failed to reset conferencing on channel %d!\n", p->channel);
+                       ast_log(LOG_WARNING, "Failed to reset conferencing on channel %d: %s\n", p->channel, strerror(errno));
        }
        return 0;
 }
@@ -1660,7 +1660,7 @@ static void dahdi_train_ec(struct dahdi_pvt *p)
                x = p->echotraining;
                res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_ECHOTRAIN, &x);
                if (res)
-                       ast_log(LOG_WARNING, "Unable to request echo training on channel %d\n", p->channel);
+                       ast_log(LOG_WARNING, "Unable to request echo training on channel %d: %s\n", p->channel, strerror(errno));
                else
                        ast_debug(1, "Engaged echo training on channel %d\n", p->channel);
        } else {
@@ -1678,7 +1678,7 @@ static void dahdi_disable_ec(struct dahdi_pvt *p)
                res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_ECHOCANCEL_PARAMS, &ecp);
 
                if (res)
-                       ast_log(LOG_WARNING, "Unable to disable echo cancellation on channel %d\n", p->channel);
+                       ast_log(LOG_WARNING, "Unable to disable echo cancellation on channel %d: %s\n", p->channel, strerror(errno));
                else
                        ast_debug(1, "Disabled echo cancellation on channel %d\n", p->channel);
        }
@@ -1846,7 +1846,7 @@ static inline int dahdi_confmute(struct dahdi_pvt *p, int muted)
                y = 1;
                res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_AUDIOMODE, &y);
                if (res)
-                       ast_log(LOG_WARNING, "Unable to set audio mode on '%d'\n", p->channel);
+                       ast_log(LOG_WARNING, "Unable to set audio mode on %d: %s\n", p->channel, strerror(errno));
        }
        res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_CONFMUTE, &x);
        if (res < 0)
@@ -2095,7 +2095,7 @@ static int dahdi_call(struct ast_channel *ast, char *rdest, int timeout)
        x = DAHDI_FLUSH_READ | DAHDI_FLUSH_WRITE;
        res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_FLUSH, &x);
        if (res)
-               ast_log(LOG_WARNING, "Unable to flush input on channel %d\n", p->channel);
+               ast_log(LOG_WARNING, "Unable to flush input on channel %d: %s\n", p->channel, strerror(errno));
        p->outgoing = 1;
 
        set_actual_gain(p->subs[SUB_REAL].zfd, 0, p->rxgain, p->txgain, p->law);
@@ -2129,11 +2129,11 @@ static int dahdi_call(struct ast_channel *ast, char *rdest, int timeout)
                        /* Choose proper cadence */
                        if ((p->distinctivering > 0) && (p->distinctivering <= num_cadence)) {
                                if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_SETCADENCE, &cadences[p->distinctivering - 1]))
-                                       ast_log(LOG_WARNING, "Unable to set distinctive ring cadence %d on '%s'\n", p->distinctivering, ast->name);
+                                       ast_log(LOG_WARNING, "Unable to set distinctive ring cadence %d on '%s': %s\n", p->distinctivering, ast->name, strerror(errno));
                                p->cidrings = cidrings[p->distinctivering - 1];
                        } else {
                                if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_SETCADENCE, NULL))
-                                       ast_log(LOG_WARNING, "Unable to reset default ring on '%s'\n", ast->name);
+                                       ast_log(LOG_WARNING, "Unable to reset default ring on '%s': %s\n", ast->name, strerror(errno));
                                p->cidrings = p->sendcalleridafter;
                        }
 
@@ -2309,9 +2309,11 @@ static int dahdi_call(struct ast_channel *ast, char *rdest, int timeout)
                        p->echobreak = 0;
                if (!res) {
                        if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_DIAL, &p->dop)) {
+                               int saveerr = errno;
+
                                x = DAHDI_ONHOOK;
                                ioctl(p->subs[SUB_REAL].zfd, DAHDI_HOOK, &x);
-                               ast_log(LOG_WARNING, "Dialing failed on channel %d: %s\n", p->channel, strerror(errno));
+                               ast_log(LOG_WARNING, "Dialing failed on channel %d: %s\n", p->channel, strerror(saveerr));
                                ast_mutex_unlock(&p->lock);
                                return -1;
                        }
@@ -3121,7 +3123,7 @@ static int dahdi_hangup(struct ast_channel *ast)
                law = DAHDI_LAW_DEFAULT;
                res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_SETLAW, &law);
                if (res < 0) 
-                       ast_log(LOG_WARNING, "Unable to set law on channel %d to default\n", p->channel);
+                       ast_log(LOG_WARNING, "Unable to set law on channel %d to default: %s\n", p->channel, strerror(errno));
                /* Perform low level hangup if no owner left */
 #ifdef HAVE_SS7
                if (p->ss7) {
@@ -3543,7 +3545,7 @@ static int dahdi_setoption(struct ast_channel *chan, int option, void *data, int
                        x = 1;
                }
                if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_AUDIOMODE, &x) == -1)
-                       ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d\n", p->channel, x);
+                       ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d: %s\n", p->channel, x, strerror(errno));
                break;
        case AST_OPTION_OPRMODE:  /* Operator services mode */
                oprmode = (struct oprmode *) data;
@@ -4146,7 +4148,7 @@ static int check_for_conference(struct dahdi_pvt *p)
                return 0;
        memset(&ci, 0, sizeof(ci));
        if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_GETCONF, &ci)) {
-               ast_log(LOG_WARNING, "Failed to get conference info on channel %d\n", p->channel);
+               ast_log(LOG_WARNING, "Failed to get conference info on channel %d: %s\n", p->channel, strerror(errno));
                return 0;
        }
        /* If we have no master and don't have a confno, then 
@@ -4172,9 +4174,13 @@ static int get_alarms(struct dahdi_pvt *p)
 
        memset(&zi, 0, sizeof(zi));
        zi.spanno = p->span;
+
        if ((res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_SPANSTAT, &zi)) >= 0) {
                if (zi.alarms != DAHDI_ALARM_NONE)
                        return zi.alarms;
+       } else {
+               ast_log(LOG_WARNING, "Unable to determine alarm on channel %d: %s\n", p->channel, strerror(errno));
+               return 0;
        }
 
        /* No alarms on the span. Check for channel alarms. */
@@ -4317,7 +4323,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                        if (p->inalarm) break;
                        if ((p->radio || (p->oprmode < 0))) break;
                        if (ioctl(p->subs[index].zfd,DAHDI_DIALING,&x) == -1) {
-                               ast_debug(1, "DAHDI_DIALING ioctl failed on %s\n",ast->name);
+                               ast_log(LOG_DEBUG, "DAHDI_DIALING ioctl failed on %s: %s\n",ast->name, strerror(errno));
                                return NULL;
                        }
                        if (!x) { /* if not still dialing in driver */
@@ -4565,9 +4571,11 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                } else
                                        p->echobreak = 0;
                                if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_DIAL, &p->dop)) {
+                                       int saveerr = errno;
+
                                        x = DAHDI_ONHOOK;
                                        ioctl(p->subs[SUB_REAL].zfd, DAHDI_HOOK, &x);
-                                       ast_log(LOG_WARNING, "Dialing failed on channel %d: %s\n", p->channel, strerror(errno));
+                                       ast_log(LOG_WARNING, "Dialing failed on channel %d: %s\n", p->channel, strerror(saveerr));
                                        return NULL;
                                        }
                                p->dialing = 1;
@@ -4601,7 +4609,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                                /* nick@dccinc.com 4/3/03 - fxo should be able to do deferred dialing */
                                                res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_DIAL, &p->dop);
                                                if (res < 0) {
-                                                       ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", p->channel);
+                                                       ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d: %s\n", p->channel, strerror(errno));
                                                        p->dop.dialstr[0] = '\0';
                                                        return NULL;
                                                } else {
@@ -4954,7 +4962,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                if (!ast_strlen_zero(p->dop.dialstr)) {
                                        res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_DIAL, &p->dop);
                                        if (res < 0) {
-                                               ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", p->channel);
+                                               ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d: %s\n", p->channel, strerror(errno));
                                                p->dop.dialstr[0] = '\0';
                                                return NULL;
                                        } else 
@@ -4983,7 +4991,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
                                if (!ast_strlen_zero(p->dop.dialstr)) {
                                        res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_DIAL, &p->dop);
                                        if (res < 0) {
-                                               ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", p->channel);
+                                               ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d: %s\n", p->channel, strerror(errno));
                                                p->dop.dialstr[0] = '\0';
                                                return NULL;
                                        } else 
@@ -5840,7 +5848,7 @@ static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpb
        ps.channo = i->channel;
        res = ioctl(i->subs[SUB_REAL].zfd, DAHDI_GET_PARAMS, &ps);
        if (res) {
-               ast_log(LOG_WARNING, "Unable to get parameters, assuming MULAW\n");
+               ast_log(LOG_WARNING, "Unable to get parameters, assuming MULAW: %s\n", strerror(errno));
                ps.curlaw = DAHDI_LAW_MULAW;
        }
        if (ps.curlaw == DAHDI_LAW_ALAW)
@@ -7509,7 +7517,7 @@ static void *mwi_send_thread(void *data)
                                /* Send the Ring Pulse Signal Alert */
                                res = ioctl(mtd->pvt->subs[SUB_REAL].zfd, DAHDI_SETCADENCE, &AS_RP_cadence);
                                if (res) {
-                                       ast_log(LOG_WARNING, "Unable to set RP-AS ring cadence\n");
+                                       ast_log(LOG_WARNING, "Unable to set RP-AS ring cadence: %s\n", strerror(errno));
                                        goto quit;
                                }
                                dahdi_set_hook(mtd->pvt->subs[SUB_REAL].zfd, DAHDI_RING);
@@ -7917,7 +7925,7 @@ static void *do_monitor(void *data)
 #ifdef DAHDI_VMWI
                                                                res2 = ioctl(last->subs[SUB_REAL].zfd, DAHDI_VMWI, res);
                                                                if (res2) {
-                                                                       ast_log(LOG_DEBUG, "Unable to control message waiting led on channel %d\n", last->channel);
+                                                                       ast_log(LOG_DEBUG, "Unable to control message waiting led on channel %d: %s\n", last->channel, strerror(errno));
                                                                }
 #endif
                                                                pthread_attr_init(&attr);
@@ -8123,7 +8131,7 @@ static int pri_create_trunkgroup(int trunkgroup, int *channels)
                        return -1;
                }
                if (ioctl(fd, DAHDI_SPANSTAT, &si)) {
-                       ast_log(LOG_WARNING, "Failed go get span information on channel %d (span %d)\n", channels[y], p.spanno);
+                       ast_log(LOG_WARNING, "Failed go get span information on channel %d (span %d): %s\n", channels[y], p.spanno, strerror(errno));
                        dahdi_close(fd);
                        return -1;
                }
@@ -8274,7 +8282,7 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf,
                                memset(&p, 0, sizeof(p));
                                res = ioctl(tmp->subs[SUB_REAL].zfd, DAHDI_GET_PARAMS, &p);
                                if (res < 0) {
-                                       ast_log(LOG_ERROR, "Unable to get parameters\n");
+                                       ast_log(LOG_ERROR, "Unable to get parameters: %s\n", strerror(errno));
                                        destroy_dahdi_pvt(&tmp);
                                        return NULL;
                                }
@@ -8524,7 +8532,7 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf,
                {
                        res = ioctl(tmp->subs[SUB_REAL].zfd, DAHDI_SET_PARAMS, &p);
                        if (res < 0) {
-                               ast_log(LOG_ERROR, "Unable to set parameters\n");
+                               ast_log(LOG_ERROR, "Unable to set parameters: %s\n", strerror(errno));
                                destroy_dahdi_pvt(&tmp);
                                return NULL;
                        }
@@ -8539,10 +8547,10 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf,
                                bi.numbufs = numbufs;
                                res = ioctl(tmp->subs[SUB_REAL].zfd, DAHDI_SET_BUFINFO, &bi);
                                if (res < 0) {
-                                       ast_log(LOG_WARNING, "Unable to set buffer policy on channel %d\n", channel);
+                                       ast_log(LOG_WARNING, "Unable to set buffer policy on channel %d: %s\n", channel, strerror(errno));
                                }
                        } else
-                               ast_log(LOG_WARNING, "Unable to check buffer policy on channel %d\n", channel);
+                               ast_log(LOG_WARNING, "Unable to check buffer policy on channel %d: %s\n", channel, strerror(errno));
                }
 #endif
                tmp->immediate = conf->chan.immediate;
@@ -8821,7 +8829,7 @@ static inline int available(struct dahdi_pvt *p, int channelmatch, ast_group_t g
                                par.rxisoffhook = 0;
                        }
                        if (res) {
-                               ast_log(LOG_WARNING, "Unable to check hook state on channel %d\n", p->channel);
+                               ast_log(LOG_WARNING, "Unable to check hook state on channel %d: %s\n", p->channel, strerror(errno));
                        } else if ((p->sig == SIG_FXSKS) || (p->sig == SIG_FXSGS)) {
                                /* When "onhook" that means no battery on the line, and thus
                                  it is out of service..., if it's on a TDM card... If it's a channel
@@ -8895,10 +8903,10 @@ static struct dahdi_pvt *chandup(struct dahdi_pvt *src)
                        bi.numbufs = numbufs;
                        res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_SET_BUFINFO, &bi);
                        if (res < 0) {
-                               ast_log(LOG_WARNING, "Unable to set buffer policy on dup channel\n");
+                               ast_log(LOG_WARNING, "Unable to set buffer policy on dup channel: %s\n", strerror(errno));
                        }
                } else
-                       ast_log(LOG_WARNING, "Unable to check buffer policy on dup channel\n");
+                       ast_log(LOG_WARNING, "Unable to check buffer policy on dup channel: %s\n", strerror(errno));
        }
        p->destroy = 1;
        p->next = iflist;
@@ -9269,7 +9277,7 @@ static void dahdi_loopback(struct dahdi_pvt *p, int enable)
 {
        if (p->loopedback != enable) {
                if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_LOOPBACK, &enable)) {
-                       ast_log(LOG_WARNING, "Unable to set loopback on channel %d\n", p->channel);
+                       ast_log(LOG_WARNING, "Unable to set loopback on channel %d: %s\n", p->channel, strerror(errno));
                        return;
                }
                p->loopedback = enable;
@@ -9286,7 +9294,7 @@ static void ss7_start_call(struct dahdi_pvt *p, struct dahdi_ss7 *linkset)
        char tmp[256];
 
        if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_AUDIOMODE, &law) == -1)
-               ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d\n", p->channel, law);
+               ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d: %s\n", p->channel, law, strrerror(errno));
        
        if (linkset->type == SS7_ITU)
                law = DAHDI_LAW_ALAW;
@@ -10788,7 +10796,7 @@ static void *pri_dchannel(void *vpri)
                                                        /* Set to audio mode at this point */
                                                        law = 1;
                                                        if (ioctl(pri->pvts[chanpos]->subs[SUB_REAL].zfd, DAHDI_AUDIOMODE, &law) == -1)
-                                                               ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d\n", pri->pvts[chanpos]->channel, law);
+                                                               ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d: %s\n", pri->pvts[chanpos]->channel, law, strerror(errno));
                                                }
                                                if (e->ring.layer1 == PRI_LAYER_1_ALAW)
                                                        law = DAHDI_LAW_ALAW;
@@ -11103,7 +11111,7 @@ static void *pri_dchannel(void *vpri)
                                                        /* Send any "w" waited stuff */
                                                        res = ioctl(pri->pvts[chanpos]->subs[SUB_REAL].zfd, DAHDI_DIAL, &pri->pvts[chanpos]->dop);
                                                        if (res < 0) {
-                                                               ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", pri->pvts[chanpos]->channel);
+                                                               ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d: %s\n", pri->pvts[chanpos]->channel, strerror(errno));
                                                                pri->pvts[chanpos]->dop.dialstr[0] = '\0';
                                                        } else
                                                                ast_debug(1, "Sent deferred digit string: %s\n", pri->pvts[chanpos]->dop.dialstr);
@@ -11426,7 +11434,7 @@ static int start_pri(struct dahdi_pri *pri)
                if ((p.sigtype != DAHDI_SIG_HDLCFCS) && (p.sigtype != DAHDI_SIG_HARDHDLC)) {
                        dahdi_close(pri->fds[i]);
                        pri->fds[i] = -1;
-                       ast_log(LOG_ERROR, "D-channel %d is not in HDLC/FCS mode.  See /etc/dahdi.conf\n", x);
+                       ast_log(LOG_ERROR, "D-channel %d is not in HDLC/FCS mode.\n", x);
                        return -1;
                }
                memset(&si, 0, sizeof(si));
@@ -11445,7 +11453,7 @@ static int start_pri(struct dahdi_pri *pri)
                bi.numbufs = 32;
                bi.bufsize = 1024;
                if (ioctl(pri->fds[i], DAHDI_SET_BUFINFO, &bi)) {
-                       ast_log(LOG_ERROR, "Unable to set appropriate buffering on channel %d\n", x);
+                       ast_log(LOG_ERROR, "Unable to set appropriate buffering on channel %d: %s\n", x, strerror(errno));
                        dahdi_close(pri->fds[i]);
                        pri->fds[i] = -1;
                        return -1;
@@ -12276,7 +12284,7 @@ static char *dahdi_show_channel(struct ast_cli_entry *e, int cmd, struct ast_cli
                                }
 #endif
                                if (ioctl(tmp->subs[SUB_REAL].zfd, DAHDI_GET_PARAMS, &ps) < 0) {
-                                       ast_log(LOG_WARNING, "Failed to get parameters on channel %d\n", tmp->channel);
+                                       ast_log(LOG_WARNING, "Failed to get parameters on channel %d: %s\n", tmp->channel, strerror(errno));
                                } else {
                                        ast_cli(a->fd, "Hookstate (FXS only): %s\n", ps.rxisoffhook ? "Offhook" : "Onhook");
                                }
@@ -12500,7 +12508,7 @@ static char *dahdi_show_version(struct ast_cli_entry *e, int cmd, struct ast_cli
        strcpy(vi.echo_canceller, "Unknown");
 
        if (ioctl(pseudo_fd, DAHDI_GETVERSION, &vi))
-               ast_cli(a->fd, "Failed to get version from control file.\n");
+               ast_cli(a->fd, "Failed to get DAHDI version: %s\n", strerror(errno));
        else
                ast_cli(a->fd, "DAHDI Version: %s Echo Canceller: %s\n", vi.version, vi.echo_canceller);
 
@@ -12577,7 +12585,7 @@ static char *dahdi_set_hwgain(struct ast_cli_entry *e, int cmd, struct ast_cli_a
                hwgain.newgain = gain;
                hwgain.tx = tx;
                if (ioctl(tmp->subs[SUB_REAL].zfd, DAHDI_SET_HWGAIN, &hwgain) < 0) {
-                       ast_cli(a->fd, "Unable to set the hardware gain for channel %d\n", channel);
+                       ast_cli(a->fd, "Unable to set the hardware gain for channel %d: %s\n", channel, strerror(errno));
                        ast_mutex_unlock(&iflock);
                        return CLI_FAILURE;
                }
@@ -13191,7 +13199,7 @@ static int linkset_addsigchan(int sigchan)
                if ((p.sigtype != DAHDI_SIG_HDLCFCS) && (p.sigtype != DAHDI_SIG_HARDHDLC) && (p.sigtype != DAHDI_SIG_MTP2)) {
                        dahdi_close(link->fds[curfd]);
                        link->fds[curfd] = -1;
-                       ast_log(LOG_ERROR, "sigchan %d is not in HDLC/FCS mode.  See /etc/dahdi.conf\n", sigchan);
+                       ast_log(LOG_ERROR, "sigchan %d is not in HDLC/FCS mode.\n", sigchan);
                        return -1;
                }
 
@@ -13201,7 +13209,7 @@ static int linkset_addsigchan(int sigchan)
                bi.bufsize = 512;
 
                if (ioctl(link->fds[curfd], DAHDI_SET_BUFINFO, &bi)) {
-                       ast_log(LOG_ERROR, "Unable to set appropriate buffering on channel %d\n", sigchan);
+                       ast_log(LOG_ERROR, "Unable to set appropriate buffering on channel %d: %s\n", sigchan, strerror(errno));
                        dahdi_close(link->fds[curfd]);
                        link->fds[curfd] = -1;
                        return -1;
@@ -14399,7 +14407,7 @@ static int process_dahdi(struct dahdi_chan_conf *confp, const char *cat, struct
                                        dps.dtmf_tonelen = dps.mfv1_tonelen = toneduration;
                                        res = ioctl(ctlfd, DAHDI_SET_DIALPARAMS, &dps);
                                        if (res < 0) {
-                                               ast_log(LOG_ERROR, "Invalid tone duration: %d ms at line %d.\n", toneduration, v->lineno);
+                                               ast_log(LOG_ERROR, "Invalid tone duration: %d ms at line %d: %s\n", toneduration, v->lineno, strerror(errno));
                                                return -1;
                                        }
                                }