diff -u --recursive --new-file ftape-4.03/BUGS ftape-4.04/BUGS --- ftape-4.03/BUGS Mon Jun 26 01:40:30 2000 +++ ftape-4.04/BUGS Sun Jul 23 22:33:29 2000 @@ -18,6 +18,8 @@ Should this be fixed? Maybe supply zftape with a dummy llseek() that simply returns -ESPIPE. + Done. + * formatting with Colorado Jumbo 350 This doesn't seem to work. I don't think that the kernel driver needs to be changed; it should be possible to fix this in user @@ -33,6 +35,11 @@ standard FDC). Apparently it doesn't help to try to disable the DMA gate of the Ditto EZ controller. I think this is a hardware bug of the EZ controller. + +* Ftape versions prior to ftape-4.04 have a bug concerning the volume + table of format code 6 cartridges (i.e. cartridges with more than + 2^16 segments). Sharing such cartridges with other operating systems + and ftape will cause data loss (ONLY for versions prior to 4.04). FIXME! diff -u --recursive --new-file ftape-4.03/ChangeLog ftape-4.04/ChangeLog --- ftape-4.03/ChangeLog Tue Jul 4 04:03:10 2000 +++ ftape-4.04/ChangeLog Sun Jul 23 22:37:22 2000 @@ -1,3 +1,140 @@ +2000-07-23 Claus-Justus Heine + + * Release version 4.04. + +2000-07-23 heine + + * RELEASE-NOTES: Update for release of version 4.04. + + * BUGS: Update. Report bug fixes. + + * include/linux/ftape.h: Bump version to 4.04. + + * ftape/zftape/zftape-ctl.c: Update of copyright notice. + + * ftape/lowlevel/ftape-read.c: + New bug work-around for format parameter inconsistency caused by other + programs. + +2000-07-21 heine + + * ftape/zftape/zftape-ctl.c: + Don't re-read the volume table segment with MTIOCFTREAD if it has + already been read in by the driver. + + * ftape/zftape/zftape-vtbl.h: Purely cosmetic changes. + +2000-07-20 heine + + * ftape/zftape/zftape-vtbl.c, ftape/zftape/zftape-vtbl.h: + Use a 3 byte signature "ZFT" for QIC-113 vendor extensions, with + attached one byte version (binary). The previous 10 bytes signature + really was overkill. + + * ftape/zftape/zftape-init.c: Fix compilation for 2.0.x kernels. + + * ftape/zftape/zftape-ctl.c, ftape/zftape/zftape-ctl.h, + ftape/zftape/zftape-init.c, ftape/zftape/zftape-inline.h, + ftape/zftape/zftape-vtbl.c, ftape/zftape/zftape-vtbl.h, + ftape/zftape/zftape-write.c: Fix volume table support for + cartridges with format code 6. Was badly broken. + + Provide compatibility with old (broken) implementation. Use new vendor + extension, indicated by signature "LNX ZFT 2". + + Soft write-protect the cartridge if a broken volume table is + discovered or if a EXVT signature is found (volume table extension is + unsupported). + + Skip unsupported signatures (i.e. UTID and XTBL). + + * Rules.make: Let the object files depend on the Makefiles. + +2000-07-13 testuser + + * MCONFIG: test. + + * MCONFIG: test + +2000-07-13 heine + + * MCONFIG: test. + + * MCONFIG: Test. + +2000-07-12 heine + + * ftape/zftape/zftape-buffers.c, ftape/zftape/zftape-ctl.h, + ftape/zftape/zftape-read.c, ftape/zftape/zftape-vtbl.c, + ftape/zftape/zftape-vtbl.h: Prepare for IDT brain-damage + work-around. Hold the volume table segment in memory permanently. + +2000-07-10 heine + + * scripts/kernel-inclusion/v2.4/Configure.help.ftape: + Adjust configure help to new ftape devfs names. + + * ftape/zftape/zftape-init.c: + Change naming scheme with devfs so that is conformes with ide-tape and + st. + + * ftape/zftape/zftape-rw.c: Remove an obsolete comment. + + * ftape/lowlevel/fdc-io.c: Change a trace message. + +2000-07-09 heine + + * ftape/zftape/zftape-init.c: + Don't create compatibility links in kernel space. + +2000-07-07 heine + + * README: Replace one instance of `ftape-4.02' with `ftape-4.x'. + + * scripts/kernel-inclusion/Documentation/00-INDEX: + Add RELEASE-NOTES file. + + * scripts/kernel-inclusion/gokernel.sh: + Coppy the release notes to Documentation/ftape/ + + * ftape/compressor/Makefile: EXTRA_CFLAGS no longer needed. + +2000-07-06 heine + + * ftape/compressor/Makefile, Rules.make: + Allow CFLAGS_sourcefile variable. This replaces the special rule + needed for lzrw3.o. + + * ftape/parport/trakker.c: + Fix trakkers auto irq detection. Bug reported and fixed by Jochen + Hoenicke. + + * scripts/kernel-inclusion/v2.4/Configure.help.ftape, + scripts/kernel-inclusion/v2.4/Config.in: Cosmetics. + + * scripts/kernel-inclusion/v2.4/Config.in, + scripts/kernel-inclusion/v2.4/Configure.help.ftape, + include/linux/zftape.h, ftape/zftape/zftape-init.h, + ftape/zftape/zftape-inline.h, ftape/zftape/zftape-read.c, + ftape/zftape/zftape-rw.c, ftape/zftape/zftape_syms.c, + ftape/zftape/zftape-vtbl.c, ftape/zftape/Makefile, + ftape/zftape/zftape-buffers.c, ftape/zftape/zftape-ctl.c, + ftape/zftape/zftape-ctl.h, ftape/zftape/zftape-init.c, MCONFIG: + Make ZFT_OBSOLETE a configuration option during kernel + configuration. Rename to CONFIG_ZFT_OBSOLETE. + + * ftape/zftape/zftape-init.c: + Account for devfs API changes in 2.4.0-test3-pre3. + + * ftape/compressor/lzrw3.c: + Fix compiler warning with 64 bit architectures. + +2000-07-04 heine + + * ChangeLog: Final fixes for ftape-4.03 release. + + * INSTALL, README, RELEASE-NOTES: Small updates. + 2000-07-04 Claus-Justus Heine * ftape-4.03 ready for release. diff -u --recursive --new-file ftape-4.03/MCONFIG ftape-4.04/MCONFIG --- ftape-4.03/MCONFIG Thu Jun 29 19:25:47 2000 +++ ftape-4.04/MCONFIG Thu Jul 13 13:38:49 2000 @@ -17,8 +17,8 @@ # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. # # $RCSfile: MCONFIG,v $ -# $Revision: 1.72 $ -# $Date: 2000/06/29 17:25:47 $ +# $Revision: 1.77 $ +# $Date: 2000/07/13 11:38:49 $ # # Compile time configuration for the QIC-40/80/3010/3020 ftape # driver for Linux @@ -311,12 +311,29 @@ # admissible. Compilation of the ftape # modules will fail if this parameter isn't # aligned to 1024 bytes. +# CONFIG_ZFT_OBSOLETE - If this is defined, then +# a) support for /dev/rawft is added, i.e. the +# minor device bit 5 toggles raw mode. +# b) the MTIOC_ZFTAPE_GETBLKSZ is supported. +# c) support for decompression of old ftape-3.x +# archives is added. +# d) in case devfs is supported then the old device +# name /dev/qft0 is created as symlink to +# /dev/ftape/0/qft. Likewise for all other +# devices. +# +# When it is not defined: no decompression, no +# old ioctls, raw-mode must be entered via new +# MTIOCFTMODE ioctl, in the presence of devfs +# all ftape devices are created below +# `/dev/ftape/´. # FTAPE_OPT = -DTHE_FTAPE_MAINTAINER=\"heine@instmath.rwth-aachen.de\" FTAPE_OPT += -DBROKEN_FLOPPY_DRIVER FTAPE_OPT += -DCONFIG_FT_PROC_FS #FTAPE_OPT += -DCONFIG_ZFT_DFLT_BLK_SZ=10240 +FTAPE_OPT += -DCONFIG_ZFT_OBSOLETE # ############################################################################### @@ -400,14 +417,20 @@ CONFIG_OPT += -DCONFIG_FT_TRAKKER_MODULE CONFIG_OPT += -DCONFIG_FT_BPCK_MODULE CONFIG_OPT += -DCONFIG_ZFTAPE_MODULE +ifneq ($(findstring, CONFIG_ZFT_OBSOLETE,$(FTAPE_OPT)),"") CONFIG_OPT += -DCONFIG_ZFT_COMPRESSOR_MODULE +endif override CONFIG_FTAPE := m override CONFIG_FT_INTERNAL := m override CONFIG_FT_PARPORT := m override CONFIG_FT_TRAKKER := m override CONFIG_FT_BPCK := m override CONFIG_ZFTAPE := m +ifneq ($(findstring, CONFIG_ZFT_OBSOLETE,$(FTAPE_OPT)),"") override CONFIG_ZFT_COMPRESSOR := m +else +override CONFIG_ZFT_COMPRESSOR := +endif ifneq ($(findstring, CONFIG_FT_PROC_FS,$(FTAPE_OPT)),"") CONFIG_FT_PROC_FS := y endif diff -u --recursive --new-file ftape-4.03/README ftape-4.04/README --- ftape-4.03/README Tue Jul 4 04:01:40 2000 +++ ftape-4.04/README Fri Jul 7 14:05:06 2000 @@ -70,12 +70,12 @@ is recommended that you download this package, too. ftape-tools-VERSION - This is an additional `ftape support package' which - contains some utilities needed to exploit some - features of the `ftape-4.02' driver. VERSION refers to - the version of the `ftape-tools' package. - `ftape-tools' contains utilities like `swapout', - `ftmt',`ftformat' and `vtblc' and some others. It is + This is an additional `ftape support package' which + contains some utilities needed to exploit some + features of the `ftape-4.x' driver. VERSION refers to + the version of the `ftape-tools' package. + `ftape-tools' contains utilities like `swapout', + `ftmt',`ftformat' and `vtblc' and some others. It is recommended that you download this package, too. Ftape-HOWTO The Ftape-HOWTO is contained in the `ftape-4.x-doc' diff -u --recursive --new-file ftape-4.03/RELEASE-NOTES ftape-4.04/RELEASE-NOTES --- ftape-4.03/RELEASE-NOTES Tue Jul 4 04:01:40 2000 +++ ftape-4.04/RELEASE-NOTES Sun Jul 23 22:34:56 2000 @@ -1,5 +1,14 @@ Hey, Emacs, we're -*-Text-*- mode! +===== Release notes for ftape-4.04 23/07/00 ===== + +-- Fix a severe bug in the volume table code. Applies only to + cartridges with more thatn 2^16 segments, where cartridges could + not be shared with various backup programs for other operating + systems. + +-- Fix a compilation bug with 2.0.x kernels + ===== Release notes for ftape-4.03 30/06/00 ===== -- Make sure the whole stuff compiles with kernels up to 2.4.0 diff -u --recursive --new-file ftape-4.03/Rules.make ftape-4.04/Rules.make --- ftape-4.03/Rules.make Fri Jun 23 14:05:14 2000 +++ ftape-4.04/Rules.make Thu Jul 20 12:24:47 2000 @@ -17,8 +17,8 @@ # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. # # $RCSfile: Rules.make,v $ -# $Revision: 1.14 $ -# $Date: 2000/06/23 12:05:14 $ +# $Revision: 1.16 $ +# $Date: 2000/07/20 10:24:47 $ # # Makefile rules for the QIC-40/80/3010/3020 ftape driver # @@ -57,16 +57,24 @@ unexport LX_OBJS unexport SYMTAB_OBJS +%.o: %.s $(TOPDIR)/MCONFIG $(LINUX_LOCATION)/.config \ + $(TOPDIR)/include/linux/autoconf.h \ + $(TOPDIR)/Makefile Makefile + $(AS) $(ASFLAGS) $(EXTRA_CFLAGS) -o $@ $< + %.o: %.c $(TOPDIR)/MCONFIG $(LINUX_LOCATION)/.config \ - $(TOPDIR)/include/linux/autoconf.h - $(CC) $(CFLAGS) -c $< + $(TOPDIR)/include/linux/autoconf.h \ + $(TOPDIR)/Makefile Makefile + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c -o $@ $< %.s: %.c $(TOPDIR)/MCONFIG $(LINUX_LOCATION)/.config \ - $(TOPDIR)/include/linux/autoconf.h - $(CC) $(SFLAGS) -S $< + $(TOPDIR)/include/linux/autoconf.h \ + $(TOPDIR)/Makefile Makefile + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -S $< -o $@ .%.d: %.c $(TOPDIR)/MCONFIG $(LINUX_LOCATION)/.config \ - $(TOPDIR)/include/linux/autoconf.h + $(TOPDIR)/include/linux/autoconf.h \ + $(TOPDIR)/Makefile Makefile -@set -e ; \ $(CC) -M $(CPPFLAGS) $< | sed 's/\($*\.o\):/\1 $@:/g' > $@ diff -u --recursive --new-file ftape-4.03/ftape/compressor/Makefile ftape-4.04/ftape/compressor/Makefile --- ftape-4.03/ftape/compressor/Makefile Tue Aug 31 11:51:25 1999 +++ ftape-4.04/ftape/compressor/Makefile Fri Jul 7 13:58:27 2000 @@ -16,8 +16,8 @@ # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. # # $RCSfile: Makefile,v $ -# $Revision: 1.5 $ -# $Date: 1999/08/31 09:51:25 $ +# $Revision: 1.7 $ +# $Date: 2000/07/07 11:58:27 $ # # Makefile for the optional compressor for th zftape VFS # interface to the QIC-40/80/3010/3020 floppy-tape driver for @@ -33,18 +33,11 @@ include $(TOPDIR)/MCONFIG endif -EXTRA_CFLAGS := -DZFT_OBSOLETE - O_TARGET := zft-compressor.o O_OBJS = zftape-compress.o lzrw3.o M_OBJS = $(O_TARGET) -include $(TOPDIR)/Rules.make - -# -# sorry, a special rule. -# -lzrw3.o: lzrw3.c - $(CC) $(CFLAGS) -O6 -funroll-all-loops -c $< +CFLAGS_lzrw3.o := -O6 -funroll-all-loops +include $(TOPDIR)/Rules.make diff -u --recursive --new-file ftape-4.03/ftape/compressor/lzrw3.c ftape-4.04/ftape/compressor/lzrw3.c --- ftape-4.03/ftape/compressor/lzrw3.c Fri Dec 18 23:01:01 1998 +++ ftape-4.04/ftape/compressor/lzrw3.c Thu Jul 6 15:45:29 2000 @@ -1,7 +1,7 @@ /* * $RCSfile: lzrw3.c,v $ - * $Revision: 1.4 $ - * $Date: 1998/12/18 22:01:01 $ + * $Revision: 1.5 $ + * $Date: 2000/07/06 13:45:29 $ * * Implementation of Ross Williams lzrw3 algorithm. Adaption for zftape. * @@ -265,8 +265,11 @@ /* is fussy about non-aligned arrays of words. To avoid these problems the */ /* following macro can be used to "waste" from 0 to 3 bytes so as to align */ /* the argument pointer. */ -#define ULONG_ALIGN_UP(X) ((((ULONG)X)+sizeof(ULONG)-1)&~(sizeof(ULONG)-1)) - +#if 0 +# define ULONG_ALIGN_UP(X) ((((ULONG)X)+sizeof(ULONG)-1)&~(sizeof(ULONG)-1)) +#else +# define ULONG_ALIGN_UP(X) ((((unsigned long)X)+sizeof(ULONG)-1)&~(sizeof(ULONG)-1)) +#endif /* The following constant defines the maximum length of an uncompressed item. */ /* This definition must not be changed; its value is hardwired into the code. */ diff -u --recursive --new-file ftape-4.03/ftape/lowlevel/fdc-io.c ftape-4.04/ftape/lowlevel/fdc-io.c --- ftape-4.03/ftape/lowlevel/fdc-io.c Sat Sep 11 16:58:58 1999 +++ ftape-4.04/ftape/lowlevel/fdc-io.c Mon Jul 10 23:23:32 2000 @@ -19,8 +19,8 @@ * * $RCSfile: fdc-io.c,v $ - * $Revision: 1.41 $ - * $Date: 1999/09/11 14:58:58 $ + * $Revision: 1.42 $ + * $Date: 2000/07/10 21:23:32 $ * * This file contains the low-level floppy disk interface code * for the QIC-40/80/3010/3020 floppy-tape driver "ftape" for @@ -799,7 +799,8 @@ * fdc_interrupt_wait() enables the fdc irq again */ if (fdc_interrupt_wait(fdc, 1 * FT_SECOND) < 0) { - TRACE(ft_t_flow, "no drive polling interrupt!"); + TRACE(ft_t_flow, "no drive polling interrupt! " + " (ignore message if everything works)"); fdc_disable_irq(fdc); dor_reset(fdc, 0); fdc_enable_irq(fdc); diff -u --recursive --new-file ftape-4.03/ftape/lowlevel/ftape-read.c ftape-4.04/ftape/lowlevel/ftape-read.c --- ftape-4.03/ftape/lowlevel/ftape-read.c Sun Feb 7 02:01:42 1999 +++ ftape-4.04/ftape/lowlevel/ftape-read.c Sun Jul 23 22:30:26 2000 @@ -18,8 +18,8 @@ * * $RCSfile: ftape-read.c,v $ - * $Revision: 1.28 $ - * $Date: 1999/02/07 01:01:42 $ + * $Revision: 1.29 $ + * $Date: 2000/07/23 20:30:26 $ * * This file contains the reading code * for the QIC-117 floppy-tape driver for Linux. @@ -614,8 +614,17 @@ TRACE(ft_t_info, "the famous Colorado bug: max_floppy_track off by one !"); max_floppy_track = 149; } - ftape->segments_per_head = ((max_floppy_sector/FT_SECTORS_PER_SEGMENT) * - (max_floppy_track + 1)); + /* another max_floppy_track bug. Seems to affect some OS/2 + * software. Reported by Mike Hardy + */ + if (ftape->segments_per_track == 150 && + ftape->tracks_per_tape == 28 && + max_floppy_side == 6 && + max_floppy_track == 254 && + max_floppy_sector == 128) { +TRACE(ft_t_info, "the famous OS/2 bug: max_floppy_track off by 105 !"); + max_floppy_track = 149; + } /* This test will compensate for some bug reported by Dima * Brodsky. Seems to be a Colorado bug, either. (freebee * Imation tape shipped together with Colorado T3000 @@ -661,6 +670,8 @@ max_floppy_side = 54; } #endif + ftape->segments_per_head = ((max_floppy_sector/FT_SECTORS_PER_SEGMENT) * + (max_floppy_track + 1)); should_be_max_floppy_side = ((ftape->segments_per_track * ftape->tracks_per_tape -1) / ftape->segments_per_head ); diff -u --recursive --new-file ftape-4.03/ftape/parport/trakker.c ftape-4.04/ftape/parport/trakker.c --- ftape-4.03/ftape/parport/trakker.c Fri Jun 30 12:53:42 2000 +++ ftape-4.04/ftape/parport/trakker.c Thu Jul 6 16:58:17 2000 @@ -65,8 +65,8 @@ /* Global vars. */ char trakker_src[] __initdata = "$RCSfile: trakker.c,v $"; -char trakker_rev[] __initdata = "$Revision: 1.19 $"; -char trakker_dat[] __initdata = "$Date: 2000/06/30 10:53:42 $"; +char trakker_rev[] __initdata = "$Revision: 1.20 $"; +char trakker_dat[] __initdata = "$Date: 2000/07/06 14:58:17 $"; /* If you have problems with this driver try to define some of these */ #undef FULL_HANDSHAKE @@ -1117,7 +1117,7 @@ trakker_id, trakker->parinfo.dev->private); #endif #endif - trakker->IRQ = irq; + fdc->irq = trakker->IRQ = irq; } #endif if (trakker->IRQ > 0) { diff -u --recursive --new-file ftape-4.03/ftape/zftape/Makefile ftape-4.04/ftape/zftape/Makefile --- ftape-4.03/ftape/zftape/Makefile Fri Dec 18 23:39:04 1998 +++ ftape-4.04/ftape/zftape/Makefile Thu Jul 6 16:42:20 2000 @@ -16,8 +16,8 @@ # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. # # $RCSfile: Makefile,v $ -# $Revision: 1.8 $ -# $Date: 1998/12/18 22:39:04 $ +# $Revision: 1.9 $ +# $Date: 2000/07/06 14:42:20 $ # # Makefile for the QIC-40/80/3010/3020 zftape interface VFS to # ftape @@ -35,11 +35,6 @@ SUB_DIRS := MOD_SUB_DIRS := $(SUB_DIRS) ALL_SUB_DIRS := $(SUB_DIRS) - -# ZFT_OBSOLETE - enable the MTIOC_ZFTAPE_GETBLKSZ ioctl. You should -# leave this enabled for compatibility with taper. - -EXTRA_CFLAGS := -DZFT_OBSOLETE O_TARGET := zftape.o O_OBJS := zftape-rw.o zftape-ctl.o zftape-read.o \ diff -u --recursive --new-file ftape-4.03/ftape/zftape/zftape-buffers.c ftape-4.04/ftape/zftape/zftape-buffers.c --- ftape-4.03/ftape/zftape/zftape-buffers.c Tue Aug 31 11:52:51 1999 +++ ftape-4.04/ftape/zftape/zftape-buffers.c Wed Jul 12 19:20:28 2000 @@ -17,8 +17,8 @@ * * $RCSfile: zftape-buffers.c,v $ - * $Revision: 1.12 $ - * $Date: 1999/08/31 09:52:51 $ + * $Revision: 1.14 $ + * $Date: 2000/07/12 17:20:28 $ * * This file contains the dynamic buffer allocation routines * of zftape @@ -95,9 +95,9 @@ ftape_vfree(FTAPE_SEL(zftape->unit), &zftape->hseg_buf, FT_SEGMENT_SIZE); zft_release_deblock_buffer(zftape, &zftape->deblock_buf); + ftape_vfree(FTAPE_SEL(zftape->unit), &zftape->vtbl_buf, FT_SEGMENT_SIZE); zft_free_vtbl(zftape); -#ifdef ZFT_OBSOLETE # if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) /* read-only compatibility with pre-ftape-4.x compressed volumes */ @@ -107,7 +107,6 @@ (*zft_cmpr_ops->reset)(zftape->cmpr_handle); } # endif -#endif zft_zap_write_buffers(zftape); TRACE_EXIT; } diff -u --recursive --new-file ftape-4.03/ftape/zftape/zftape-ctl.c ftape-4.04/ftape/zftape/zftape-ctl.c --- ftape-4.03/ftape/zftape/zftape-ctl.c Tue Sep 7 01:16:42 1999 +++ ftape-4.04/ftape/zftape/zftape-ctl.c Sun Jul 23 22:31:00 2000 @@ -1,5 +1,5 @@ /* - * Copyright (C) 1996-1998 Claus-Justus Heine + * Copyright (C) 1996-2000 Claus-Justus Heine This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,8 +17,8 @@ * * $RCSfile: zftape-ctl.c,v $ - * $Revision: 1.41 $ - * $Date: 1999/09/06 23:16:42 $ + * $Revision: 1.45 $ + * $Date: 2000/07/23 20:31:00 $ * * This file contains the non-read/write zftape functions * for the QIC-40/80/3010/3020 floppy-tape driver for Linux. @@ -152,8 +152,7 @@ zft_zap_read_buffers(zftape); zft_zap_write_buffers(zftape); zft_prevent_flush(zftape); -#ifdef ZFT_OBSOLETE -# if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) +#if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) /* read-only compatibility with pre-ftape-4.x compressed volumes */ /* unlock the compresison module if it is loaded. * The zero arg means not to try to load the module. @@ -162,7 +161,6 @@ (*zft_cmpr_ops->reset)(zftape->cmpr_handle); /* unlock */ } #endif -#endif TRACE_EXIT; } @@ -172,6 +170,8 @@ zftape->header_read = zftape->vtbl_read = zftape->old_ftape = + zftape->exvt_extension = + zftape->vtbl_broken = zftape->offline = zftape->write_protected = zftape->going_offline = @@ -398,8 +398,7 @@ exceed = 0; } -#ifdef ZFT_OBSOLETE -# if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) +#if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) /* read-only compatibility with pre-ftape-4.x compressed volumes */ if (zftape->use_compression && volume->use_compression) { TRACE_CATCH(zft_cmpr_lock(zftape, 1 /* try to load */),); @@ -409,7 +408,6 @@ pos->tape_pos = zft_calc_tape_pos(zftape, pos->seg_pos); pos->tape_pos += pos->seg_byte_pos; } else -# endif #endif { pos->volume_pos = zft_mul_blksz(new_block_pos, volume->blk_sz); @@ -791,9 +789,12 @@ * (!zftape->tape_at_lbot() && -- tape no at logical BOT * !(zft_tape_at_eom() || -- tape not at logical EOM (or EOD) * (zft_tape_at_eom() && - * zft_old_ftape()))) -- we can't add new volume to tapes - * written by old ftape because ftape - * don't use the volume table + * (zftape->old_ftape || -- we can't add new volume to tapes + * written by old ftape because ftape + * don't use the volume table + * zftape->exvt_extension)))) -- EXVT extension is not supported. + * So we can't write to the tape in + * this case. * * when the drive is in true raw mode (aka /dev/rawft0) then we don't * care about LBOT and EOM conditions. This device is intended for a @@ -834,9 +835,10 @@ * not at BOT because they use the vtbl * segment for storing data */ - if (zftape->old_ftape) { - TRACE_ABORT(-EACCES, ft_t_warn, - "Cannot write to cartridges written by old ftape when not at BOT"); + if (zft_vtbl_soft_ro(zftape)) { + TRACE(ft_t_warn, + "vtbl r/o condition, cannot write"); + TRACE_EXIT -EACCES; } /* not at BOT, but allow writes at EOD, of course */ @@ -884,7 +886,7 @@ } if (zftape->volume_table_changed || zftape->header_changed) { /* header segments dirty if tape not write protected */ - return !(ftape->write_protected || zftape->old_ftape); + return !(ftape->write_protected || zft_vtbl_soft_ro(zftape)); } return 0; } @@ -960,7 +962,7 @@ zft_init_driver(zftape); zft_uninit_mem(zftape); } -#if ZFT_OBSOLETE +#if CONFIG_ZFT_OBSOLETE else if ((old_unit & ZFT_RAW_MODE) != (dev_minor & ZFT_RAW_MODE)) { @@ -993,8 +995,7 @@ ft_t_warn, "wrong access mode %s cartridge", ftape->no_tape ? "without a" : "with write protected"); } -#ifdef ZFT_OBSOLETE -# if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) +#if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) /* Hack: read-only compatibility with pre-ftape-4.x compressed * volumes */ @@ -1005,7 +1006,6 @@ ftape_disable(sel); /* resets ft_no_tape */ TRACE_EXIT -EROFS; } -# endif #endif zftape->write_protected = (access_mode == O_RDONLY || ftape->write_protected != 0); @@ -1058,7 +1058,7 @@ TRACE_EXIT 0; } if (zftape->header_read && (zftape->vtbl_read || !zftape->qic_mode) && - !(ftape->write_protected || zftape->old_ftape)) { + !(ftape->write_protected || zft_vtbl_soft_ro(zftape))) { result = zft_flush_buffers(zftape); TRACE(ft_t_noise, "writing file mark at current position"); if (zftape->qic_mode && @@ -1111,14 +1111,12 @@ zft_tape_at_lbot(zftape, &zftape->pos) ? "no" : "yes"); /* don't unlock the door */ } else { -#ifdef ZFT_OBSOLETE -# if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) +#if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) /* read-only compatibility with pre-ftape-4.x compressed volumes */ if (zft_cmpr_lock(zftape, 0 /* don't load */) == 0) { /* unlock it again */ (*zft_cmpr_ops->reset)(zftape->cmpr_handle); } -# endif #endif } if (!zftape->volume_table_changed && @@ -1211,9 +1209,14 @@ mtget->mt_gstat = GMT_ONLINE(~0UL); /* should rather return the status of the cartridge * than the access mode of the file, therefor use - * ft_write_protected, not zft_write_protected + * ft_write_protected, not zft_write_protected + * + * However, in some case (VTBL is trashed, or old + * ftape-2.x cartridge) the cartridge is "soft" + * write-protected. In this case we also set the + * write-protect bit. */ - if (ftape->write_protected) { + if (ftape->write_protected || zft_vtbl_soft_ro(zftape)) { mtget->mt_gstat |= GMT_WR_PROT(~0UL); } /* this catches non-formatted */ @@ -1264,6 +1267,8 @@ struct mtftseg * mtftseg, int arg_size) { ftape_info_t *ftape = zftape->ftape; + void *buffer; + int result; TRACE_FUN(ft_t_flow); TRACE(ft_t_noise, "Mag tape ioctl command: MTIOCRDFTSEG"); @@ -1298,56 +1303,51 @@ * The header segment has been read anyway, no need * to re-read it */ -#if LINUX_VERSION_CODE > KERNEL_VER(2,1,3) - if (copy_to_user(mtftseg->mt_data, - zftape->hseg_buf, - FT_SEGMENT_SIZE) != 0) { - TRACE_EXIT -EFAULT; - } -#else - TRACE_CATCH(verify_area(VERIFY_WRITE, mtftseg->mt_data, - FT_SEGMENT_SIZE),); - memcpy_tofs(mtftseg->mt_data, zftape->hseg_buf, - FT_SEGMENT_SIZE); -#endif + buffer = zftape->hseg_buf; mtftseg->mt_result = FT_SEGMENT_SIZE; - TRACE_EXIT 0; - } else if (mtftseg->mt_segno - < - zftape->ftape->first_data_segment) { + } else if (mtftseg->mt_segno < zftape->ftape->first_data_segment) { + buffer = NULL; mtftseg->mt_result = -EIO; - TRACE_EXIT 0; + } else if (mtftseg->mt_segno == zftape->ftape->first_data_segment) { + if (!zftape->vtbl_read) { + result = zft_read_volume_table(zftape); + mtftseg->mt_result = + result < 0 ? result : zftape->vtbl_size; + } else { + mtftseg->mt_result = zftape->vtbl_size; + } + buffer = zftape->vtbl_buf; + } else { + mtftseg->mt_result = zft_fetch_segment(zftape, + mtftseg->mt_segno, + &zftape->deblock_buf, + mtftseg->mt_mode); + buffer = zftape->deblock_buf; } - mtftseg->mt_result = zft_fetch_segment(zftape, - mtftseg->mt_segno, - &zftape->deblock_buf, - mtftseg->mt_mode); + if (mtftseg->mt_result < 0) { - /* a negativ result is not an ioctl error. if - * the user wants to read damaged tapes, - * it's up to her/him + /* a negativ result is not an ioctl error. if the + * user wants to read damaged tapes, it's up to + * her/him */ TRACE_EXIT 0; } #if 1 /* the following check can be removed when no longer needed */ - else if (zftape->deblock_buf == NULL) { + else if (buffer == NULL) { TRACE(ft_t_err, "no deblock buffer"); TRACE_EXIT -EIO; } #endif #if LINUX_VERSION_CODE > KERNEL_VER(2,1,3) - if (copy_to_user(mtftseg->mt_data, - zftape->deblock_buf, - mtftseg->mt_result) != 0) { + if (copy_to_user(mtftseg->mt_data, buffer, mtftseg->mt_result) != 0) { TRACE_EXIT -EFAULT; } #else TRACE_CATCH(verify_area(VERIFY_WRITE, mtftseg->mt_data, mtftseg->mt_result),); - memcpy_tofs(mtftseg->mt_data, zftape->deblock_buf, - mtftseg->mt_result); + memcpy_tofs(mtftseg->mt_data, buffer, mtftseg->mt_result); #endif TRACE_EXIT 0; } @@ -1476,17 +1476,15 @@ volinfo->mt_size = volume->size >> 10; volinfo->mt_rawsize = ((zft_calc_tape_pos(zftape, volume->end_seg + 1) >> 10) - (zft_calc_tape_pos(zftape, volume->start_seg) >> 10)); -#ifdef ZFT_OBSOLETE -# if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) +#if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) /* read-only compatibility with pre-ftape-4.x compressed volumes */ volinfo->mt_cmpr = volume->use_compression; -# endif #endif TRACE_EXIT 0; } #endif -#ifdef ZFT_OBSOLETE +#ifdef CONFIG_ZFT_OBSOLETE static int mtioc_zftape_getblksz(zftape_info_t *zftape, struct mtblksz *blksz, int arg_size) { @@ -1838,7 +1836,7 @@ #ifdef MTIOCFTFORMAT struct mtftformat mtftformat; #endif -#ifdef ZFT_OBSOLETE +#ifdef CONFIG_ZFT_OBSOLETE struct mtblksz mtblksz; #endif #ifdef MTIOCFTCMD @@ -1884,7 +1882,7 @@ result = mtiocvolinfo(zftape, &krnl_arg.mtvolinfo, arg_size); break; #endif -#ifdef ZFT_OBSOLETE +#ifdef CONFIG_ZFT_OBSOLETE case MTIOC_ZFTAPE_GETBLKSZ: result = mtioc_zftape_getblksz(zftape, &krnl_arg.mtblksz, arg_size); break; diff -u --recursive --new-file ftape-4.03/ftape/zftape/zftape-ctl.h ftape-4.04/ftape/zftape/zftape-ctl.h --- ftape-4.03/ftape/zftape/zftape-ctl.h Tue Aug 31 11:52:51 1999 +++ ftape-4.04/ftape/zftape/zftape-ctl.h Thu Jul 20 13:17:16 2000 @@ -20,8 +20,8 @@ * * $RCSfile: zftape-ctl.h,v $ - * $Revision: 1.12 $ - * $Date: 1999/08/31 09:52:51 $ + * $Revision: 1.15 $ + * $Date: 2000/07/20 11:17:16 $ * * This file contains the non-standard IOCTL related definitions * for the QIC-40/80 floppy-tape driver for Linux. @@ -39,6 +39,8 @@ ftape_info_t *ftape; unsigned int qic_mode:1; /* use the vtbl */ unsigned int old_ftape:1; /* prevents old ftaped tapes to be overwritten */ + unsigned int exvt_extension:1; /* force r/o */ + unsigned int vtbl_broken:1; /* force r/o */ unsigned int offline:1; unsigned int going_offline:1; unsigned int write_protected:1; @@ -69,6 +71,7 @@ zft_position pos; __u8 *deblock_buf; __u8 *hseg_buf; + __u8 *vtbl_buf; zft_status_enum io_state; unsigned int blk_sz; __s64 capacity; @@ -100,12 +103,10 @@ struct list_head hard_errors; /* the list of pending hard errors */ int hard_error_cnt; /* how many of them */ -#ifdef ZFT_OBSOLETE -# if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) +#if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) /* read-only compatibility with pre-ftape-4.x compressed volumes */ unsigned int use_compression:1; void *cmpr_handle; -# endif #endif #ifndef CONFIG_FT_NO_TRACE_AT_ALL diff -u --recursive --new-file ftape-4.03/ftape/zftape/zftape-init.c ftape-4.04/ftape/zftape/zftape-init.c --- ftape-4.03/ftape/zftape/zftape-init.c Mon Jul 3 11:01:26 2000 +++ ftape-4.04/ftape/zftape/zftape-init.c Thu Jul 20 15:18:05 2000 @@ -46,10 +46,10 @@ static devfs_handle_t devfs_zq[4]; static devfs_handle_t devfs_zqn[4]; # endif +# if CONFIG_ZFT_OBSOLETE static devfs_handle_t devfs_raw[4]; static devfs_handle_t devfs_rawn[4]; - -#define CREATE_FT_COMPATIBILITY_LINKS 1 +# endif #endif @@ -62,8 +62,8 @@ #include "zftape_syms.h" char zft_src[] __initdata = "$RCSfile: zftape-init.c,v $"; -char zft_rev[] __initdata = "$Revision: 1.32 $"; -char zft_dat[] __initdata = "$Date: 2000/07/03 09:01:26 $"; +char zft_rev[] __initdata = "$Revision: 1.38 $"; +char zft_dat[] __initdata = "$Date: 2000/07/20 13:18:05 $"; int ft_major_device_number = QIC117_TAPE_MAJOR; @@ -140,7 +140,11 @@ #if LINUX_VERSION_CODE >= KERNEL_VER(2,4,0) owner: THIS_MODULE, #endif +#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,60) llseek: zft_seek, +#else + lseek: zft_seek, +#endif read: zft_read, write: zft_write, ioctl: zft_ioctl, @@ -288,6 +292,13 @@ TRACE(ft_t_data_flow, "called with count: %ld", (unsigned long)req_len); +#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,60) + if (ppos != &fp->f_pos) { + /* "A request was outside the capabilities of the device." */ + TRACE_EXIT -ENXIO; + } +#endif + if (!busy_flag[sel] || !zftape || MINOR(ino->i_rdev) != zftape->unit || !zftape->ftape || zftape->ftape->failure) { @@ -327,7 +338,12 @@ TRACE_FUN(ft_t_flow); TRACE(ft_t_data_flow, "called with count: %ld", (unsigned long)req_len); - +#if LINUX_VERSION_CODE >= KERNEL_VER(2,1,60) + if (ppos != &fp->f_pos) { + /* "A request was outside the capabilities of the device." */ + TRACE_EXIT -ENXIO; + } +#endif if (!busy_flag[sel] || !zftape || MINOR(ino->i_rdev) != zftape->unit || !zftape->ftape || zftape->ftape->failure) { @@ -362,8 +378,7 @@ #define GLOBAL_TRACING #include "../lowlevel/ftape-real-tracing.h" -#ifdef ZFT_OBSOLETE -# if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) +#if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) struct zft_cmpr_ops *zft_cmpr_ops = NULL; /* the compression module has to call this function to hook into the @@ -395,7 +410,7 @@ int zft_cmpr_lock(zftape_info_t *zftape, int try_to_load) { if (zft_cmpr_ops == NULL) { -# ifdef FT_MODULE_AUTOLOAD +# ifdef FT_MODULE_AUTOLOAD if (try_to_load) { request_module("zft-compressor"); if (zft_cmpr_ops == NULL) { @@ -404,52 +419,24 @@ } else { return -ENOSYS; } -# else +# else return -ENOSYS; -# endif +# endif } zftape->cmpr_handle = (*zft_cmpr_ops->lock)(zftape); return 0; } -# ifdef CONFIG_ZFT_COMPRESSOR +# ifdef CONFIG_ZFT_COMPRESSOR extern int zft_compressor_init(void); -# endif -# endif /* CONFIG_ZFT_COMPRESSOR || CONFIG_ZFT_COMPRESSOR_MODULE */ -#endif /* ZFT_OBSOLETE */ +# endif +#endif /* CONFIG_ZFT_COMPRESSOR || CONFIG_ZFT_COMPRESSOR_MODULE */ #ifdef FT_TRACE_ATTR # undef FT_TRACE_ATTR #endif #define FT_TRACE_ATTR __initlocaldata -#if CREATE_FT_COMPATIBILITY_LINKS -static void zft_devfs_mk_symlink(const char *name, - int sel, devfs_handle_t entry) -{ - char tmpname[40], tmpname1[40]; - - sprintf(tmpname, "%s%d", name, sel); - sprintf(tmpname1, "ftape/%d/%s", sel, name); - devfs_mk_symlink(NULL, tmpname, - 0, DEVFS_FL_DEFAULT, - tmpname1, 0, NULL, NULL); -} - -# ifdef MODULE -static void zft_devfs_rm_entry(const char *name, int sel) -{ - char tmpname[40]; - - sprintf(tmpname, "%s%d", name, sel); - devfs_unregister(devfs_find_handle(NULL, tmpname, 0, 0, 0, 0, 0)); -} -# endif -#else -# define zft_devfs_mk_symlink(name, sel, entry) do { /* */ } while (0) -# define zft_devfs_rm_entry(name, el) do { /* */ } while (0) -#endif - static int __init zft_devfs_register(void) { #if LINUX_VERSION_CODE < KERNEL_VER(2,3,46) @@ -463,73 +450,60 @@ TRACE_CATCH(devfs_register_chrdev(ft_major_device_number, "zft", &zft_cdev),); - ftape_devfs_handle = devfs_mk_dir(NULL, "ftape", 0, NULL); + ftape_devfs_handle = devfs_mk_dir(NULL, "ftape", NULL); for (sel = 0; sel < 4; sel++) { char tmpname[40]; sprintf(tmpname, "%d", sel); devfs_handle[sel] = devfs_mk_dir(ftape_devfs_handle, - tmpname, 0, NULL); + tmpname, NULL); - devfs_q[sel] = devfs_register(devfs_handle[sel], "qft", + devfs_q[sel] = devfs_register(devfs_handle[sel], "mt", DEVFS_FL_DEFAULT, ft_major_device_number, sel, S_IFCHR | S_IRUSR | S_IWUSR, &zft_cdev, NULL); - zft_devfs_mk_symlink("qft", sel, devfs_q[sel]); - devfs_qn[sel] = devfs_register(devfs_handle[sel], "nqft", + devfs_qn[sel] = devfs_register(devfs_handle[sel], "mtn", DEVFS_FL_DEFAULT, ft_major_device_number, sel|FTAPE_NO_REWIND , S_IFCHR | S_IRUSR | S_IWUSR, &zft_cdev, NULL); - zft_devfs_mk_symlink("nqft", sel, devfs_qn[sel]); # if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) devfs_zq[sel] = - devfs_register(devfs_handle[sel], "zqft", + devfs_register(devfs_handle[sel], "mtz", DEVFS_FL_DEFAULT, ft_major_device_number, sel|ZFT_ZIP_MODE, S_IFCHR | S_IRUSR | S_IWUSR, &zft_cdev, NULL); - zft_devfs_mk_symlink("zqft", sel, devfs_zq[sel]); devfs_zqn[sel] = - devfs_register(devfs_handle[sel], "nzqft", + devfs_register(devfs_handle[sel], "mtzn", DEVFS_FL_DEFAULT, ft_major_device_number, sel|ZFT_ZIP_MODE|FTAPE_NO_REWIND, S_IFCHR | S_IRUSR | S_IWUSR, &zft_cdev, NULL); - zft_devfs_mk_symlink("nzqft", sel, devfs_zqn[sel]); # endif -# if ZFT_OBSOLETE +# if CONFIG_ZFT_OBSOLETE devfs_raw[sel] = - devfs_register(devfs_handle[sel], "rawft", + devfs_register(devfs_handle[sel], "mtr", DEVFS_FL_DEFAULT, ft_major_device_number, sel|ZFT_RAW_MODE, S_IFCHR | S_IRUSR | S_IWUSR, &zft_cdev, NULL); devfs_rawn[sel] = - devfs_register(devfs_handle[sel], "nrawft", + devfs_register(devfs_handle[sel], "mtrn", DEVFS_FL_DEFAULT, ft_major_device_number, sel|ZFT_RAW_MODE|FTAPE_NO_REWIND, S_IFCHR | S_IRUSR | S_IWUSR, &zft_cdev, NULL); -# else - devfs_mk_symlink(devfs_handle[sel], "rawft", - 0, DEVFS_FL_DEFAULT, - "qft", 0, &devfs_raw[sel], NULL); - devfs_mk_symlink(devfs_handle[sel], "nrawft", - 0, DEVFS_FL_DEFAULT, - "nqft", 0, &devfs_rawn[sel], NULL); # endif - zft_devfs_mk_symlink("rawft", sel, devfs_raw[sel]); - zft_devfs_mk_symlink("nrawft", sel, devfs_rawn[sel]); devfs_register_tape(devfs_q[sel]); } #endif @@ -569,16 +543,14 @@ "installing zftape VFS interface for ftape driver ..."); TRACE_CATCH(zft_devfs_register(),); -#ifdef ZFT_OBSOLETE -# ifdef CONFIG_ZFT_COMPRESSOR +#ifdef CONFIG_ZFT_COMPRESSOR (void)zft_compressor_init(); -# elif defined(CONFIG_ZFT_COMPRESSOR_MODULE) -# if LINUX_VERSION_CODE >= KERNEL_VER(1,2,0) &&\ +#elif defined(CONFIG_ZFT_COMPRESSOR_MODULE) +# if LINUX_VERSION_CODE >= KERNEL_VER(1,2,0) &&\ LINUX_VERSION_CODE < KERNEL_VER(2,1,18) register_symtab(&zft_symbol_table); /* add global zftape symbols */ -# endif -# endif /* CONFIG_ZFT_COMPRESSOR */ -#endif /* ZFT_OBSOLETE */ +# endif +#endif /* CONFIG_ZFT_COMPRESSOR */ TRACE_EXIT 0; } @@ -611,14 +583,14 @@ */ int init_module(void) { -# if !defined(CONFIG_ZFT_COMPRESSOR_MODULE) || !defined(ZFT_OBSOLETE) -# if LINUX_VERSION_CODE >= KERNEL_VER(1,1,85)&&\ - LINUX_VERSION_CODE < KERNEL_VER(2,1,18) +# if !defined(CONFIG_ZFT_COMPRESSOR_MODULE) +# if LINUX_VERSION_CODE >= KERNEL_VER(1,1,85) && \ + LINUX_VERSION_CODE < KERNEL_VER(2,1,18) register_symtab(0); /* remove global ftape symbols */ # else EXPORT_NO_SYMBOLS; # endif -# endif /* CONFIG_ZFT_COMPRESSOR_MODULE || !ZFT_OBSOLETE */ +# endif /* CONFIG_ZFT_COMPRESSOR_MODULE */ # if LINUX_VERSION_CODE >= KERNEL_VER(2,1,18) if (!mod_member_present(&__this_module, can_unload)) { return -EBUSY; @@ -655,16 +627,6 @@ ftape_kfree(FTAPE_SEL(sel), &zftapes[sel], sizeof(*zftapes[sel])); } # if LINUX_VERSION_CODE >= KERNEL_VER(2,3,46) -# if CREATE_FT_COMPATIBILITY_LINKS - zft_devfs_rm_entry("qft", sel); - zft_devfs_rm_entry("nqft", sel); -# if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) - zft_devfs_rm_entry("zqft", sel); - zft_devfs_rm_entry("nzqft", sel); -# endif - zft_devfs_rm_entry("rawft", sel); - zft_devfs_rm_entry("nrawft", sel); -# endif devfs_unregister (devfs_q[sel]); devfs_q[sel] = NULL; devfs_unregister (devfs_qn[sel]); @@ -675,10 +637,12 @@ devfs_unregister(devfs_zqn[sel]); devfs_zqn[sel] = NULL; # endif +# ifdef CONFIG_ZFT_OBSOLETE devfs_unregister(devfs_raw[sel]); devfs_raw[sel] = NULL; devfs_unregister(devfs_rawn[sel]); devfs_rawn[sel] = NULL; +#endif devfs_unregister(devfs_handle[sel]); devfs_handle[sel] = NULL; # endif diff -u --recursive --new-file ftape-4.03/ftape/zftape/zftape-init.h ftape-4.04/ftape/zftape/zftape-init.h --- ftape-4.03/ftape/zftape/zftape-init.h Tue Aug 31 11:52:51 1999 +++ ftape-4.04/ftape/zftape/zftape-init.h Thu Jul 6 16:42:21 2000 @@ -20,8 +20,8 @@ * * $RCSfile: zftape-init.h,v $ - * $Revision: 1.10 $ - * $Date: 1999/08/31 09:52:51 $ + * $Revision: 1.11 $ + * $Date: 2000/07/06 14:42:21 $ * * This file contains definitions and macro for the vfs * interface defined by zftape @@ -39,8 +39,7 @@ #include "../lowlevel/ftape-buffer.h" #include "../lowlevel/ftape-format.h" -#ifdef ZFT_OBSOLETE -# if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) +#if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) /* Only kept for compatibility with old zftape versions. */ #include "zftape-rw.h" @@ -70,8 +69,7 @@ extern struct zft_cmpr_ops *zft_cmpr_unregister(void); extern int zft_cmpr_lock(struct zftape_info *zftape, int try_to_load); -# endif /* CONFIG_ZFT_COMPRESSOR[_MODULE] */ -#endif /* ZFT_OBSOLETE */ +#endif /* CONFIG_ZFT_COMPRESSOR[_MODULE] */ #ifdef MODULE diff -u --recursive --new-file ftape-4.03/ftape/zftape/zftape-inline.h ftape-4.04/ftape/zftape/zftape-inline.h --- ftape-4.03/ftape/zftape/zftape-inline.h Tue Aug 31 11:52:51 1999 +++ ftape-4.04/ftape/zftape/zftape-inline.h Thu Jul 20 13:17:16 2000 @@ -21,8 +21,8 @@ * * $RCSfile: zftape-inline.h,v $ - * $Revision: 1.9 $ - * $Date: 1999/08/31 09:52:51 $ + * $Revision: 1.11 $ + * $Date: 2000/07/20 11:17:16 $ * * This file contains some inline functions that would hose up * the dependencies between header file pretty badly @@ -40,6 +40,7 @@ const zft_position *pos); extern inline int zft_tape_at_lbot (struct zftape_info *zftape, const zft_position *pos); +extern inline int zft_vtbl_soft_ro(const struct zftape_info *zftape); extern inline void zft_position_before_eof(struct zftape_info *zftape, zft_position *pos, const zft_volinfo *volume); @@ -50,6 +51,14 @@ extern inline __s64 zft_block_size(const struct zftape_info *zftape, const zft_volinfo *vtbl); +/* check whether we can alter the vtbl */ +extern inline int zft_vtbl_soft_ro(const struct zftape_info *zftape) +{ + return (zftape->old_ftape | + zftape->exvt_extension | + zftape->vtbl_broken) != 0; +} + /* this function decrements the zft_seg_pos counter if we are right * at the beginning of a segment. This is to handel fsfm/bsfm -- we * need to position before the eof mark. NOTE: zft_tape_pos is not @@ -106,8 +115,7 @@ extern inline __s64 zft_volume_size(const struct zftape_info *zftape, const zft_volinfo *vtbl) { -#if defined(ZFT_OBSOLETE) && \ - (defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE)) +#if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) if (!vtbl->use_compression || zftape->use_compression) { return vtbl->size; } @@ -127,8 +135,7 @@ extern inline __s64 zft_block_size(const struct zftape_info *zftape, const zft_volinfo *vtbl) { -#if defined(ZFT_OBSOLETE) && \ - (defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE)) +#if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) if (vtbl->use_compression && !zftape->use_compression) { return 1024; } diff -u --recursive --new-file ftape-4.03/ftape/zftape/zftape-read.c ftape-4.04/ftape/zftape/zftape-read.c --- ftape-4.03/ftape/zftape/zftape-read.c Tue Aug 31 11:52:51 1999 +++ ftape-4.04/ftape/zftape/zftape-read.c Wed Jul 12 19:20:28 2000 @@ -17,8 +17,8 @@ * * $RCSfile: zftape-read.c,v $ - * $Revision: 1.16 $ - * $Date: 1999/08/31 09:52:51 $ + * $Revision: 1.18 $ + * $Date: 2000/07/12 17:20:28 $ * * This file contains the high level reading code * for the QIC-117 floppy-tape driver for Linux. @@ -62,7 +62,8 @@ TRACE_FUN(ft_t_flow); TRACE_CATCH(ftape_vmalloc(FTAPE_SEL(zftape->unit), - &zftape->hseg_buf, FT_SEGMENT_SIZE),); + &zftape->hseg_buf, FT_SEGMENT_SIZE),); + zftape->deblock_buf = NULL; /* ftape_read_header_segment() will mess it up */ zftape->deblock_segment = -1; TRACE_CATCH(ftape_read_header_segment(zftape->ftape, @@ -125,7 +126,11 @@ if ((result = ftape_abort_operation(zftape->ftape)) < 0) { goto out; } - zft_extract_volume_headers(zftape, deblock_buf); + + TRACE_CATCH(zft_vmalloc_once(zftape, + &zftape->vtbl_buf, FT_SEGMENT_SIZE),); + memcpy(zftape->vtbl_buf, deblock_buf, FT_SEGMENT_SIZE); + zft_extract_volume_headers(zftape, zftape->vtbl_buf); zftape->vtbl_read = 1; out: TRACE_CATCH(fdc_put_deblock_buffer(zftape->ftape->fdc, &deblock_buf), @@ -245,8 +250,7 @@ int result = 0; TRACE_FUN(ft_t_flow); -#ifdef ZFT_OBSOLETE -# if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) +#if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) /* read-only compatibility with pre-ftape-4.x compressed volumes */ if (zftape->use_compression && volume->use_compression) { TRACE_CATCH(zft_cmpr_lock(zftape, 1 /* try to load */),); @@ -256,7 +260,6 @@ src_buf, seg_sz, pos, volume),); } else -# endif #endif { if (seg_sz - pos->seg_byte_pos < req_len) { diff -u --recursive --new-file ftape-4.03/ftape/zftape/zftape-rw.c ftape-4.04/ftape/zftape/zftape-rw.c --- ftape-4.03/ftape/zftape/zftape-rw.c Tue Sep 7 01:16:42 1999 +++ ftape-4.04/ftape/zftape/zftape-rw.c Mon Jul 10 23:24:28 2000 @@ -17,8 +17,8 @@ * * $RCSfile: zftape-rw.c,v $ - * $Revision: 1.19 $ - * $Date: 1999/09/06 23:16:42 $ + * $Revision: 1.21 $ + * $Date: 2000/07/10 21:24:28 $ * * This file contains some common code for the r/w code for * zftape. @@ -61,13 +61,12 @@ } } -/* ftape_set_flags(). Claus-Justus Heine, 1994/1995 - */ int zft_set_flags(zftape_info_t *zftape, unsigned minor_unit) { TRACE_FUN(ft_t_flow); -#ifdef ZFT_OBSOLETE /* otherwise only non-rewind bit is valid. */ +#if defined(CONFIG_ZFT_OBSOLETE) || \ + defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) # if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) /* read-only compatibility with pre-ftape-4.x compressed volumes */ zftape->use_compression = 0; @@ -78,10 +77,12 @@ case ZFT_ZIP_MODE: zftape->use_compression = 1; # endif +# if defined(CONFIG_ZFT_OBSOLETE) case 0: case ZFT_Q80_MODE: case ZFT_RAW_MODE: break; +# endif default: TRACE(ft_t_warn, "Warning:\n" KERN_INFO "Wrong combination of minor device bits.\n" diff -u --recursive --new-file ftape-4.03/ftape/zftape/zftape-vtbl.c ftape-4.04/ftape/zftape/zftape-vtbl.c --- ftape-4.03/ftape/zftape/zftape-vtbl.c Tue Aug 31 11:52:51 1999 +++ ftape-4.04/ftape/zftape/zftape-vtbl.c Thu Jul 20 15:19:21 2000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995-1998 Claus-Justus Heine + * Copyright (c) 1995-2000 Claus-Justus Heine This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -18,8 +18,8 @@ * * $RCSfile: zftape-vtbl.c,v $ - * $Revision: 1.21 $ - * $Date: 1999/08/31 09:52:51 $ + * $Revision: 1.25 $ + * $Date: 2000/07/20 13:19:21 $ * * This file defines a volume table as defined in various QIC * standards. @@ -28,6 +28,7 @@ * :( prgrams to identify the cartridge as used. */ + #include #include @@ -42,7 +43,7 @@ #include "zftape-vtbl.h" #include "zftape-inline.h" -#define ZFT_CMAP_HACK /* leave this defined to hide the compression map */ +#define ZFT_CMAP_HACK 1 /* leave this defined to hide the compression map */ /* * global variables @@ -88,6 +89,9 @@ { zft_volinfo *new; + zftape->exvt_extension = 0; + zftape->vtbl_broken = 0; + zft_free_vtbl(zftape); /* Create the two dummy vtbl entries @@ -100,11 +104,13 @@ zft_head_vtbl->end_seg = zftape->ftape->first_data_segment; zft_head_vtbl->blk_sz = zftape->blk_sz; zft_head_vtbl->count = -1; + zft_head_vtbl->offset = -128; zft_eom_vtbl->start_seg = zftape->ftape->first_data_segment+1; zft_eom_vtbl->end_seg = zftape->ftape->last_data_segment +1; zft_eom_vtbl->blk_sz = zftape->blk_sz; zft_eom_vtbl->count = 0; + zft_eom_vtbl->offset = 0; /* Reset the pointer for zft_find_volume() */ @@ -118,6 +124,7 @@ zftape->eot_vtbl.size = zftape->eot_vtbl.rawsize = 0; zftape->eot_vtbl.count = -1; + zftape->eot_vtbl.offset = -1; zftape->tape_vtbl.start_seg = zftape->ftape->first_data_segment; zftape->tape_vtbl.end_seg = zftape->ftape->last_data_segment; @@ -125,19 +132,7 @@ zftape->tape_vtbl.size = zftape->tape_vtbl.rawsize = zftape->capacity; zftape->tape_vtbl.count = 0; -} - -/* check for a valid VTBL signature. - */ -static int vtbl_signature_valid(__u8 signature[4]) -{ - const char *vtbl_ids[] = VTBL_IDS; /* valid signatures */ - int j; - - for (j = 0; - (j < NR_ITEMS(vtbl_ids)) && (memcmp(signature, vtbl_ids[j], 4) != 0); - j++); - return j < NR_ITEMS(vtbl_ids); + zftape->tape_vtbl.offset = -1; } /* We used to store the block-size of the volume in the volume-label, @@ -151,11 +146,15 @@ static int check_volume_label(zftape_info_t *zftape, const char *label, int *blk_sz) { - int valid_format; + int valid_format; char *blocksize; + char pr_label[VTBL_DESC_LEN+1]; TRACE_FUN(ft_t_flow); - TRACE(ft_t_noise, "called with \"%s\" / \"%s\"", label, ZFT_VOL_NAME); + memcpy(pr_label, label, VTBL_DESC_LEN); + pr_label[VTBL_DESC_LEN] = '\0'; + TRACE(ft_t_noise, "called with \"%s\" / \"%s\"", + pr_label, ZFT_VOL_NAME); if (strncmp(label, ZFT_VOL_NAME, strlen(ZFT_VOL_NAME)) != 0) { #if 0 *blk_sz = 1; /* smallest block size that we allow */ @@ -206,16 +205,31 @@ __u8 *entry, zft_volinfo *volume) { TRACE_FUN(ft_t_flow); - - if(strncmp(&entry[VTBL_EXT+EXT_ZFTAPE_SIG], ZFTAPE_SIG, - strlen(ZFTAPE_SIG)) == 0) { - TRACE(ft_t_noise, "got new style zftape vtbl entry"); - volume->blk_sz = GET2(entry, VTBL_EXT+EXT_ZFTAPE_BLKSZ); - volume->qic113 = entry[VTBL_EXT+EXT_ZFTAPE_QIC113]; + + if(memcmp(&entry[VTBL_EXT+EXT_ZFT_SIG], ZFT_SIG, ZFT_SIGLEN) == 0) { + TRACE(ft_t_noise, "got new style (v1) zftape vtbl entry"); + volume->blk_sz = GET2(entry, VTBL_EXT+EXT_ZFT_BLKSZ); + volume->qic113 = entry[VTBL_EXT+EXT_ZFT_QIC113]; + volume->version = 1; + TRACE_EXIT 1; + } else if (zftape->ftape->format_code == fmt_big && + memcmp(&entry[VTBL_6_EXT+EXT_6_ZFT_SIG], + ZFT_SIG2, ZFT_SIGLEN2) == 0) { + /* post v2 extension is required to be downwards compatible */ + volume->version = entry[VTBL_6_EXT+EXT_6_ZFT_SIGV]; + + TRACE(ft_t_noise, + "got new style (v%d) zftape vtbl entry", + volume->version); + + volume->blk_sz = GET2(entry, VTBL_6_EXT+EXT_6_ZFT_BLKSZ); + volume->qic113 = 1; TRACE_EXIT 1; } else { + volume->version = 0; TRACE_EXIT check_volume_label(zftape, - &entry[VTBL_DESC], &volume->blk_sz); + &entry[VTBL_DESC], + &volume->blk_sz); } } @@ -236,15 +250,23 @@ memset(&entry[VTBL_DESC] + n, ' ', VTBL_DESC_LEN - n); entry[VTBL_FLAGS] = (VTBL_FL_NOT_VERIFIED | VTBL_FL_SEG_SPANNING); entry[VTBL_M_NO] = 1; /* multi_cartridge_count */ - strcpy(&entry[VTBL_EXT+EXT_ZFTAPE_SIG], ZFTAPE_SIG); - PUT2(entry, VTBL_EXT+EXT_ZFTAPE_BLKSZ, vtbl->blk_sz); + if (zftape->ftape->format_code == fmt_big) { + memcpy(&entry[VTBL_6_EXT+EXT_6_ZFT_SIG],ZFT_SIG2, ZFT_SIGLEN2); + entry[VTBL_6_EXT+EXT_6_ZFT_SIGV] = 2; + PUT2(entry, VTBL_6_EXT+EXT_6_ZFT_BLKSZ, vtbl->blk_sz); + } else { + memcpy(&entry[VTBL_EXT+EXT_ZFT_SIG], ZFT_SIG, ZFT_SIGLEN); + PUT2(entry, VTBL_EXT+EXT_ZFT_BLKSZ, vtbl->blk_sz); + } if (zftape->qic113) { PUT8(entry, VTBL_DATA_SIZE, vtbl->size); entry[VTBL_CMPR] = VTBL_CMPR_UNREG; if (vtbl->use_compression) { /* use compression: */ entry[VTBL_CMPR] |= VTBL_CMPR_USED; } - entry[VTBL_EXT+EXT_ZFTAPE_QIC113] = 1; + if (zftape->ftape->format_code != fmt_big) { + entry[VTBL_EXT+EXT_ZFT_QIC113] = 1; + } } else { PUT4(entry, VTBL_DATA_SIZE, vtbl->size); entry[VTBL_K_CMPR] = VTBL_CMPR_UNREG; @@ -253,10 +275,12 @@ } } if (zftape->ftape->format_code == fmt_big) { - /* SCSI like vtbl, store the number of used - * segments as 4 byte value - */ - PUT4(entry, VTBL_SCSI_SEGS, vtbl->end_seg-vtbl->start_seg + 1); + /* QIC-113, Rev. G */ + PUT2(entry, VTBL_6_MAJOR, 113); + PUT2(entry, VTBL_6_MINOR, 7); + PUT4(entry, VTBL_6_SEGS, vtbl->end_seg-vtbl->start_seg + 1); + PUT4(entry, VTBL_6_START, vtbl->start_seg); + PUT4(entry, VTBL_6_END, vtbl->end_seg); } else { /* normal, QIC-80MC like vtbl */ @@ -278,9 +302,9 @@ TRACE_FUN(ft_t_flow); #ifdef ZFT_CMAP_HACK - if((strncmp(&buffer[VTBL_EXT+EXT_ZFTAPE_SIG], ZFTAPE_SIG, - strlen(ZFTAPE_SIG)) == 0) && - buffer[VTBL_EXT+EXT_ZFTAPE_CMAP] != 0) { + if((memcmp(&buffer[VTBL_EXT+EXT_ZFT_SIG], ZFT_SIG, ZFT_SIGLEN) == 0) + && + buffer[VTBL_EXT+EXT_ZFT_CMAP] != 0) { TRACE(ft_t_noise, "deleting cmap volume"); memmove(buffer, buffer + VTBL_SIZE, FT_SEGMENT_SIZE - VTBL_SIZE); @@ -291,16 +315,25 @@ tmp != &zft_eom_vtbl->node; tmp = tmp->next) { vtbl = list_entry(tmp, zft_volinfo, node); - /* we now fill in the values only for newly created volumes. - */ + +#if 1 + if (vtbl->offset >= FT_SEGMENT_SIZE) { + TRACE(ft_t_bug, "BUG: Offset %d too large", + vtbl->offset); + vtbl->offset = FT_SEGMENT_SIZE - VTBL_SIZE; + } +#endif + entry = &buffer[vtbl->offset]; + + /* fill in the values only for new volumes */ if (vtbl->new_volume) { create_zft_volume(zftape, entry, vtbl); vtbl->new_volume = 0; /* clear the flag */ } DUMP_VOLINFO(ft_t_noise, &entry[VTBL_DESC], vtbl); - entry += VTBL_SIZE; } + entry += VTBL_SIZE; memset(entry, 0, FT_SEGMENT_SIZE - zft_eom_vtbl->count * VTBL_SIZE); TRACE_EXIT; } @@ -309,31 +342,13 @@ */ int zft_update_volume_table(zftape_info_t *zftape, unsigned int segment) { - int result = 0; - __u8 *verify_buf = NULL; TRACE_FUN(ft_t_flow); - TRACE_CATCH(result = ftape_read_segment(zftape->ftape, - segment, - &zftape->deblock_buf, - FT_RD_SINGLE),); - if (zftape->deblock_buf == NULL) { - TRACE_ABORT(-EIO, ft_t_bug, "No deblock buffer"); - } - zft_create_volume_headers(zftape, zftape->deblock_buf); + zft_create_volume_headers(zftape, zftape->vtbl_buf); TRACE(ft_t_noise, "writing volume table segment %d", segment); - if (ftape_vmalloc(FTAPE_SEL(zftape->unit), &verify_buf, result) == 0) { - memcpy(verify_buf, zftape->deblock_buf, result); - TRACE_CATCH(zft_verify_write_segments(zftape, segment, - verify_buf, result), - ftape_vfree(FTAPE_SEL(zftape->unit), &verify_buf, - result)); - ftape_vfree(FTAPE_SEL(zftape->unit), &verify_buf, result); - } else { - TRACE_CATCH(ftape_write_segment(zftape->ftape, - segment, &zftape->deblock_buf, - FT_WR_SINGLE),); - } + TRACE_CATCH(zft_verify_write_segments(zftape, segment, + zftape->vtbl_buf, + zft_get_seg_sz(zftape, segment)),); TRACE_EXIT 0; } @@ -396,57 +411,114 @@ TRACE_EXIT; } +static void extract_segment_range(zftape_info_t *zftape, + zft_volinfo *vtbl, __u8 *entry) +{ + TRACE_FUN(ft_t_flow); + + if (zftape->ftape->format_code == fmt_big) { + /* Compatibility with a bug in ftape-4.03 and earlier + * versions. + */ + if (vtbl->zft_volume && vtbl->version == 1) { + unsigned int num_segments = GET4(entry, VTBL_6_SEGS); + vtbl->start_seg = zft_eom_vtbl->start_seg; + vtbl->end_seg = (vtbl->start_seg + num_segments - 1); + } else { + vtbl->start_seg = GET4(entry, VTBL_6_START); + vtbl->end_seg = GET4(entry, VTBL_6_END); + } + } else { + /* `normal', QIC-80 like vtbl */ + vtbl->start_seg = GET2(entry, VTBL_START); + vtbl->end_seg = GET2(entry, VTBL_END); + } + TRACE_EXIT; +} + /* extract the volume table from buffer. "buffer" must already contain * the vtbl-segment */ void zft_extract_volume_headers(zftape_info_t *zftape, __u8 *buffer) { + zft_volinfo *prev; __u8 *entry; TRACE_FUN(ft_t_flow); zft_init_vtbl(zftape); entry = buffer; #ifdef ZFT_CMAP_HACK - if ((strncmp(&entry[VTBL_EXT+EXT_ZFTAPE_SIG], ZFTAPE_SIG, - strlen(ZFTAPE_SIG)) == 0) && - entry[VTBL_EXT+EXT_ZFTAPE_CMAP] != 0) { + if ((strncmp(&entry[VTBL_EXT+EXT_ZFT_SIG], ZFT_SIG, + strlen(ZFT_SIG)) == 0) && + entry[VTBL_EXT+EXT_ZFT_CMAP] != 0) { TRACE(ft_t_noise, "ignoring cmap volume"); entry += VTBL_SIZE; } #endif - /* the end of the vtbl is indicated by an invalid signature + prev = zft_head_vtbl; + /* the end of the vtbl is indicated by an invalid signature or + * the end of the buffer. */ - while (vtbl_signature_valid(&entry[VTBL_SIG]) && - (entry - buffer) < FT_SEGMENT_SIZE) { - zft_new_vtbl_entry(zftape); - if (zftape->ftape->format_code == fmt_big) { - /* SCSI like vtbl, stores only the number of - * segments used - */ - unsigned int num_segments= GET4(entry, VTBL_SCSI_SEGS); - zft_last_vtbl->start_seg = zft_eom_vtbl->start_seg; - zft_last_vtbl->end_seg = (zft_last_vtbl->start_seg + - num_segments - 1); - } else { - /* `normal', QIC-80 like vtbl - */ - zft_last_vtbl->start_seg = GET2(entry, VTBL_START); - zft_last_vtbl->end_seg = GET2(entry, VTBL_END); + while ((entry - buffer) < FT_SEGMENT_SIZE) { + + /* force read-only in the presence of the EXVT extension */ + if (memcmp(&entry[VTBL_SIG], "EXVT", 4) == 0) { + TRACE(ft_t_warn, "EXVT signature found, force r/o"); + zftape->exvt_extension = 1; + break; } - zft_eom_vtbl->start_seg = zft_last_vtbl->end_seg + 1; - /* check if we created this volume and get the - * blk_sz - */ + /* ignore all non-VTBL entries */ + if (memcmp(&entry[VTBL_SIG], "XTBL", 4) == 0) { + TRACE(ft_t_noise, "Ignoring \"XTBL\" entry"); + entry +=VTBL_SIZE; + continue; + } + if (memcmp(&entry[VTBL_SIG], "UTID", 4) == 0) { + TRACE(ft_t_noise, "Ignoring \"UTID\" entry"); + entry +=VTBL_SIZE; + continue; + } + + /* now must be VTBL, else stop */ + if (memcmp(&entry[VTBL_SIG], "VTBL", 4) != 0) { + break; + } + + zft_new_vtbl_entry(zftape); + + /* check if we created this volume and get the blk_sz */ zft_last_vtbl->zft_volume = get_type_and_block_size(zftape, entry, zft_last_vtbl); - if (zft_last_vtbl->zft_volume == 0) { + + /* get start and end segment */ + extract_segment_range(zftape, zft_last_vtbl, entry); + + zft_eom_vtbl->start_seg = zft_last_vtbl->end_seg + 1; + + if (!zft_last_vtbl->zft_volume) { extract_alien_volume(zftape, entry, zft_last_vtbl); } else { extract_zft_volume(zftape, entry, zft_last_vtbl); } + zft_last_vtbl->offset = (unsigned int)(entry - buffer); + + /* sanity check: volumes should be in consecutive order, + * and the segments should be in range first_data_segment + 1 + * to last_data_segment + */ + if (prev->end_seg >= zft_last_vtbl->start_seg || + zft_last_vtbl->start_seg <= zft_head_vtbl->end_seg || + zft_last_vtbl->end_seg >= zft_eom_vtbl->end_seg) { + TRACE(ft_t_warn, + "WARNING: broken volume table, forcing r/o"); + zftape->vtbl_broken = 1; + } + prev = zft_last_vtbl; + DUMP_VOLINFO(ft_t_noise, &entry[VTBL_DESC], zft_last_vtbl); entry +=VTBL_SIZE; + } #if 0 /* @@ -463,6 +535,7 @@ - zft_calc_tape_pos(zftape, zft_last_vtbl->start_seg)); #endif + TRACE_EXIT; } @@ -551,6 +624,7 @@ int zft_open_volume(zftape_info_t *zftape, zft_position *pos, int blk_sz) { + unsigned int offset; TRACE_FUN(ft_t_flow); if (!zftape->qic_mode) { @@ -576,6 +650,13 @@ "Error: maxmimal number of volumes exhausted " "(maxmimum is %d)", ZFT_MAX_VOLUMES); } + + offset = zft_last_vtbl->offset + VTBL_SIZE; + TRACE(ft_t_noise, "Offset is %d\n", offset); + if (offset >= FT_SEGMENT_SIZE) { + TRACE(ft_t_bug, "BUG: offset %d > FT_SEGMENT_SIZE", offset); + TRACE_EXIT -EIO; + } zft_new_vtbl_entry(zftape); pos->volume_pos = pos->seg_byte_pos = 0; zft_last_vtbl->start_seg = pos->seg_pos; @@ -585,6 +666,8 @@ zft_last_vtbl->zft_volume = 1; zft_last_vtbl->use_compression = 0; zft_last_vtbl->qic113 = zftape->qic113; + zft_last_vtbl->offset = offset; + zft_last_vtbl->version = zftape->qic113 ? 2 : 0; /* unused */ zft_last_vtbl->new_volume = 1; zft_last_vtbl->open = 1; zftape->volume_table_changed = 1; @@ -616,13 +699,11 @@ pos->volume_pos = 0; pos->tape_pos = zft_calc_tape_pos(zftape, pos->seg_pos); zftape->just_before_eof = zft_volume_size(zftape, vtbl) == 0; -#ifdef ZFT_OBSOLETE -# if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) +#if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) /* read-only compatibility with pre-ftape-4.x compressed volumes */ if (zft_cmpr_ops) { (*zft_cmpr_ops->reset)(zftape->cmpr_handle); } -# endif #endif /* no need to keep cache */ zft_release_deblock_buffer(zftape, &zftape->deblock_buf); @@ -711,7 +792,7 @@ int zft_weof(zftape_info_t *zftape, unsigned int count, zft_position *pos) { - + unsigned int offset; TRACE_FUN(ft_t_flow); if (!count) { /* write zero EOF marks should be a real no-op */ @@ -739,6 +820,13 @@ zft_eom_vtbl->count < ZFT_MAX_VOLUMES) { TRACE(ft_t_noise, "Writing zero sized file at segment %d", pos->seg_pos); + offset = zft_last_vtbl->offset + VTBL_SIZE; + TRACE(ft_t_noise, "Offset is %d\n", offset); + if (offset >= FT_SEGMENT_SIZE) { + TRACE(ft_t_bug, + "BUG: offset %d >= FT_SEGMENT_SIZE", offset); + TRACE_EXIT -EIO; + } zft_new_vtbl_entry(zftape); zft_last_vtbl->start_seg = pos->seg_pos; zft_last_vtbl->end_seg = pos->seg_pos; @@ -746,6 +834,10 @@ zft_last_vtbl->blk_sz = zftape->blk_sz; zft_last_vtbl->zft_volume = 1; zft_last_vtbl->use_compression = 0; + zft_last_vtbl->qic113 = zftape->qic113; + zft_last_vtbl->offset = offset; + zft_last_vtbl->version = zftape->qic113 ? 2 : 0; + zft_last_vtbl->new_volume = 1; pos->tape_pos += zft_get_seg_sz(zftape, pos->seg_pos); zft_eom_vtbl->start_seg = ++ pos->seg_pos; count --; @@ -757,12 +849,13 @@ zftape->resid = count; TRACE(ft_t_noise,"Number of marks NOT written: %d", zftape->resid); if (zft_eom_vtbl->count == ZFT_MAX_VOLUMES) { - TRACE_ABORT(-EINVAL, ft_t_warn, - "maximum allowed number of files " - "exhausted: %d", ZFT_MAX_VOLUMES); + TRACE(ft_t_warn, + "maximum allowed number of files exhausted: %d", + ZFT_MAX_VOLUMES); + TRACE_EXIT -EINVAL; } else { - TRACE_ABORT(-ENOSPC, - ft_t_noise, "reached end of tape"); + TRACE(ft_t_noise, "reached end of tape"); + TRACE_EXIT -ENOSPC; } } TRACE_EXIT 0; @@ -848,7 +941,7 @@ { TRACE_FUN(ft_t_flow); - TRACE(ft_t_any, "called with seg_pos %d",seg_pos); + TRACE(ft_t_any, "called with seg_pos %d", seg_pos); if (!zftape->qic_mode) { if (seg_pos > zftape->ftape->last_data_segment) { TRACE_EXIT &zftape->eot_vtbl; @@ -859,6 +952,7 @@ if (seg_pos < zft_first_vtbl->start_seg) { TRACE_EXIT (zftape->cur_vtbl = zft_first_vtbl); } + TRACE(ft_t_noise, "cur_vtbl: %p", zftape->cur_vtbl); while (seg_pos > zftape->cur_vtbl->end_seg) { zftape->cur_vtbl = list_entry(zftape->cur_vtbl->node.next, zft_volinfo, node); TRACE(ft_t_noise, "%d - %d", zftape->cur_vtbl->start_seg, zftape->cur_vtbl->end_seg); @@ -884,13 +978,11 @@ pos->tape_pos += zft_get_seg_sz(zftape, pos->seg_pos++) - pos->seg_byte_pos; pos->seg_byte_pos = 0; pos->volume_pos = 0; -#ifdef ZFT_OBSOLETE -# if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) +#if defined(CONFIG_ZFT_COMPRESSOR) || defined(CONFIG_ZFT_COMPRESSOR_MODULE) /* read-only compatibility with pre-ftape-4.x compressed volumes */ if (zft_cmpr_ops) { (*zft_cmpr_ops->reset)(zftape->cmpr_handle); } -# endif #endif zftape->just_before_eof = 0; /* no need to cache it anymore */ diff -u --recursive --new-file ftape-4.03/ftape/zftape/zftape-vtbl.h ftape-4.04/ftape/zftape/zftape-vtbl.h --- ftape-4.03/ftape/zftape/zftape-vtbl.h Fri Mar 12 12:35:09 1999 +++ ftape-4.04/ftape/zftape/zftape-vtbl.h Fri Jul 21 11:32:50 2000 @@ -21,8 +21,8 @@ * * $RCSfile: zftape-vtbl.h,v $ - * $Revision: 1.12 $ - * $Date: 1999/03/12 11:35:09 $ + * $Revision: 1.16 $ + * $Date: 2000/07/21 09:32:50 $ * * This file defines a volume table as defined in the QIC-80 * development standards. @@ -52,10 +52,10 @@ #define VTBL_FL_RESERVED_7 (1<<7) #define VTBL_M_NO 57 #define VTBL_EXT 58 -#define EXT_ZFTAPE_SIG 0 -#define EXT_ZFTAPE_BLKSZ 10 -#define EXT_ZFTAPE_CMAP 12 -#define EXT_ZFTAPE_QIC113 13 +#define EXT_ZFT_SIG 0 +#define EXT_ZFT_BLKSZ 10 +#define EXT_ZFT_CMAP 12 +#define EXT_ZFT_QIC113 13 #define VTBL_PWD 84 #define VTBL_DIR_SIZE 92 #define VTBL_DATA_SIZE 96 @@ -75,9 +75,21 @@ /* the next is used by QIC-3020 tapes with format code 6 (>2^16 * segments) It is specified in QIC-113, Rev. G, Section 5 (SCSI * volume table). The difference is simply, that we only store the - * number of segments used, not the starting segment. + * number of segments used, not the starting segment. The starting + * and ending segment is stored at offset 76 and 80. The vendor + * extension data starts at 62. + * */ -#define VTBL_SCSI_SEGS 4 /* is a 4 byte value */ +#define VTBL_6_SEGS 4 /* is a 4 byte value */ +#define VTBL_6_MAJOR 58 /* set to 113 */ +#define VTBL_6_MINOR 60 /* Revision G, i.e. 7 */ +#define VTBL_6_EXT 62 /* 14 bytes */ +#define EXT_6_ZFT_SIG 0 /* signature, 3 bytes */ +#define EXT_6_ZFT_SIGV 3 /* version, 1 byte */ +#define EXT_6_ZFT_BLKSZ 4 /* block size, 2 bytes */ +#define EXT_6_ZFT_RES 6 /* reserved, 8 bytes */ +#define VTBL_6_START 76 +#define VTBL_6_END 80 /* one vtbl is 128 bytes, that results in a maximum number of * 29*1024/128 = 232 volumes. @@ -86,7 +98,11 @@ #define VTBL_ID "VTBL" #define VTBL_IDS { VTBL_ID, "XTBL", "UTID", "EXVT" } /* other valid ids */ #define ZFT_VOL_NAME "zftape volume" /* volume label used by me */ -#define ZFTAPE_SIG "LINUX ZFT" +#define ZFT_SIG "LINUX ZFT" /* QIC-80/3010/3020 vendor extension */ +#define ZFT_SIGLEN 10 +#define ZFT_SIG2 "ZFT" /* QIC-113 vendor extension */ +#define ZFT_SIGLEN2 3 + /* global variables */ @@ -99,6 +115,8 @@ __s64 size; /* size after compression */ __s64 rawsize; /* tape space used */ unsigned int blk_sz; /* block size for this volume */ + unsigned int version; /* corresponds to ZFT_SIG/_SIG2 */ + unsigned int offset; /* offset in vtbl segment */ unsigned int zft_volume :1; /* zftape created this volume */ unsigned int use_compression:1; /* compressed volume (obsolete) */ unsigned int qic113 :1; /* layout of compressed block @@ -135,11 +153,14 @@ KERN_INFO "size : " LL_X "\n" \ KERN_INFO "rawsize : " LL_X "\n" \ KERN_INFO "block size : %d\n" \ + KERN_INFO "version : %d\n" \ + KERN_INFO "offset : %d\n" \ KERN_INFO "compression : %d\n" \ KERN_INFO "zftape volume: %d\n" \ KERN_INFO "QIC-113 conf.: %d", \ (info)->count, tmp, (info)->start_seg, (info)->end_seg, \ LL((info)->size), LL((info)->rawsize), (info)->blk_sz, \ + (info)->version, (info)->offset, \ (info)->use_compression != 0, (info)->zft_volume != 0, \ (info)->qic113 != 0); \ } diff -u --recursive --new-file ftape-4.03/ftape/zftape/zftape-write.c ftape-4.04/ftape/zftape/zftape-write.c --- ftape-4.03/ftape/zftape/zftape-write.c Fri Dec 18 23:39:05 1998 +++ ftape-4.04/ftape/zftape/zftape-write.c Thu Jul 20 13:17:16 2000 @@ -17,8 +17,8 @@ * * $RCSfile: zftape-write.c,v $ - * $Revision: 1.20 $ - * $Date: 1998/12/18 22:39:05 $ + * $Revision: 1.21 $ + * $Date: 2000/07/20 11:17:16 $ * * This file contains the writing code * for the QIC-117 floppy-tape driver for Linux. @@ -46,6 +46,7 @@ #include "zftape-rw.h" #include "zftape-vtbl.h" #include "zftape-buffers.h" +#include "zftape-inline.h" /* Global vars. */ @@ -111,7 +112,7 @@ * file access mode. But we also want to update when soft * write protection is enabled (O_RDONLY) */ - if (ftape->write_protected || zftape->old_ftape) { + if (ftape->write_protected || zft_vtbl_soft_ro(zftape)) { TRACE_ABORT(0, ft_t_noise, "Tape set read-only: no update"); } if (!zftape->header_read) { diff -u --recursive --new-file ftape-4.03/ftape/zftape/zftape_syms.c ftape-4.04/ftape/zftape/zftape_syms.c --- ftape-4.03/ftape/zftape/zftape_syms.c Tue Aug 31 11:52:51 1999 +++ ftape-4.04/ftape/zftape/zftape_syms.c Thu Jul 6 16:42:21 2000 @@ -17,8 +17,8 @@ * * $RCSfile: zftape_syms.c,v $ - * $Revision: 1.11 $ - * $Date: 1999/08/31 09:52:51 $ + * $Revision: 1.12 $ + * $Date: 2000/07/06 14:42:21 $ * * This file contains the the symbols that the zftape frontend to * the ftape floppy tape driver exports @@ -45,12 +45,10 @@ struct symbol_table zft_symbol_table = { #include #endif -#ifdef ZFT_OBSOLETE -# ifdef CONFIG_ZFT_COMPRESSOR_MODULE +#ifdef CONFIG_ZFT_COMPRESSOR_MODULE /* zftape-init.c */ FT_KSYM(zft_cmpr_register) FT_KSYM(zft_cmpr_unregister) -# endif #endif /* zftape-read.c */ FT_KSYM(zft_fetch_segment) diff -u --recursive --new-file ftape-4.03/include/linux/ftape.h ftape-4.04/include/linux/ftape.h --- ftape-4.03/include/linux/ftape.h Fri Jun 30 12:58:29 2000 +++ ftape-4.04/include/linux/ftape.h Sun Jul 23 22:32:35 2000 @@ -21,15 +21,15 @@ * * $RCSfile: ftape.h,v $ - * $Revision: 1.58 $ - * $Date: 2000/06/30 10:58:29 $ + * $Revision: 1.59 $ + * $Date: 2000/07/23 20:32:35 $ * * This file contains global definitions, typedefs and macro's * for the QIC-40/80/3010/3020 floppy-tape driver for Linux. * */ -#define FTAPE_VERSION "ftape v4.03 06/30/2000" +#define FTAPE_VERSION "ftape v4.04 07/23/2000" #ifdef __KERNEL__ #include diff -u --recursive --new-file ftape-4.03/include/linux/zftape.h ftape-4.04/include/linux/zftape.h --- ftape-4.03/include/linux/zftape.h Tue Aug 31 11:54:07 1999 +++ ftape-4.04/include/linux/zftape.h Thu Jul 6 16:42:27 2000 @@ -20,8 +20,8 @@ * * $RCSfile: zftape.h,v $ - * $Revision: 1.17 $ - * $Date: 1999/08/31 09:54:07 $ + * $Revision: 1.18 $ + * $Date: 2000/07/06 14:42:27 $ * * Special ioctl and other global info for the zftape VFS * interface for the QIC-40/80/3010/3020 floppy-tape driver for @@ -36,7 +36,7 @@ /* Bits of the minor device number that control the operation mode */ -#ifndef ZFT_OBSOLETE +#ifndef CONFIG_ZFT_OBSOLETE # define ZFT_MINOR_OP_MASK 0 #else @@ -61,7 +61,7 @@ unsigned int mt_blksz; }; # define MTIOC_ZFTAPE_GETBLKSZ _IOR('m', 104, struct mtblksz) -#endif /* ZFT_OBSOLETE */ +#endif /* CONFIG_ZFT_OBSOLETE */ /* valid bits of minor device number */ #define ZFT_MINOR_MASK (FTAPE_SEL_MASK | \ diff -u --recursive --new-file ftape-4.03/modules/.cvsfun ftape-4.04/modules/.cvsfun --- ftape-4.03/modules/.cvsfun Thu Jan 1 01:00:00 1970 +++ ftape-4.04/modules/.cvsfun Sat Dec 13 15:09:44 1997 @@ -0,0 +1 @@ +This is here so that CVS will create the "modules" sub-directory on checkout and export! diff -u --recursive --new-file ftape-4.03/scripts/kernel-inclusion/Documentation/00-INDEX ftape-4.04/scripts/kernel-inclusion/Documentation/00-INDEX --- ftape-4.03/scripts/kernel-inclusion/Documentation/00-INDEX Mon Jun 26 03:15:41 2000 +++ ftape-4.04/scripts/kernel-inclusion/Documentation/00-INDEX Fri Jul 7 13:59:05 2000 @@ -6,7 +6,9 @@ 00-INDEX - - this file + - this file. +RELEASE-NOTES + - Revision history. ftape.txt - general notes and configuration options. diff -u --recursive --new-file ftape-4.03/scripts/kernel-inclusion/gokernel.sh ftape-4.04/scripts/kernel-inclusion/gokernel.sh --- ftape-4.03/scripts/kernel-inclusion/gokernel.sh Thu Jun 29 19:27:02 2000 +++ ftape-4.04/scripts/kernel-inclusion/gokernel.sh Fri Jul 7 13:58:53 2000 @@ -54,6 +54,7 @@ mkdir $LINUX_LOCATION/Documentation/ftape cp -aR $PATCH_SOURCES/Documentation/* $LINUX_LOCATION/Documentation/ftape/ rm -rf $LINUX_LOCATION/Documentation/ftape/CVS/ +cp $FTAPE_SOURCES/RELEASE-NOTES $LINUX_LOCATION/Documentation/ftape/ # # patch Documentation/Configure.help # @@ -84,6 +85,7 @@ done cp $FTAPE_SOURCES/scripts/kernel-inclusion/v$MAJOR.$MINOR/Config.in \ $LINUX_LOCATION/drivers/char/ftape/Config.in +find $LINUX_LOCATION/drivers/char/ftape/ -name CVS -o -name '.cvsignore' -o -name '.*.d' -o -name '*.o' -o -name '.#*' -exec rm -rf '{}' ';' # # # diff -u --recursive --new-file ftape-4.03/scripts/kernel-inclusion/v2.4/Config.in ftape-4.04/scripts/kernel-inclusion/v2.4/Config.in --- ftape-4.03/scripts/kernel-inclusion/v2.4/Config.in Thu Jun 29 19:27:17 2000 +++ ftape-4.04/scripts/kernel-inclusion/v2.4/Config.in Thu Jul 6 16:57:40 2000 @@ -3,15 +3,17 @@ # if [ "$CONFIG_ZFTAPE" != "y" -a "$CONFIG_ZFTAPE" != "m" ]; then define_bool CONFIG_ZFTAPE m - comment 'The zftape module will also be build as module' fi dep_tristate 'Zftape, the VFS interface' CONFIG_ZFTAPE $CONFIG_FTAPE y -bool 'Enable read-back of ftape-3.x compressed archives' CONFIG_FT_UNCMPR n -if [ "$CONFIG_FT_UNCMPR" = "y" ]; then - comment 'The de-compressor will be built as a module only!' - define_bool CONFIG_ZFT_COMPRESSOR m -else - define_bool CONFIG_ZFT_COMPRESSOR n +bool 'Enable obsolete backwards compatibility stuff' CONFIG_ZFT_OBSOLETE n +if [ "$CONFIG_ZFT_OBSOLETE" = "y" ]; then + bool 'Enable read-back of ftape-3.x compressed archives' CONFIG_FT_UNCMPR n + if [ "$CONFIG_FT_UNCMPR" = "y" -a "$CONFIG_ZFT_OBSOLETE" = "y" ]; then + comment 'The de-compressor will be built as a module only!' + define_bool CONFIG_ZFT_COMPRESSOR m + else + define_bool CONFIG_ZFT_COMPRESSOR n + fi fi comment 'General ftape options' int 'Default block size' CONFIG_ZFT_DFLT_BLK_SZ 10240 diff -u --recursive --new-file ftape-4.03/scripts/kernel-inclusion/v2.4/Configure.help.ftape ftape-4.04/scripts/kernel-inclusion/v2.4/Configure.help.ftape --- ftape-4.03/scripts/kernel-inclusion/v2.4/Configure.help.ftape Thu Jun 29 23:10:17 2000 +++ ftape-4.04/scripts/kernel-inclusion/v2.4/Configure.help.ftape Mon Jul 10 23:27:39 2000 @@ -62,6 +62,20 @@ between tape archives) but pre-3.xx versions of ftape will lack file mark support when reading archives produced by zftape. +Obsolete backwards compatibility stuff +CONFIG_ZFT_OBSOLETE + If this is defined, then + a) support for /dev/rawft is added, i.e. the minor device bit 5 + toggles raw mode. + b) the MTIOC_ZFTAPE_GETBLKSZ is supported. + c) support for decompression of old ftape-3.x archives is + added. Decompression is supported when bit 4 of the minor device + number is set (i.e. /dev/zqft). + When it is not defined: no decompression, no old ioctls, raw-mode + must be entered via new MTIOCFTMODE ioctl. If you have archives + created by old ftape versions say `y'. Otherwise you can say + `n'. If unsure say `y'. + Read-only compatibility with ftape-3.x compressed archives CONFIG_FT_UNCMPR Enable de-compression of ftape-3.x compressed archives. If you @@ -1325,11 +1339,11 @@ speed. If unsure, leave this disabled, i.e. leave it at 4000 bits/sec. - LocalWords: QIC TR GB CONFIG FTAPE Iomega Exabyte Trakker Iomega's - LocalWords: ftape FC paride Linux CMS FDC IRQ PCI README txt HOWTO - LocalWords: http www rwth VFS aachen claus ZFTAPE zftape ZFT DFLT + LocalWords: QIC TR GB CONFIG FTAPE Iomega Exabyte Trakker Iomega's MTIOC + LocalWords: ftape FC paride Linux CMS FDC IRQ PCI README txt HOWTO GETBLKSZ + LocalWords: http www rwth VFS aachen claus ZFTAPE zftape ZFT DFLT devfs LocalWords: BLK SZ MTSETBLK mt dev MTIOCTOP qft setblk BLKSZ tar's LocalWords: afio's NR setdrvbuffer kb FS EZ NUMBUFFERS Procfs FDCs - LocalWords: MBit isapnptools ISA PnP roestock co uk netscape + LocalWords: MBit isapnptools ISA PnP roestock co uk netscape MTIOCFTMODE LocalWords: parport BPCK INT STD HW unprecise UNCMPR zft zqft LocalWords: LocalWords