mt.c (schily-2021-08-14.tar.bz2) | : | mt.c (schily-2021-09-18.tar.bz2) | ||
---|---|---|---|---|
/* @(#)mt.c 1.30 18/11/28 Copyright 2000-2018 J. Schilling */ | /* @(#)mt.c 1.32 21/08/20 Copyright 2000-2021 J. Schilling */ | |||
#include <schily/mconfig.h> | #include <schily/mconfig.h> | |||
#ifndef lint | #ifndef lint | |||
static UConst char sccsid[] = | static UConst char sccsid[] = | |||
"@(#)mt.c 1.30 18/11/28 Copyright 2000-2018 J. Schilling"; | "@(#)mt.c 1.32 21/08/20 Copyright 2000-2021 J. Schilling"; | |||
#endif | #endif | |||
/* | /* | |||
* Magnetic tape manipulation program | * Magnetic tape manipulation program | |||
* | * | |||
* Copyright (c) 2000-2018 J. Schilling | * Copyright (c) 2000-2021 J. Schilling | |||
*/ | */ | |||
/* | /* | |||
* The contents of this file are subject to the terms of the | * The contents of this file are subject to the terms of the | |||
* Common Development and Distribution License, Version 1.0 only | * Common Development and Distribution License, Version 1.0 only | |||
* (the "License"). You may not use this file except in compliance | * (the "License"). You may not use this file except in compliance | |||
* with the License. | * with the License. | |||
* | * | |||
* See the file CDDL.Schily.txt in this distribution for details. | * See the file CDDL.Schily.txt in this distribution for details. | |||
* A copy of the CDDL is also available via the Internet at | * A copy of the CDDL is also available via the Internet at | |||
* http://www.opensource.org/licenses/cddl1.txt | * http://www.opensource.org/licenses/cddl1.txt | |||
skipping to change at line 51 | skipping to change at line 51 | |||
#include <schily/stdio.h> | #include <schily/stdio.h> | |||
#include <schily/stdlib.h> | #include <schily/stdlib.h> | |||
#include <schily/unistd.h> | #include <schily/unistd.h> | |||
#include <schily/string.h> | #include <schily/string.h> | |||
#include <schily/utypes.h> | #include <schily/utypes.h> | |||
#include <schily/fcntl.h> | #include <schily/fcntl.h> | |||
#include <schily/ioctl.h> | #include <schily/ioctl.h> | |||
#include <schily/errno.h> | #include <schily/errno.h> | |||
#define GT_COMERR /* #define comerr gtcomerr */ | ||||
#define GT_ERROR /* #define error gterror */ | ||||
#include <schily/schily.h> | #include <schily/schily.h> | |||
#include <schily/standard.h> | #include <schily/standard.h> | |||
/*#undef HAVE_SYS_MTIO_H*/ | /*#undef HAVE_SYS_MTIO_H*/ | |||
#include <schily/mtio.h> | #include <schily/mtio.h> | |||
#include <schily/librmt.h> | #include <schily/librmt.h> | |||
#include <schily/nlsdefs.h> | ||||
LOCAL BOOL help; | LOCAL BOOL help; | |||
LOCAL BOOL prvers; | LOCAL BOOL prvers; | |||
LOCAL BOOL wready; | LOCAL BOOL wready; | |||
LOCAL int debug; | LOCAL int debug; | |||
LOCAL struct mtop mt_op; | LOCAL struct mtop mt_op; | |||
LOCAL struct rmtget mt_status; | LOCAL struct rmtget mt_status; | |||
#ifndef HAVE_MTGET_TYPE | #ifndef HAVE_MTGET_TYPE | |||
skipping to change at line 186 | skipping to change at line 189 | |||
char *av[]; | char *av[]; | |||
{ | { | |||
int cac; | int cac; | |||
char * const *cav; | char * const *cav; | |||
char *tape = NULL; | char *tape = NULL; | |||
char *cmd = "BADCMD"; | char *cmd = "BADCMD"; | |||
int count = 1; | int count = 1; | |||
struct mt_cmds *cp; | struct mt_cmds *cp; | |||
save_args(ac, av); | save_args(ac, av); | |||
(void) setlocale(LC_ALL, ""); | ||||
#ifdef USE_NLS | ||||
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ | ||||
#define TEXT_DOMAIN "mt" /* Use this only if it weren't */ | ||||
#endif | ||||
{ char *dir; | ||||
dir = searchfileinpath("share/locale", F_OK, | ||||
SIP_ANY_FILE|SIP_NO_PATH, NULL); | ||||
if (dir) | ||||
(void) bindtextdomain(TEXT_DOMAIN, dir); | ||||
else | ||||
#if defined(PROTOTYPES) && defined(INS_BASE) | ||||
(void) bindtextdomain(TEXT_DOMAIN, INS_BASE "/share/locale"); | ||||
#else | ||||
(void) bindtextdomain(TEXT_DOMAIN, "/usr/share/locale"); | ||||
#endif | ||||
(void) textdomain(TEXT_DOMAIN); | ||||
} | ||||
#endif /* USE_NLS */ | ||||
cac = --ac; | cac = --ac; | |||
cav = ++av; | cav = ++av; | |||
if (getallargs(&cac, &cav, opts, | if (getallargs(&cac, &cav, opts, | |||
&tape, &tape, | &tape, &tape, | |||
&prvers, | &prvers, | |||
&help, &help, | &help, &help, | |||
&debug, | &debug, | |||
&wready) < 0) { | &wready) < 0) { | |||
errmsgno(EX_BAD, "Bad Option: '%s'.\n", cav[0]); | errmsgno(EX_BAD, "Bad Option: '%s'.\n", cav[0]); | |||
usage(EX_BAD); | usage(EX_BAD); | |||
} | } | |||
if (help) usage(0); | if (help) usage(0); | |||
if (prvers) { | if (prvers) { | |||
printf("mt %s %s (%s-%s-%s)\n\n", "1.30", "2018/11/28", HOST_CPU, | gtprintf("mt %s %s (%s-%s-%s)\n\n", "1.32", "2021/08/20", HOST_CP | |||
HOST_VENDOR, HOST_OS); | U, HOST_VENDOR, HOST_OS); | |||
printf("Copyright (C) 2000-2018 Jörg Schilling\n"); | gtprintf("Copyright (C) 2000-2021 %s\n", _("Jörg Schilling")); | |||
printf("This is free software; see the source for copying conditi | gtprintf("This is free software; see the source for copying condi | |||
ons. There is NO\n"); | tions. There is NO\n"); | |||
printf("warranty; not even for MERCHANTABILITY or FITNESS FOR A P | gtprintf("warranty; not even for MERCHANTABILITY or FITNESS FOR A | |||
ARTICULAR PURPOSE.\n"); | PARTICULAR PURPOSE.\n"); | |||
exit(0); | exit(0); | |||
} | } | |||
if (tape == NULL && (tape = getenv("TAPE")) == NULL) { | if (tape == NULL && (tape = getenv("TAPE")) == NULL) { | |||
#ifdef DEFTAPE | #ifdef DEFTAPE | |||
tape = DEFTAPE; | tape = DEFTAPE; | |||
#else | #else | |||
errmsgno(EX_BAD, "No default tape defined.\n"); | errmsgno(EX_BAD, "No default tape defined.\n"); | |||
usage(EX_BAD); | usage(EX_BAD); | |||
/* NOTREACHED */ | /* NOTREACHED */ | |||
skipping to change at line 406 | skipping to change at line 431 | |||
#endif | #endif | |||
#if defined(MTF_SCSI) | #if defined(MTF_SCSI) | |||
if ((sp->mt_xflags & RMT_FLAGS) && (sp->mt_flags & MTF_SCSI)) { | if ((sp->mt_xflags & RMT_FLAGS) && (sp->mt_flags & MTF_SCSI)) { | |||
/* | /* | |||
* Handle SCSI tape drives specially. | * Handle SCSI tape drives specially. | |||
*/ | */ | |||
if (sp->mt_xflags & RMT_TYPE) { | if (sp->mt_xflags & RMT_TYPE) { | |||
if (mt != NULL && mt->t_type == sp->mt_type) | if (mt != NULL && mt->t_type == sp->mt_type) | |||
printf("%s tape drive:\n", mt->t_name); | gtprintf("%s tape drive:\n", mt->t_name); | |||
else | else | |||
printf("%s tape drive:\n", "SCSI"); | gtprintf("%s tape drive:\n", "SCSI"); | |||
} else { | } else { | |||
printf("Unknown SCSI tape drive:\n"); | gtprintf("Unknown SCSI tape drive:\n"); | |||
} | } | |||
printf(" sense key(0x%llx)= %s residual= %lld ", | printf(" sense key(0x%llx)= %s residual= %lld ", | |||
sp->mt_erreg, print_key(sp->mt_erreg), sp->mt_resid); | sp->mt_erreg, print_key(sp->mt_erreg), sp->mt_resid); | |||
printf("retries= %lld\n", sp->mt_dsreg); | gtprintf("retries= %lld\n", sp->mt_dsreg); | |||
} else | } else | |||
#endif /* MTF_SCSI */ | #endif /* MTF_SCSI */ | |||
{ | { | |||
/* | /* | |||
* Handle other drives below. | * Handle other drives below. | |||
*/ | */ | |||
if (sp->mt_xflags & RMT_TYPE) { | if (sp->mt_xflags & RMT_TYPE) { | |||
if (mt == NULL || mt->t_type == 0) { | if (mt == NULL || mt->t_type == 0) { | |||
printf("Unknown tape drive type (0x%llX):\n", (Ul long)sp->mt_type); | gtprintf("Unknown tape drive type (0x%llX):\n", ( Ullong)sp->mt_type); | |||
} else { | } else { | |||
printf("%s tape drive:\n", mt->t_name); | gtprintf("%s tape drive:\n", mt->t_name); | |||
} | } | |||
} else { | } else { | |||
printf("Unknown tape drive:\n"); | gtprintf("Unknown tape drive:\n"); | |||
} | } | |||
if (sp->mt_xflags & RMT_RESID) | if (sp->mt_xflags & RMT_RESID) | |||
printf(" residual= %lld", sp->mt_resid); | gtprintf(" residual= %lld", sp->mt_resid); | |||
/* | /* | |||
* If we implement better support for specific OS, | * If we implement better support for specific OS, | |||
* then we may want to implement something like the | * then we may want to implement something like the | |||
* *BSD kernel %b printf format (e.g. printreg). | * *BSD kernel %b printf format (e.g. printreg). | |||
*/ | */ | |||
if (sp->mt_xflags & RMT_DSREG) | if (sp->mt_xflags & RMT_DSREG) | |||
printf (" ds = %llX", (Ullong)sp->mt_dsreg); | printf (" ds = %llX", (Ullong)sp->mt_dsreg); | |||
if (sp->mt_xflags & RMT_ERREG) | if (sp->mt_xflags & RMT_ERREG) | |||
printf (" er = %llX", sp->mt_erreg); | printf (" er = %llX", sp->mt_erreg); | |||
putchar('\n'); | putchar('\n'); | |||
} | } | |||
printf(" file no= %lld block no= %lld\n", | gtprintf(" file no= %lld block no= %lld\n", | |||
(sp->mt_xflags & RMT_FILENO)? | (sp->mt_xflags & RMT_FILENO)? | |||
sp->mt_fileno: | sp->mt_fileno: | |||
(Llong)-1, | (Llong)-1, | |||
(sp->mt_xflags & RMT_BLKNO)? | (sp->mt_xflags & RMT_BLKNO)? | |||
sp->mt_blkno: | sp->mt_blkno: | |||
(Llong)-1); | (Llong)-1); | |||
if (sp->mt_xflags & RMT_BF) | if (sp->mt_xflags & RMT_BF) | |||
printf(" optimum blocking factor= %ld\n", sp->mt_bf); | gtprintf(" optimum blocking factor= %ld\n", sp->mt_bf); | |||
if (sp->mt_xflags & RMT_FLAGS) | if (sp->mt_xflags & RMT_FLAGS) | |||
printf(" flags= 0x%llX\n", sp->mt_flags); | gtprintf(" flags= 0x%llX\n", sp->mt_flags); | |||
} | } | |||
static char *sense_keys[] = { | static char *sense_keys[] = { | |||
"No Additional Sense", /* 0x00 */ | "No Additional Sense", /* 0x00 */ | |||
"Recovered Error", /* 0x01 */ | "Recovered Error", /* 0x01 */ | |||
"Not Ready", /* 0x02 */ | "Not Ready", /* 0x02 */ | |||
"Medium Error", /* 0x03 */ | "Medium Error", /* 0x03 */ | |||
"Hardware Error", /* 0x04 */ | "Hardware Error", /* 0x04 */ | |||
"Illegal Request", /* 0x05 */ | "Illegal Request", /* 0x05 */ | |||
"Unit Attention", /* 0x06 */ | "Unit Attention", /* 0x06 */ | |||
End of changes. 18 change blocks. | ||||
21 lines changed or deleted | 46 lines changed or added |