BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / vax / uba / tmscp.c
index aa1ba70..93a67cd 100644 (file)
@@ -1,9 +1,41 @@
-/*     @(#)tmscp.c     7.11 (Berkeley) %G% */
-
-#ifndef lint
-static char    *sccsid = "@(#)tmscp.c  1.24    (ULTRIX)        1/21/86";
-#endif lint
+/*-
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)tmscp.c     7.16 (Berkeley) 5/9/91
+ */
 
 
+/*
+ * sccsid = "@(#)tmscp.c       1.24    (ULTRIX)        1/21/86";
+ */
 
 /************************************************************************
  *                                                                     *
 
 /************************************************************************
  *                                                                     *
@@ -122,24 +154,24 @@ static    char    *sccsid = "@(#)tmscp.c  1.24    (ULTRIX)        1/21/86";
 #include "tms.h"
 #if NTMSCP > 0
 
 #include "tms.h"
 #if NTMSCP > 0
 
-#include "param.h"
-#include "systm.h"
-#include "buf.h"
-#include "conf.h"
-#include "user.h"
-#include "proc.h"
-#include "file.h"
-#include "map.h"
-#include "vm.h"
-#include "ioctl.h"
-#include "syslog.h"
-#include "mtio.h"
-#include "cmap.h"
-#include "uio.h"
-
-#include "../vax/pte.h"
-#include "../vax/cpu.h"
-#include "../vax/mtpr.h"
+#include "sys/param.h"
+#include "sys/systm.h"
+#include "sys/buf.h"
+#include "sys/conf.h"
+#include "sys/errno.h"
+#include "sys/file.h"
+#include "sys/map.h"
+#include "sys/vm.h"
+#include "sys/ioctl.h"
+#include "sys/syslog.h"
+#include "sys/mtio.h"
+#include "sys/cmap.h"
+#include "sys/uio.h"
+#include "sys/tprintf.h"
+
+#include "../include/pte.h"
+#include "../include/cpu.h"
+#include "../include/mtpr.h"
 #include "ubareg.h"
 #include "ubavar.h"
 
 #include "ubareg.h"
 #include "ubavar.h"
 
@@ -191,7 +223,7 @@ struct tms_info {
        short           tms_fmtmenu;    /* the unit's format (density) menu */
        short           tms_unitflgs;   /* unit flag parameters */
        short           tms_format;     /* the unit's current format (density) */
        short           tms_fmtmenu;    /* the unit's format (density) menu */
        short           tms_unitflgs;   /* unit flag parameters */
        short           tms_format;     /* the unit's current format (density) */
-       caddr_t         tms_ctty;       /* user's controlling tty (vnode) */
+       tpr_t           tms_tpr;        /* tprintf handle */
 } tms_info[NTMS];
 struct uba_ctlr *tmscpminfo[NTMSCP];
 struct uba_device *tmsdinfo[NTMS];
 } tms_info[NTMS];
 struct uba_ctlr *tmscpminfo[NTMSCP];
 struct uba_device *tmsdinfo[NTMS];
@@ -704,8 +736,7 @@ tmscpopen(dev, flag)
                return (EBUSY);
        sc = &tmscp_softc[ui->ui_ctlr];
        tms->tms_openf = 1;
                return (EBUSY);
        sc = &tmscp_softc[ui->ui_ctlr];
        tms->tms_openf = 1;
-       tms->tms_ctty = (caddr_t)(u.u_procp->p_flag&SCTTY ?
-                       u.u_procp->p_session->s_ttyvp : 0);
+       tms->tms_tpr = tprintf_open();
        s = spl5();
        if (sc->sc_state != S_RUN)
                {
        s = spl5();
        if (sc->sc_state != S_RUN)
                {
@@ -836,6 +867,7 @@ tmscpclose(dev, flag)
 #                      endif
                        tmscpcommand(dev, TMS_CSE, 1);
                        }
 #                      endif
                        tmscpcommand(dev, TMS_CSE, 1);
                        }
+       tprintf_close(tms->tms_tpr);
        tms->tms_openf = 0;
        return (0);
 }
        tms->tms_openf = 0;
        return (0);
 }
@@ -1043,7 +1075,7 @@ tmscpstart(um)
        tms = &tms_info[ui->ui_unit];
        if ((tmscpaddr->tmscpsa&TMSCP_ERR) || sc->sc_state != S_RUN)
                {
        tms = &tms_info[ui->ui_unit];
        if ((tmscpaddr->tmscpsa&TMSCP_ERR) || sc->sc_state != S_RUN)
                {
-               tprintf(tms->tms_ctty,
+               tprintf(tms->tms_tpr,
                    "tms%d: hard error bn%d\n",
                    minor(bp->b_dev)&03, bp->b_blkno);
                log(TMS_PRI, "tmscp%d: sa 0%o, state %d\n",um->um_ctlr,
                    "tms%d: hard error bn%d\n",
                    minor(bp->b_dev)&03, bp->b_blkno);
                log(TMS_PRI, "tmscp%d: sa 0%o, state %d\n",um->um_ctlr,
@@ -1414,11 +1446,11 @@ tmscprsp(um, tm, sc, i)
                else 
                        {
                        if (bp = dp->b_actf)
                else 
                        {
                        if (bp = dp->b_actf)
-                               tprintf(tms->tms_ctty,
+                               tprintf(tms->tms_tpr,
                                    "tms%d: hard error bn%d: OFFLINE\n",
                                    minor(bp->b_dev)&03, bp->b_blkno);
                        else
                                    "tms%d: hard error bn%d: OFFLINE\n",
                                    minor(bp->b_dev)&03, bp->b_blkno);
                        else
-                               tprintf(tms->tms_ctty,
+                               tprintf(tms->tms_tpr,
                                    "tms%d: hard error: OFFLINE\n",
                                    ui->ui_unit);
                        while (bp = dp->b_actf)
                                    "tms%d: hard error: OFFLINE\n",
                                    ui->ui_unit);
                        while (bp = dp->b_actf)
@@ -1550,7 +1582,7 @@ tmscprsp(um, tm, sc, i)
                                tms->tms_serex = 1;
                        if (st != M_ST_TAPEM)
                                {
                                tms->tms_serex = 1;
                        if (st != M_ST_TAPEM)
                                {
-                               tprintf(tms->tms_ctty,
+                               tprintf(tms->tms_tpr,
                                    "tms%d: hard error bn%d\n",
                                    minor(bp->b_dev)&03, bp->b_blkno);
                                errinfo(st);            /* produces more info */
                                    "tms%d: hard error bn%d\n",
                                    minor(bp->b_dev)&03, bp->b_blkno);
                                errinfo(st);            /* produces more info */
@@ -1894,6 +1926,7 @@ tmscpioctl(dev, cmd, data, flag)
        register struct uba_device *ui;
        register struct tms_info *tms;
        int fcount;             /* number of files (or records) to space */
        register struct uba_device *ui;
        register struct tms_info *tms;
        int fcount;             /* number of files (or records) to space */
+       int error = 0;
        register struct mtop *mtop;     /* mag tape cmd op to perform */
        register struct mtget *mtget;   /* mag tape struct to get info in */
 
        register struct mtop *mtop;     /* mag tape cmd op to perform */
        register struct mtget *mtget;   /* mag tape struct to get info in */
 
@@ -1936,7 +1969,10 @@ tmscpioctl(dev, cmd, data, flag)
                        if (bp->b_flags & B_ERROR)      /* like hitting BOT */
                                break;
                        }
                        if (bp->b_flags & B_ERROR)      /* like hitting BOT */
                                break;
                        }
-               return (geterror(bp));
+               if (bp->b_flags&B_ERROR)
+                       if ((error = bp->b_error)==0)
+                               return (EIO);
+               return (error);
 
        case MTIOCGET:
                /*
 
        case MTIOCGET:
                /*