zftape-rw.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. #ifndef _ZFTAPE_RW_H
  2. #define _ZFTAPE_RW_H
  3. /*
  4.  * Copyright (C) 1996, 1997 Claus-Justus Heine.
  5.  This program is free software; you can redistribute it and/or modify
  6.  it under the terms of the GNU General Public License as published by
  7.  the Free Software Foundation; either version 2, or (at your option)
  8.  any later version.
  9.  This program is distributed in the hope that it will be useful,
  10.  but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  GNU General Public License for more details.
  13.  You should have received a copy of the GNU General Public License
  14.  along with this program; see the file COPYING.  If not, write to
  15.  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  16.  *
  17.  * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-rw.h,v $
  18.  * $Revision: 1.2 $
  19.  * $Date: 1997/10/05 19:19:09 $
  20.  *
  21.  *      This file contains the definitions for the read and write
  22.  *      functions for the QIC-117 floppy-tape driver for Linux.
  23.  *
  24.  */
  25. #include <linux/config.h> /* for CONFIG_ZFT_DFLT_BLK_SZ */
  26. #include "../zftape/zftape-buffers.h"
  27. #define SEGMENTS_PER_TAPE  (ft_segments_per_track * ft_tracks_per_tape)
  28. /*  QIC-113 Rev. G says that `a maximum of 63488 raw bytes may be
  29.  *  compressed into a single frame'.
  30.  *  Maybe we should stick to 32kb to make it more `beautiful'
  31.  */
  32. #define ZFT_MAX_BLK_SZ           (62*1024) /* bytes */
  33. #if !defined(CONFIG_ZFT_DFLT_BLK_SZ)
  34. # define CONFIG_ZFT_DFLT_BLK_SZ   (10*1024) /* bytes, default of gnu tar */
  35. #elif CONFIG_ZFT_DFLT_BLK_SZ == 0
  36. # undef  CONFIG_ZFT_DFLT_BLK_SZ
  37. # define CONFIG_ZFT_DFLT_BLK_SZ 1
  38. #elif (CONFIG_ZFT_DFLT_BLK_SZ % 1024) != 0
  39. # error CONFIG_ZFT_DFLT_BLK_SZ must be 1 or a multiple of 1024
  40. #endif
  41. /* The *optional* compression routines need some overhead per tape
  42.  *  block for their purposes. Instead of asking the actual compression
  43.  *  implementation how much it needs, we restrict this overhead to be
  44.  *  maximal of ZFT_CMPT_OVERHEAD size. We need this for EOT
  45.  *  conditions. The tape is assumed to be logical at EOT when the
  46.  *  distance from the physical EOT is less than 
  47.  *  one tape block + ZFT_CMPR_OVERHEAD 
  48.  */
  49. #define ZFT_CMPR_OVERHEAD 16        /* bytes */
  50. typedef enum
  51. zft_idle = 0,
  52. zft_reading,
  53. zft_writing,
  54. } zft_status_enum;
  55. typedef struct               /*  all values measured in bytes */
  56. {
  57. int   seg_pos;       /*  segment currently positioned at */
  58. int   seg_byte_pos;  /*  offset in current segment */ 
  59. __s64 tape_pos;      /*  real offset from BOT */
  60. __s64 volume_pos;    /*  pos. in uncompressed data stream in
  61.       *  current volume 
  62.       */
  63. } zft_position; 
  64. extern zft_position zft_pos;
  65. extern __u8 *zft_deblock_buf;
  66. extern __u8 *zft_hseg_buf;
  67. extern int zft_deblock_segment;
  68. extern zft_status_enum zft_io_state;
  69. extern int zft_header_changed;
  70. extern int zft_bad_sector_map_changed;
  71. extern int zft_qic113; /* conform to old specs. and old zftape */
  72. extern int zft_use_compression;
  73. extern unsigned int zft_blk_sz;
  74. extern __s64 zft_capacity;
  75. extern unsigned int zft_written_segments;
  76. extern int zft_label_changed;
  77. /*  zftape-rw.c exported functions
  78.  */
  79. extern unsigned int zft_get_seg_sz(unsigned int segment);
  80. extern void  zft_set_flags(unsigned int minor_unit);
  81. extern int   zft_calc_seg_byte_coord(int *seg_byte_pos, __s64 tape_pos);
  82. extern __s64 zft_calc_tape_pos(int segment);
  83. extern __s64 zft_get_capacity(void);
  84. extern void  zft_update_label(__u8 *buffer);
  85. extern int   zft_erase(void);
  86. extern int   zft_verify_write_segments(unsigned int segment, 
  87.        __u8 *data, size_t size, __u8 *buffer);
  88. extern unsigned int zft_get_time(void);
  89. #endif /* _ZFTAPE_RW_H */