The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/mtio.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-3-Clause
    3  *
    4  * Copyright (c) 1982, 1986, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. Neither the name of the University nor the names of its contributors
   16  *    may be used to endorse or promote products derived from this software
   17  *    without specific prior written permission.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  *
   31  *      @(#)mtio.h      8.1 (Berkeley) 6/2/93
   32  * $FreeBSD: stable/12/sys/sys/mtio.h 326023 2017-11-20 19:43:44Z pfg $
   33  */
   34 
   35 #ifndef _SYS_MTIO_H_
   36 #define _SYS_MTIO_H_
   37 
   38 #ifndef _KERNEL
   39 #include <sys/types.h>
   40 #endif
   41 #include <sys/ioccom.h>
   42 
   43 /*
   44  * Structures and definitions for mag tape io control commands
   45  */
   46 
   47 /* structure for MTIOCTOP - mag tape op command */
   48 struct mtop {
   49         short   mt_op;          /* operations defined below */
   50         int32_t mt_count;       /* how many of them */
   51 };
   52 
   53 /* operations */
   54 #define MTWEOF          0       /* write an end-of-file record */
   55 #define MTFSF           1       /* forward space file */
   56 #define MTBSF           2       /* backward space file */
   57 #define MTFSR           3       /* forward space record */
   58 #define MTBSR           4       /* backward space record */
   59 #define MTREW           5       /* rewind */
   60 #define MTOFFL          6       /* rewind and put the drive offline */
   61 #define MTNOP           7       /* no operation, sets status only */
   62 #define MTCACHE         8       /* enable controller cache */
   63 #define MTNOCACHE       9       /* disable controller cache */
   64 
   65 #if defined(__FreeBSD__)
   66 /* Set block size for device. If device is a variable size dev          */
   67 /* a non zero parameter will change the device to a fixed block size    */
   68 /* device with block size set to that of the parameter passed in.       */
   69 /* Resetting the block size to 0 will restore the device to a variable  */
   70 /* block size device. */
   71 
   72 #define MTSETBSIZ       10
   73 
   74 /* Set density values for device. Sets the value for the opened mode only. */
   75 
   76 #define MTSETDNSTY      11
   77 
   78 #define MTERASE         12      /* erase to EOM */
   79 #define MTEOD           13      /* Space to EOM */
   80 #define MTCOMP          14      /* select compression mode 0=off, 1=def */
   81 #define MTRETENS        15      /* re-tension tape */
   82 #define MTWSS           16      /* write setmark(s) */
   83 #define MTFSS           17      /* forward space setmark */
   84 #define MTBSS           18      /* backward space setmark */
   85 #define MTLOAD          19      /* load tape in drive */
   86 #define MTWEOFI         20      /* write an end-of-file record without waiting*/
   87 
   88 #define MT_COMP_ENABLE          0xffffffff
   89 #define MT_COMP_DISABLED        0xfffffffe
   90 #define MT_COMP_UNSUPP          0xfffffffd
   91 
   92 /*
   93  * Values in mt_dsreg that say what the device is doing
   94  */
   95 #define MTIO_DSREG_NIL  0       /* Unknown */
   96 #define MTIO_DSREG_REST 1       /* Doing Nothing */
   97 #define MTIO_DSREG_RBSY 2       /* Communicating with tape (but no motion) */
   98 #define MTIO_DSREG_WR   20      /* Writing */
   99 #define MTIO_DSREG_FMK  21      /* Writing Filemarks */
  100 #define MTIO_DSREG_ZER  22      /* Erasing */
  101 #define MTIO_DSREG_RD   30      /* Reading */
  102 #define MTIO_DSREG_FWD  40      /* Spacing Forward */
  103 #define MTIO_DSREG_REV  41      /* Spacing Reverse */
  104 #define MTIO_DSREG_POS  42      /* Hardware Positioning (direction unknown) */
  105 #define MTIO_DSREG_REW  43      /* Rewinding */
  106 #define MTIO_DSREG_TEN  44      /* Retensioning */
  107 #define MTIO_DSREG_UNL  45      /* Unloading */
  108 #define MTIO_DSREG_LD   46      /* Loading */
  109 
  110 #endif  /* __FreeBSD__ */
  111 
  112 /* structure for MTIOCGET - mag tape get status command */
  113 
  114 struct mtget {
  115         short   mt_type;        /* type of magtape device */
  116 /* the following two registers are grossly device dependent */
  117         short   mt_dsreg;       /* ``drive status'' register */
  118         short   mt_erreg;       /* ``error'' register */
  119 /* end device-dependent registers */
  120         /*
  121          * Note that the residual count, while maintained, may be
  122          * be nonsense because the size of the residual may (greatly)
  123          * exceed 32 K-bytes. Use the MTIOCERRSTAT ioctl to get a
  124          * more accurate count.
  125          */
  126         short   mt_resid;       /* residual count */
  127 #if defined (__FreeBSD__)
  128         int32_t mt_blksiz;      /* presently operating blocksize */
  129         int32_t mt_density;     /* presently operating density */
  130         u_int32_t mt_comp;      /* presently operating compression */
  131         int32_t mt_blksiz0;     /* blocksize for mode 0 */
  132         int32_t mt_blksiz1;     /* blocksize for mode 1 */
  133         int32_t mt_blksiz2;     /* blocksize for mode 2 */
  134         int32_t mt_blksiz3;     /* blocksize for mode 3 */
  135         int32_t mt_density0;    /* density for mode 0 */
  136         int32_t mt_density1;    /* density for mode 1 */
  137         int32_t mt_density2;    /* density for mode 2 */
  138         int32_t mt_density3;    /* density for mode 3 */
  139 /* the following are not yet implemented */
  140         u_int32_t mt_comp0;     /* compression type for mode 0 */
  141         u_int32_t mt_comp1;     /* compression type for mode 1 */
  142         u_int32_t mt_comp2;     /* compression type for mode 2 */
  143         u_int32_t mt_comp3;     /* compression type for mode 3 */
  144 /* end not yet implemented */
  145 #endif
  146         int32_t mt_fileno;      /* relative file number of current position */
  147         int32_t mt_blkno;       /* relative block number of current position */
  148 };
  149 
  150 /* structure for MTIOCERRSTAT - tape get error status command */
  151 /* really only supported for SCSI tapes right now */
  152 struct scsi_tape_errors {
  153         /*
  154          * These are latched from the last command that had a SCSI
  155          * Check Condition noted for these operations. The act
  156          * of issuing an MTIOCERRSTAT unlatches and clears them.
  157          */
  158         u_int8_t io_sense[32];  /* Last Sense Data For Data I/O */
  159         int32_t io_resid;       /* residual count from last Data I/O */
  160         u_int8_t io_cdb[16];    /* Command that Caused the Last Data Sense */
  161         u_int8_t ctl_sense[32]; /* Last Sense Data For Control I/O */
  162         int32_t ctl_resid;      /* residual count from last Control I/O */
  163         u_int8_t ctl_cdb[16];   /* Command that Caused the Last Control Sense */
  164         /*
  165          * These are the read and write cumulative error counters.
  166          * (how to reset cumulative error counters is not yet defined).
  167          * (not implemented as yet but space is being reserved for them)
  168          */
  169         struct {
  170                 u_int32_t retries;      /* total # retries performed */
  171                 u_int32_t corrected;    /* total # corrections performed */
  172                 u_int32_t processed;    /* total # corrections successful */
  173                 u_int32_t failures;     /* total # corrections/retries failed */
  174                 u_int64_t nbytes;       /* total # bytes processed */
  175         } wterr, rderr;
  176 };
  177         
  178 union mterrstat {
  179         struct scsi_tape_errors scsi_errstat;
  180         char _reserved_padding[256];
  181 };
  182 
  183 struct mtrblim {
  184         uint32_t granularity;
  185         uint32_t min_block_length;
  186         uint32_t max_block_length;
  187 };
  188 
  189 typedef enum {
  190         MT_LOCATE_DEST_OBJECT   = 0x00,
  191         MT_LOCATE_DEST_FILE     = 0x01,
  192         MT_LOCATE_DEST_SET      = 0x02,
  193         MT_LOCATE_DEST_EOD      = 0x03
  194 } mt_locate_dest_type;
  195 
  196 typedef enum {
  197         MT_LOCATE_BAM_IMPLICIT  = 0x00,
  198         MT_LOCATE_BAM_EXPLICIT  = 0x01
  199 } mt_locate_bam;
  200 
  201 typedef enum {
  202         MT_LOCATE_FLAG_IMMED            = 0x01,
  203         MT_LOCATE_FLAG_CHANGE_PART      = 0x02
  204 } mt_locate_flags;
  205 
  206 struct mtlocate {
  207         mt_locate_flags         flags;
  208         mt_locate_dest_type     dest_type;
  209         mt_locate_bam           block_address_mode;
  210         int64_t                 partition;
  211         uint64_t                logical_id;
  212         uint8_t                 reserved[64];
  213 };
  214 
  215 typedef enum {
  216         MT_EXT_GET_NONE,
  217         MT_EXT_GET_OK,
  218         MT_EXT_GET_NEED_MORE_SPACE,
  219         MT_EXT_GET_ERROR
  220 } mt_ext_get_status;
  221 
  222 struct mtextget {
  223         uint32_t                alloc_len;
  224         char                    *status_xml;
  225         uint32_t                fill_len;
  226         mt_ext_get_status       status;
  227         char                    error_str[128];
  228         uint8_t                 reserved[64];
  229 };
  230 
  231 #define MT_EXT_GET_ROOT_NAME            "mtextget"
  232 #define MT_DENSITY_ROOT_NAME            "mtdensity"
  233 #define MT_MEDIA_DENSITY_NAME           "media_density"
  234 #define MT_DENSITY_REPORT_NAME          "density_report"
  235 #define MT_MEDIUM_TYPE_REPORT_NAME      "medium_type_report"
  236 #define MT_MEDIA_REPORT_NAME            "media_report"
  237 #define MT_DENSITY_ENTRY_NAME           "density_entry"
  238 
  239 #define MT_DENS_WRITE_OK                0x80
  240 #define MT_DENS_DUP                     0x40
  241 #define MT_DENS_DEFLT                   0x20
  242 
  243 
  244 #define MT_PARAM_FIXED_STR_LEN  32
  245 union mt_param_value {
  246         int64_t         value_signed;
  247         uint64_t        value_unsigned;
  248         char            *value_var_str;
  249         char            value_fixed_str[MT_PARAM_FIXED_STR_LEN];
  250         uint8_t         reserved[64];
  251 };
  252 
  253 typedef enum {
  254         MT_PARAM_SET_NONE,
  255         MT_PARAM_SET_SIGNED,
  256         MT_PARAM_SET_UNSIGNED,
  257         MT_PARAM_SET_VAR_STR,
  258         MT_PARAM_SET_FIXED_STR
  259 } mt_param_set_type;
  260 
  261 typedef enum {
  262         MT_PARAM_STATUS_NONE,
  263         MT_PARAM_STATUS_OK,
  264         MT_PARAM_STATUS_ERROR
  265 } mt_param_set_status;
  266 
  267 #define MT_PARAM_VALUE_NAME_LEN 64
  268 struct mtparamset {
  269         char                    value_name[MT_PARAM_VALUE_NAME_LEN];
  270         mt_param_set_type       value_type;
  271         int                     value_len;
  272         union mt_param_value    value;
  273         mt_param_set_status     status;
  274         char                    error_str[128];
  275 };
  276 
  277 #define MT_PARAM_ROOT_NAME      "mtparamget"
  278 #define MT_PROTECTION_NAME      "protection"
  279 
  280 /*
  281  * Set a list of parameters.
  282  */
  283 struct mtsetlist {
  284         int num_params;
  285         int param_len;
  286         struct mtparamset *params;
  287 };
  288 
  289 /*
  290  * Constants for mt_type byte.  These are the same
  291  * for controllers compatible with the types listed.
  292  */
  293 #define MT_ISTS         0x01            /* TS-11 */
  294 #define MT_ISHT         0x02            /* TM03 Massbus: TE16, TU45, TU77 */
  295 #define MT_ISTM         0x03            /* TM11/TE10 Unibus */
  296 #define MT_ISMT         0x04            /* TM78/TU78 Massbus */
  297 #define MT_ISUT         0x05            /* SI TU-45 emulation on Unibus */
  298 #define MT_ISCPC        0x06            /* SUN */
  299 #define MT_ISAR         0x07            /* SUN */
  300 #define MT_ISTMSCP      0x08            /* DEC TMSCP protocol (TU81, TK50) */
  301 #define MT_ISCY         0x09            /* CCI Cipher */
  302 #define MT_ISCT         0x0a            /* HP 1/4 tape */
  303 #define MT_ISFHP        0x0b            /* HP 7980 1/2 tape */
  304 #define MT_ISEXABYTE    0x0c            /* Exabyte */
  305 #define MT_ISEXA8200    0x0c            /* Exabyte EXB-8200 */
  306 #define MT_ISEXA8500    0x0d            /* Exabyte EXB-8500 */
  307 #define MT_ISVIPER1     0x0e            /* Archive Viper-150 */
  308 #define MT_ISPYTHON     0x0f            /* Archive Python (DAT) */
  309 #define MT_ISHPDAT      0x10            /* HP 35450A DAT drive */
  310 #define MT_ISMFOUR      0x11            /* M4 Data 1/2 9track drive */
  311 #define MT_ISTK50       0x12            /* DEC SCSI TK50 */
  312 #define MT_ISMT02       0x13            /* Emulex MT02 SCSI tape controller */
  313 
  314 /* mag tape io control commands */
  315 #define MTIOCTOP        _IOW('m', 1, struct mtop)       /* do a mag tape op */
  316 #define MTIOCGET        _IOR('m', 2, struct mtget)      /* get tape status */
  317 /* these two do not appear to be used anywhere */
  318 #define MTIOCIEOT       _IO('m', 3)                     /* ignore EOT error */
  319 #define MTIOCEEOT       _IO('m', 4)                     /* enable EOT error */
  320 /*
  321  * When more SCSI-3 SSC (streaming device) devices are out there
  322  * that support the full 32 byte type 2 structure, we'll have to
  323  * rethink these ioctls to support all the entities they haul into
  324  * the picture (64 bit blocks, logical file record numbers, etc..).
  325  */
  326 #define MTIOCRDSPOS     _IOR('m', 5, u_int32_t) /* get logical blk addr */
  327 #define MTIOCRDHPOS     _IOR('m', 6, u_int32_t) /* get hardware blk addr */
  328 #define MTIOCSLOCATE    _IOW('m', 5, u_int32_t) /* seek to logical blk addr */
  329 #define MTIOCHLOCATE    _IOW('m', 6, u_int32_t) /* seek to hardware blk addr */
  330 #define MTIOCERRSTAT    _IOR('m', 7, union mterrstat)   /* get tape errors */
  331 
  332 /*
  333  * Set EOT model- argument is number of filemarks to end a tape with.
  334  * Note that not all possible values will be accepted.
  335  */
  336 #define MTIOCSETEOTMODEL        _IOW('m', 8, u_int32_t)
  337 /* Get current EOT model */
  338 #define MTIOCGETEOTMODEL        _IOR('m', 8, u_int32_t)
  339 
  340 #define MTIOCRBLIM      _IOR('m', 9, struct mtrblim)    /* get block limits */
  341 #define MTIOCEXTLOCATE  _IOW('m', 10, struct mtlocate)  /* seek to position */
  342 #define MTIOCEXTGET     _IOWR('m', 11, struct mtextget) /* get tape status */
  343 #define MTIOCPARAMGET   _IOWR('m', 12, struct mtextget) /* get tape params */
  344 #define MTIOCPARAMSET   _IOWR('m', 13, struct mtparamset) /* set tape params */
  345 #define MTIOCSETLIST    _IOWR('m', 14, struct mtsetlist) /* set N params */
  346 
  347 #ifndef _KERNEL
  348 #define DEFTAPE "/dev/nsa0"
  349 #endif
  350 
  351 #endif /* !_SYS_MTIO_H_ */

Cache object: d698e5c7edfcba52a98dd071c4a48f94


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.