* errno.cc (errmap): Map ERROR_SHARING_VIOLATION to EBUSY,
ERROR_EOM_OVERFLOW and ERROR_NO_DATA_DETECTED to EIO. Add mappings for ERROR_NO_MEDIA_IN_DRIVE, ERROR_DEVICE_REQUIRES_CLEANING and ERROR_DEVICE_DOOR_OPEN. * fhandler.h (class fhandler_dev_raw): Drop varblkop member. (fhandler_dev_raw::is_eom): De-virtualize. (fhandler_dev_raw::is_eof): Ditto. (class fhandler_dev_tape): Drop lasterr and dp member. Add mt_mtx member. Drop all private methods formerly used by ioctl. (fhandler_dev_tape::is_rewind_device): Use get_minor for clarity. (fhandler_dev_tape::driveno): New method. (fhandler_dev_tape::drive_init): New method. (fhandler_dev_tape::clear): Remove method. (fhandler_dev_tape::is_eom): Ditto. (fhandler_dev_tape::is_eof): Ditto. (fhandler_dev_tape::write_file): Ditto. (fhandler_dev_tape::read_file): Ditto. (fhandler_dev_tape::_lock): New method. (fhandler_dev_tape::unlock): New method. (fhandler_dev_tape::raw_read): New method. (fhandler_dev_tape::raw_write): New method. * fhandler_raw.cc (fhandler_dev_raw::is_eom): New method. (fhandler_dev_raw::is_eof): New method. (fhandler_dev_raw::open): Allow setting write through option by using the O_TEXT flag as ... flag. (fhandler_dev_raw::writebuf): Remove usage of varblkop and other tape specific code. (fhandler_dev_raw::raw_read): Ditto. (fhandler_dev_raw::dup): Ditto. * fhandler_tape.cc: Rewrite tape operations entirely. Implement new tape driver classes mtinfo, mtinfo_drive and mtinfo_part. Reduce fhandler_dev_tape methods to mostly just calling appropriate mtinfo_drive methods. (mtinfo_init): New function adding the mtinfo shared memory area. * mtinfo.h: New file, containing the definition of the new tape driver classes. * shared.cc: Include mtinfo.h. (offsets): Add entry for mtinfo shared memory area. (memory_init): Call mtinfo_init. * shared_info.h (shared_locations): Add SH_MTINFO shared location. * include/cygwin/mtio.h: Change and add various comments. Add GMT_xxx macros for new generic flags. Add MT_ST_xxx bitfield definitions for MTSETDRVBUFFER ioctl. * include/cygwin/version.h: Bump API minor version number.
This commit is contained in:
parent
359b6e4c49
commit
dee563095d
|
@ -1,3 +1,50 @@
|
|||
2004-03-26 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* errno.cc (errmap): Map ERROR_SHARING_VIOLATION to EBUSY,
|
||||
ERROR_EOM_OVERFLOW and ERROR_NO_DATA_DETECTED to EIO. Add mappings
|
||||
for ERROR_NO_MEDIA_IN_DRIVE, ERROR_DEVICE_REQUIRES_CLEANING and
|
||||
ERROR_DEVICE_DOOR_OPEN.
|
||||
* fhandler.h (class fhandler_dev_raw): Drop varblkop member.
|
||||
(fhandler_dev_raw::is_eom): De-virtualize.
|
||||
(fhandler_dev_raw::is_eof): Ditto.
|
||||
(class fhandler_dev_tape): Drop lasterr and dp member. Add mt_mtx
|
||||
member. Drop all private methods formerly used by ioctl.
|
||||
(fhandler_dev_tape::is_rewind_device): Use get_minor for clarity.
|
||||
(fhandler_dev_tape::driveno): New method.
|
||||
(fhandler_dev_tape::drive_init): New method.
|
||||
(fhandler_dev_tape::clear): Remove method.
|
||||
(fhandler_dev_tape::is_eom): Ditto.
|
||||
(fhandler_dev_tape::is_eof): Ditto.
|
||||
(fhandler_dev_tape::write_file): Ditto.
|
||||
(fhandler_dev_tape::read_file): Ditto.
|
||||
(fhandler_dev_tape::_lock): New method.
|
||||
(fhandler_dev_tape::unlock): New method.
|
||||
(fhandler_dev_tape::raw_read): New method.
|
||||
(fhandler_dev_tape::raw_write): New method.
|
||||
* fhandler_raw.cc (fhandler_dev_raw::is_eom): New method.
|
||||
(fhandler_dev_raw::is_eof): New method.
|
||||
(fhandler_dev_raw::open): Allow setting write through option by
|
||||
using the O_TEXT flag as ... flag.
|
||||
(fhandler_dev_raw::writebuf): Remove usage of varblkop and other
|
||||
tape specific code.
|
||||
(fhandler_dev_raw::raw_read): Ditto.
|
||||
(fhandler_dev_raw::dup): Ditto.
|
||||
* fhandler_tape.cc: Rewrite tape operations entirely. Implement
|
||||
new tape driver classes mtinfo, mtinfo_drive and mtinfo_part.
|
||||
Reduce fhandler_dev_tape methods to mostly just calling appropriate
|
||||
mtinfo_drive methods.
|
||||
(mtinfo_init): New function adding the mtinfo shared memory area.
|
||||
* mtinfo.h: New file, containing the definition of the new tape
|
||||
driver classes.
|
||||
* shared.cc: Include mtinfo.h.
|
||||
(offsets): Add entry for mtinfo shared memory area.
|
||||
(memory_init): Call mtinfo_init.
|
||||
* shared_info.h (shared_locations): Add SH_MTINFO shared location.
|
||||
* include/cygwin/mtio.h: Change and add various comments. Add GMT_xxx
|
||||
macros for new generic flags. Add MT_ST_xxx bitfield definitions
|
||||
for MTSETDRVBUFFER ioctl.
|
||||
* include/cygwin/version.h: Bump API minor version number.
|
||||
|
||||
2004-03-26 Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
* path.cc (path_conv::check): Use 'strchr' rather than 'strrchr' to
|
||||
|
|
|
@ -48,7 +48,7 @@ static NO_COPY struct
|
|||
X (NO_MORE_FILES, ENMFILE),
|
||||
X (WRITE_PROTECT, EROFS),
|
||||
X (BAD_UNIT, ENODEV),
|
||||
X (SHARING_VIOLATION, EACCES),
|
||||
X (SHARING_VIOLATION, EBUSY),
|
||||
X (LOCK_VIOLATION, EACCES),
|
||||
X (SHARING_BUFFER_EXCEEDED, ENOLCK),
|
||||
X (HANDLE_EOF, ENODATA),
|
||||
|
@ -101,10 +101,10 @@ static NO_COPY struct
|
|||
X (IO_DEVICE, EIO),
|
||||
X (NOT_OWNER, EPERM),
|
||||
X (END_OF_MEDIA, ENOSPC),
|
||||
X (EOM_OVERFLOW, ENOSPC),
|
||||
X (EOM_OVERFLOW, EIO),
|
||||
X (BEGINNING_OF_MEDIA, EIO),
|
||||
X (SETMARK_DETECTED, EIO),
|
||||
X (NO_DATA_DETECTED, ENOSPC),
|
||||
X (NO_DATA_DETECTED, EIO),
|
||||
X (POSSIBLE_DEADLOCK, EDEADLOCK),
|
||||
X (CRC, EIO),
|
||||
X (NEGATIVE_SEEK, EINVAL),
|
||||
|
@ -116,6 +116,9 @@ static NO_COPY struct
|
|||
X (INVALID_BLOCK_LENGTH, EIO),
|
||||
X (BUS_RESET, EIO),
|
||||
X (FILEMARK_DETECTED, EIO),
|
||||
X (NO_MEDIA_IN_DRIVE, ENOMEDIUM),
|
||||
X (DEVICE_REQUIRES_CLEANING, EIO),
|
||||
X (DEVICE_DOOR_OPEN, EIO),
|
||||
{ 0, NULL, 0}
|
||||
};
|
||||
|
||||
|
|
|
@ -509,7 +509,6 @@ class fhandler_dev_raw: public fhandler_base
|
|||
int lastblk_to_read : 1;
|
||||
int is_writing : 1;
|
||||
int has_written : 1;
|
||||
int varblkop : 1;
|
||||
|
||||
virtual void clear (void);
|
||||
virtual BOOL write_file (const void *buf, DWORD to_write,
|
||||
|
@ -518,9 +517,9 @@ class fhandler_dev_raw: public fhandler_base
|
|||
virtual int writebuf (void);
|
||||
|
||||
/* returns not null, if `win_error' determines an end of media condition */
|
||||
virtual int is_eom(int win_error) = 0;
|
||||
virtual int is_eom(int win_error);
|
||||
/* returns not null, if `win_error' determines an end of file condition */
|
||||
virtual int is_eof(int win_error) = 0;
|
||||
virtual int is_eof(int win_error);
|
||||
|
||||
fhandler_dev_raw ();
|
||||
|
||||
|
@ -569,18 +568,14 @@ class fhandler_dev_floppy: public fhandler_dev_raw
|
|||
|
||||
class fhandler_dev_tape: public fhandler_dev_raw
|
||||
{
|
||||
int lasterr;
|
||||
TAPE_GET_DRIVE_PARAMETERS dp;
|
||||
HANDLE mt_mtx;
|
||||
|
||||
bool is_rewind_device () { return get_unit () < 128; }
|
||||
bool is_rewind_device () { return get_minor () < 128; }
|
||||
unsigned int driveno () { return (unsigned int) get_minor () & 0x7f; }
|
||||
void drive_init (void);
|
||||
|
||||
protected:
|
||||
virtual void clear (void);
|
||||
virtual int is_eom (int win_error);
|
||||
virtual int is_eof (int win_error);
|
||||
virtual BOOL write_file (const void *buf, DWORD to_write,
|
||||
DWORD *written, int *err);
|
||||
virtual BOOL read_file (void *buf, DWORD to_read, DWORD *read, int *err);
|
||||
inline bool _lock ();
|
||||
inline int unlock (int ret = 0);
|
||||
|
||||
public:
|
||||
fhandler_dev_tape ();
|
||||
|
@ -588,33 +583,15 @@ class fhandler_dev_tape: public fhandler_dev_raw
|
|||
virtual int open (int flags, mode_t mode = 0);
|
||||
virtual int close (void);
|
||||
|
||||
void raw_read (void *ptr, size_t& ulen);
|
||||
int raw_write (const void *ptr, size_t ulen);
|
||||
|
||||
virtual _off64_t lseek (_off64_t offset, int whence);
|
||||
|
||||
virtual int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
|
||||
|
||||
virtual int dup (fhandler_base *child);
|
||||
|
||||
virtual int ioctl (unsigned int cmd, void *buf);
|
||||
|
||||
private:
|
||||
inline bool tape_get_feature (DWORD parm)
|
||||
{
|
||||
return ((parm & TAPE_DRIVE_HIGH_FEATURES)
|
||||
? ((dp.FeaturesHigh & parm) != 0)
|
||||
: ((dp.FeaturesLow & parm) != 0));
|
||||
}
|
||||
int tape_error (const char *txt);
|
||||
int tape_write_marks (int marktype, DWORD len);
|
||||
int tape_get_pos (unsigned long *block, unsigned long *partition = NULL);
|
||||
int tape_set_pos (int mode, long count, bool sfm_func = false);
|
||||
int _tape_set_pos (int mode, long count, int partition = 0);
|
||||
int tape_erase (int mode);
|
||||
int tape_prepare (int action);
|
||||
int tape_set_blocksize (long count);
|
||||
int tape_status (struct mtget *get);
|
||||
int tape_compression (long count);
|
||||
int tape_partition (long count);
|
||||
int tape_set_partition (long count);
|
||||
};
|
||||
|
||||
/* Standard disk file */
|
||||
|
|
|
@ -37,9 +37,21 @@ fhandler_dev_raw::clear (void)
|
|||
eom_detected = 0;
|
||||
eof_detected = 0;
|
||||
lastblk_to_read = 0;
|
||||
varblkop = 0;
|
||||
}
|
||||
|
||||
int
|
||||
fhandler_dev_raw::is_eom (int win_error)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
fhandler_dev_raw::is_eof (int)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Wrapper functions to allow fhandler_dev_tape to detect and care for
|
||||
media changes and bus resets. */
|
||||
|
||||
|
@ -76,16 +88,13 @@ fhandler_dev_raw::writebuf (void)
|
|||
DWORD written;
|
||||
int ret = 0;
|
||||
|
||||
if (!varblkop && is_writing && devbuf && devbufend)
|
||||
if (is_writing && devbuf && devbufend)
|
||||
{
|
||||
DWORD to_write;
|
||||
int ret = 0;
|
||||
|
||||
memset (devbuf + devbufend, 0, devbufsiz - devbufend);
|
||||
if (get_major () != DEV_TAPE_MAJOR)
|
||||
to_write = ((devbufend - 1) / 512 + 1) * 512;
|
||||
else
|
||||
to_write = devbufsiz;
|
||||
if (!write_file (devbuf, to_write, &written, &ret)
|
||||
&& is_eom (ret))
|
||||
eom_detected = 1;
|
||||
|
@ -141,7 +150,7 @@ fhandler_dev_raw::open (int flags, mode_t)
|
|||
}
|
||||
|
||||
/* Check for illegal flags. */
|
||||
if (flags & (O_APPEND | O_EXCL))
|
||||
if (get_major () != DEV_TAPE_MAJOR && (flags & (O_APPEND | O_EXCL)))
|
||||
{
|
||||
set_errno (EINVAL);
|
||||
return 0;
|
||||
|
@ -162,11 +171,16 @@ fhandler_dev_raw::open (int flags, mode_t)
|
|||
WCHAR devname[CYG_MAX_PATH + 1];
|
||||
str2buf2uni (dev, devname, get_win32_name ());
|
||||
OBJECT_ATTRIBUTES attr;
|
||||
ULONG options = FILE_SYNCHRONOUS_IO_NONALERT;
|
||||
/* The O_TEXT flag is used to indicate write-through on tape devices */
|
||||
if (get_major () == DEV_TAPE_MAJOR && (flags & O_TEXT))
|
||||
options |= FILE_WRITE_THROUGH;
|
||||
flags &= ~O_TEXT;
|
||||
InitializeObjectAttributes (&attr, &dev, OBJ_CASE_INSENSITIVE, NULL, NULL);
|
||||
|
||||
HANDLE h;
|
||||
IO_STATUS_BLOCK io;
|
||||
NTSTATUS status = NtOpenFile (&h, access, &attr, &io, wincap.shared (),
|
||||
NTSTATUS status = NtOpenFile (&h, access, &attr, &io, 0 /* excl. access */,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||
if (!NT_SUCCESS (status))
|
||||
{
|
||||
|
@ -234,7 +248,8 @@ fhandler_dev_raw::raw_read (void *ptr, size_t& ulen)
|
|||
{
|
||||
bytes_to_read = min (len, devbufend - devbufstart);
|
||||
debug_printf ("read %d bytes from buffer (rest %d)",
|
||||
bytes_to_read, devbufend - devbufend);
|
||||
bytes_to_read,
|
||||
devbufend - devbufstart - bytes_to_read);
|
||||
memcpy (p, devbuf + devbufstart, bytes_to_read);
|
||||
len -= bytes_to_read;
|
||||
p += bytes_to_read;
|
||||
|
@ -251,9 +266,6 @@ fhandler_dev_raw::raw_read (void *ptr, size_t& ulen)
|
|||
{
|
||||
if (len >= devbufsiz)
|
||||
{
|
||||
if (get_major () == DEV_TAPE_MAJOR)
|
||||
bytes_to_read = (len / devbufsiz) * devbufsiz;
|
||||
else
|
||||
bytes_to_read = (len / 512) * 512;
|
||||
tgt = p;
|
||||
debug_printf ("read %d bytes direct from file",bytes_to_read);
|
||||
|
@ -310,11 +322,6 @@ fhandler_dev_raw::raw_read (void *ptr, size_t& ulen)
|
|||
{
|
||||
if (!is_eof (ret) && !is_eom (ret))
|
||||
{
|
||||
if (varblkop && ret == ERROR_MORE_DATA)
|
||||
/* *ulen < blocksize. Linux returns ENOMEM here
|
||||
when reading with variable blocksize . */
|
||||
set_errno (ENOMEM);
|
||||
else
|
||||
__seterrno ();
|
||||
goto err;
|
||||
}
|
||||
|
@ -470,7 +477,6 @@ fhandler_dev_raw::dup (fhandler_base *child)
|
|||
fhc->eom_detected = eom_detected;
|
||||
fhc->eof_detected = eof_detected;
|
||||
fhc->lastblk_to_read = 0;
|
||||
fhc->varblkop = varblkop;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -35,7 +35,7 @@ struct mtop {
|
|||
};
|
||||
|
||||
/* Magnetic Tape operations [Not all operations supported by all drivers]: */
|
||||
#define MTRESET 0 /* +reset drive in case of problems */
|
||||
#define MTRESET 0 /* reset drive in case of problems */
|
||||
#define MTFSF 1 /* forward space over FileMark,
|
||||
* position at first record of next file
|
||||
*/
|
||||
|
@ -80,15 +80,14 @@ struct mtop {
|
|||
/* structure for MTIOCGET - mag tape get status command */
|
||||
|
||||
struct mtget {
|
||||
long mt_type; /* type of magtape device
|
||||
* Cygwin: MT_ISUNKNOWN */
|
||||
long mt_type; /* type of magtape device */
|
||||
long mt_resid; /* residual count: (not sure)
|
||||
* number of bytes ignored, or
|
||||
* number of files not skipped, or
|
||||
* number of records not skipped.
|
||||
* Cygwin: remaining KB until 1.5.7.
|
||||
* active partition since 1.5.8,
|
||||
* same as on linux.
|
||||
* active partition since 1.5.8
|
||||
* (same as on GNU-Linux).
|
||||
*/
|
||||
/* the following registers are device dependent */
|
||||
long mt_dsreg; /* status register, Contains blocksize and
|
||||
|
@ -133,17 +132,27 @@ struct mtpos {
|
|||
#define GMT_SM(x) ((x) & 0x10000000) /* DDS setmark */
|
||||
#define GMT_EOD(x) ((x) & 0x08000000) /* DDS EOD */
|
||||
#define GMT_WR_PROT(x) ((x) & 0x04000000)
|
||||
/* #define GMT_ ? ((x) & 0x02000000) */
|
||||
#define GMT_REP_SM(x) ((x) & 0x02000000) /* Cygwin: rep. setmarks */
|
||||
#define GMT_ONLINE(x) ((x) & 0x01000000)
|
||||
#define GMT_D_6250(x) ((x) & 0x00800000)
|
||||
#define GMT_D_1600(x) ((x) & 0x00400000)
|
||||
#define GMT_D_800(x) ((x) & 0x00200000)
|
||||
#define GMT_PADDING(x) ((x) & 0x00100000) /* data padding */
|
||||
#define GMT_HW_ECC(x) ((x) & 0x00080000) /* HW error correction */
|
||||
#define GMT_PADDING(x) ((x) & 0x00100000) /* Cygwin: data padding */
|
||||
#define GMT_HW_ECC(x) ((x) & 0x00080000) /* Cygwin: HW error corr. */
|
||||
#define GMT_DR_OPEN(x) ((x) & 0x00040000) /* door open (no tape) */
|
||||
#define GMT_HW_COMP(x) ((x) & 0x00020000) /* HW compression */
|
||||
#define GMT_HW_COMP(x) ((x) & 0x00020000) /* Cygwin: HW compression */
|
||||
#define GMT_IM_REP_EN(x) ((x) & 0x00010000) /* immediate report mode */
|
||||
/* 16 generic status bits unused */
|
||||
#define GMT_CLN(x) ((x) & 0x00008000) /* cleaning requested */
|
||||
/* 15 generic status bits unused */
|
||||
/* Cygwin only: The below settings are also used by the GNU-Linux SCSI tape
|
||||
driver but they aren't usually reported here. Unfortunately, there's no
|
||||
other official method to retrieve the values of these settings and
|
||||
reporting them here apparently doesn't hurt. */
|
||||
#define GMT_TWO_FM(x) ((x) & 0x00000080) /* two fm after write */
|
||||
#define GMT_FAST_MTEOM(x) ((x) & 0x00000040) /* fast seek to eom */
|
||||
#define GMT_AUTO_LOCK(x) ((x) & 0x00000020) /* auto door lock on r/w */
|
||||
#define GMT_SYSV(x) ((x) & 0x00000010) /* SYSV read semantics */
|
||||
#define GMT_NOWAIT(x) ((x) & 0x00000008) /* don't wait for positioning commands */
|
||||
|
||||
|
||||
/* SCSI-tape specific definitions */
|
||||
|
@ -156,6 +165,33 @@ struct mtpos {
|
|||
#define MT_ST_SOFTERR_SHIFT 0
|
||||
#define MT_ST_SOFTERR_MASK 0xffff
|
||||
|
||||
/* Bitfields for the MTSETDRVBUFFER ioctl. */
|
||||
#define MT_ST_OPTIONS 0xf0000000
|
||||
#define MT_ST_BOOLEANS 0x10000000
|
||||
#define MT_ST_SETBOOLEANS 0x30000000
|
||||
#define MT_ST_CLEARBOOLEANS 0x40000000
|
||||
#define MT_ST_WRITE_THRESHOLD 0x20000000 /* Not supported */
|
||||
#define MT_ST_DEF_OPTIONS 0x60000000 /* Not supported */
|
||||
#define MT_ST_EOT_WZ_SIZE 0xf0000000 /* Cygwin only */
|
||||
|
||||
#define MT_ST_BUFFER_WRITES 0x00000001
|
||||
#define MT_ST_ASYNC_WRITES 0x00000002 /* Not supported */
|
||||
#define MT_ST_READ_AHEAD 0x00000004 /* Not supported */
|
||||
#define MT_ST_DEBUGGING 0x00000008 /* Not supported */
|
||||
#define MT_ST_TWO_FM 0x00000010
|
||||
#define MT_ST_FAST_MTEOM 0x00000020
|
||||
#define MT_ST_AUTO_LOCK 0x00000040
|
||||
#define MT_ST_DEF_WRITES 0x00000080 /* Not supported */
|
||||
#define MT_ST_CAN_BSR 0x00000100 /* Not supported */
|
||||
#define MT_ST_NO_BLKLIMS 0x00000200 /* Not supported */
|
||||
#define MT_ST_CAN_PARTITIONS 0x00000400 /* Not supported */
|
||||
#define MT_ST_SCSI2LOGICAL 0x00000800 /* Not supported */
|
||||
#define MT_ST_SYSV 0x00001000
|
||||
#define MT_ST_NOWAIT 0x00002000
|
||||
#define MT_ST_ECC 0x00010000 /* Cygwin only */
|
||||
#define MT_ST_PADDING 0x00020000 /* Cygwin only */
|
||||
#define MT_ST_REPORT_SM 0x00040000 /* Cygwin only */
|
||||
|
||||
/*
|
||||
* Constants for mt_type. Not all of these are supported,
|
||||
* and these are not all of the ones that are supported.
|
||||
|
|
|
@ -238,12 +238,14 @@ details. */
|
|||
timer_settime
|
||||
111: Export sigqueue, sighold.
|
||||
112: Redefine some mtget fields.
|
||||
113: Again redefine some mtget fields. Use mt_fileno and mt_blkno as
|
||||
on Linux.
|
||||
*/
|
||||
|
||||
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
|
||||
|
||||
#define CYGWIN_VERSION_API_MAJOR 0
|
||||
#define CYGWIN_VERSION_API_MINOR 112
|
||||
#define CYGWIN_VERSION_API_MINOR 113
|
||||
|
||||
/* There is also a compatibity version number associated with the
|
||||
shared memory regions. It is incremented when incompatible
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
/* mtinfo.h: Defininitions for the Cygwin tape driver class.
|
||||
|
||||
Copyright 2004 Red Hat, Inc.
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
This software is a copyrighted work licensed under the terms of the
|
||||
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||
details. */
|
||||
|
||||
#define MTINFO_MAGIC 0x179b2af0
|
||||
#define MTINFO_VERSION 1
|
||||
|
||||
/* Maximum number of supported partitions per drive. */
|
||||
#define MAX_PARTITION_NUM 64
|
||||
/* Maximum number of supported drives. */
|
||||
#define MAX_DRIVE_NUM 8
|
||||
|
||||
/* Values for bookkeeping of the tape position relative to filemarks
|
||||
and eod/eom. */
|
||||
enum eom_val
|
||||
{
|
||||
no_eof,
|
||||
eof_hit,
|
||||
eof,
|
||||
eod_hit,
|
||||
eod,
|
||||
eom_hit,
|
||||
eom
|
||||
};
|
||||
|
||||
enum dirty_state
|
||||
{
|
||||
clean,
|
||||
has_read,
|
||||
has_written
|
||||
};
|
||||
|
||||
enum lock_state
|
||||
{
|
||||
unlocked,
|
||||
lock_error,
|
||||
auto_locked,
|
||||
locked
|
||||
};
|
||||
|
||||
/* Partition specific information */
|
||||
class mtinfo_part
|
||||
{
|
||||
public:
|
||||
long block; /* logical block no */
|
||||
long file; /* current file no */
|
||||
long fblock; /* relative block no */
|
||||
bool smark; /* At setmark? */
|
||||
eom_val emark; /* "end-of"-mark */
|
||||
|
||||
void initialize (long nblock = -1);
|
||||
};
|
||||
|
||||
class mtinfo_drive
|
||||
{
|
||||
int drive;
|
||||
int lasterr;
|
||||
long partition;
|
||||
long block;
|
||||
dirty_state dirty;
|
||||
lock_state lock;
|
||||
TAPE_GET_DRIVE_PARAMETERS _dp;
|
||||
TAPE_GET_MEDIA_PARAMETERS _mp;
|
||||
bool buffer_writes;
|
||||
bool two_fm;
|
||||
bool fast_eom;
|
||||
bool auto_lock;
|
||||
bool sysv;
|
||||
bool nowait;
|
||||
mtinfo_part _part[MAX_PARTITION_NUM];
|
||||
|
||||
inline int error (const char *str)
|
||||
{
|
||||
if (lasterr)
|
||||
debug_printf ("%s: Win32 error %d", lasterr);
|
||||
return lasterr;
|
||||
}
|
||||
inline bool get_feature (DWORD parm)
|
||||
{
|
||||
return ((parm & TAPE_DRIVE_HIGH_FEATURES)
|
||||
? ((_dp.FeaturesHigh & parm) != 0)
|
||||
: ((_dp.FeaturesLow & parm) != 0));
|
||||
}
|
||||
int get_pos (HANDLE mt, long *ppartition = NULL, long *pblock = NULL);
|
||||
int _set_pos (HANDLE mt, int mode, long count, int partition);
|
||||
int create_partitions (HANDLE mt, long count);
|
||||
int set_partition (HANDLE mt, long count);
|
||||
int write_marks (HANDLE mt, int marktype, DWORD count);
|
||||
int erase (HANDLE mt, int mode);
|
||||
int prepare (HANDLE mt, int action, bool is_auto = false);
|
||||
int set_compression (HANDLE mt, long count);
|
||||
int set_blocksize (HANDLE mt, long count);
|
||||
int status (HANDLE mt, struct mtget *get);
|
||||
int set_options (HANDLE mt, long options);
|
||||
|
||||
public:
|
||||
void initialize (int num, bool first_time);
|
||||
int get_dp (HANDLE mt);
|
||||
int get_mp (HANDLE mt);
|
||||
int open (HANDLE mt);
|
||||
int close (HANDLE mt, bool rewind);
|
||||
int read (HANDLE mt, void *ptr, size_t &ulen);
|
||||
int write (HANDLE mt, const void *ptr, size_t &len);
|
||||
int ioctl (HANDLE mt, unsigned int cmd, void *buf);
|
||||
int set_pos (HANDLE mt, int mode, long count, bool sfm_func);
|
||||
|
||||
inline bool buffered_writes (void) { return buffer_writes; }
|
||||
PTAPE_GET_DRIVE_PARAMETERS dp (void) { return &_dp; }
|
||||
PTAPE_GET_MEDIA_PARAMETERS mp (void) { return &_mp; }
|
||||
mtinfo_part *part (int num) { return &_part[num]; }
|
||||
};
|
||||
|
||||
class mtinfo
|
||||
{
|
||||
DWORD magic;
|
||||
DWORD version;
|
||||
mtinfo_drive _drive[MAX_DRIVE_NUM];
|
||||
|
||||
public:
|
||||
void initialize (void);
|
||||
mtinfo_drive *drive (int num) { return &_drive[num]; }
|
||||
};
|
||||
|
||||
extern HANDLE mt_h;
|
||||
extern mtinfo *mt;
|
||||
|
||||
extern void __stdcall mtinfo_init ();
|
|
@ -26,6 +26,7 @@ details. */
|
|||
#include "registry.h"
|
||||
#include "cygwin_version.h"
|
||||
#include "child_info.h"
|
||||
#include "mtinfo.h"
|
||||
|
||||
shared_info NO_COPY *cygwin_shared;
|
||||
user_info NO_COPY *user_shared;
|
||||
|
@ -58,11 +59,17 @@ static char *offsets[] =
|
|||
+ pround (sizeof (shared_info))
|
||||
+ pround (sizeof (user_info))
|
||||
+ pround (sizeof (console_state)),
|
||||
(char *) cygwin_shared_address
|
||||
+ pround (sizeof (shared_info))
|
||||
+ pround (sizeof (user_info))
|
||||
+ pround (sizeof (console_state))
|
||||
+ pround (sizeof (_pinfo)),
|
||||
(char *) cygwin_shared_address
|
||||
+ pround (sizeof (shared_info))
|
||||
+ pround (sizeof (user_info))
|
||||
+ pround (sizeof (console_state))
|
||||
+ pround (sizeof (_pinfo))
|
||||
+ pround (sizeof (mtinfo))
|
||||
};
|
||||
|
||||
void * __stdcall
|
||||
|
@ -243,6 +250,7 @@ memory_init ()
|
|||
ProtectHandleINH (cygheap->shared_h);
|
||||
|
||||
user_shared_initialize (false);
|
||||
mtinfo_init ();
|
||||
}
|
||||
|
||||
unsigned
|
||||
|
|
|
@ -176,6 +176,7 @@ enum shared_locations
|
|||
SH_USER_SHARED,
|
||||
SH_SHARED_CONSOLE,
|
||||
SH_MYSELF,
|
||||
SH_MTINFO,
|
||||
SH_TOTAL_SIZE
|
||||
};
|
||||
void __stdcall memory_init ();
|
||||
|
|
Loading…
Reference in New Issue