* mtinfo.h (class mtinfo_part): Change type of block numbers to int64_t.

(mtinfo_part::initialize): Ditto for nblock parameter in declaration.
	(class mtinfo_drive): Change type of block number to int64_t.  Change
	all parameters indicating a block number to int64_t in method
	declarations.
	* fhandler_tape.cc (mtinfo_part::initialize): Ditto in definition.
	(mtinfo_drive::get_pos): Ditto.  Replace low and high with a
	ULARGE_INTEGER and use it's components in call to GetTapePosition.
	Store full value in block.
	(mtinfo_drive::_set_pos): Change type of count parameter to int64_t.
	Change call to SetTapePosition accordingly.
	(mtinfo_drive::set_pos): Change type of count parameter to int64_t.
	Change local variables holding block numbers accordingly.
	(mtinfo_drive::get_status): Don't bail out early if fetching media
	parameters fails.
	(mtinfo_drive::ioctl): Add explicit cast matching receiving type in
	MTTELL and MTIOCPOS calls.
This commit is contained in:
Corinna Vinschen 2013-08-26 16:14:40 +00:00
parent 8451a289cc
commit 6585330779
3 changed files with 51 additions and 29 deletions

View File

@ -1,3 +1,23 @@
2013-08-26 Corinna Vinschen <corinna@vinschen.de>
* mtinfo.h (class mtinfo_part): Change type of block numbers to int64_t.
(mtinfo_part::initialize): Ditto for nblock parameter in declaration.
(class mtinfo_drive): Change type of block number to int64_t. Change
all parameters indicating a block number to int64_t in method
declarations.
* fhandler_tape.cc (mtinfo_part::initialize): Ditto in definition.
(mtinfo_drive::get_pos): Ditto. Replace low and high with a
ULARGE_INTEGER and use it's components in call to GetTapePosition.
Store full value in block.
(mtinfo_drive::_set_pos): Change type of count parameter to int64_t.
Change call to SetTapePosition accordingly.
(mtinfo_drive::set_pos): Change type of count parameter to int64_t.
Change local variables holding block numbers accordingly.
(mtinfo_drive::get_status): Don't bail out early if fetching media
parameters fails.
(mtinfo_drive::ioctl): Add explicit cast matching receiving type in
MTTELL and MTIOCPOS calls.
2013-08-23 Corinna Vinschen <corinna@vinschen.de>
* flock.cc (lockf_t::from_obj_name): Fix test for valid pid.

View File

@ -53,7 +53,7 @@ details. */
/* mtinfo_part */
void
mtinfo_part::initialize (int32_t nblock)
mtinfo_part::initialize (int64_t nblock)
{
block = nblock;
if (block == 0)
@ -353,18 +353,21 @@ mtinfo_drive::write (HANDLE mt, LPOVERLAPPED pov, const void *ptr, size_t &len)
}
int
mtinfo_drive::get_pos (HANDLE mt, int32_t *ppartition, int32_t *pblock)
mtinfo_drive::get_pos (HANDLE mt, int32_t *ppartition, int64_t *pblock)
{
DWORD p, low, high;
DWORD p;
ULARGE_INTEGER b;
TAPE_FUNC (GetTapePosition (mt, TAPE_LOGICAL_POSITION, &p, &low, &high));
TAPE_FUNC (GetTapePosition (mt, TAPE_LOGICAL_POSITION, &p,
&b.LowPart, &b.HighPart));
if (lasterr == ERROR_INVALID_FUNCTION)
TAPE_FUNC (GetTapePosition (mt, TAPE_ABSOLUTE_POSITION, &p, &low, &high));
TAPE_FUNC (GetTapePosition (mt, TAPE_ABSOLUTE_POSITION, &p,
&b.LowPart, &b.HighPart));
if (!lasterr)
{
if (p > 0)
partition = (int32_t) p - 1;
block = (int32_t) low;
block = (int64_t) b.QuadPart;
if (ppartition)
*ppartition= partition;
if (pblock)
@ -379,23 +382,24 @@ mtinfo_drive::get_pos (HANDLE mt, int32_t *ppartition, int32_t *pblock)
}
int
mtinfo_drive::_set_pos (HANDLE mt, int mode, int32_t count, int partition,
mtinfo_drive::_set_pos (HANDLE mt, int mode, int64_t count, int partition,
BOOL dont_wait)
{
/* If an async write is still pending, wait for completion. */
if (dirty == async_write_pending)
lasterr = async_wait (mt, NULL);
dirty = clean;
TAPE_FUNC (SetTapePosition (mt, mode, partition, count, count < 0 ? -1 : 0,
LARGE_INTEGER c = { QuadPart:count };
TAPE_FUNC (SetTapePosition (mt, mode, partition, c.LowPart, c.HighPart,
dont_wait));
return lasterr;
}
int
mtinfo_drive::set_pos (HANDLE mt, int mode, int32_t count, bool sfm_func)
mtinfo_drive::set_pos (HANDLE mt, int mode, int64_t count, bool sfm_func)
{
int err = 0;
int32_t undone = count;
int64_t undone = count;
BOOL dont_wait = FALSE;
switch (mode)
@ -589,12 +593,12 @@ mtinfo_drive::set_partition (HANDLE mt, int32_t count)
lasterr = ERROR_IO_DEVICE;
else
{
int part_block = part (count)->block >= 0 ? part (count)->block : 0;
uint64_t part_block = part (count)->block >= 0 ? part (count)->block : 0;
int err = _set_pos (mt, TAPE_LOGICAL_BLOCK, part_block, count + 1, FALSE);
if (err)
{
int sav_block = block;
int sav_partition = partition;
int64_t sav_block = block;
int32_t sav_partition = partition;
get_pos (mt);
if (sav_partition != partition)
{
@ -649,8 +653,8 @@ mtinfo_drive::write_marks (HANDLE mt, int marktype, DWORD count)
}
else
{
int sav_block = block;
int sav_partition = partition;
int64_t sav_block = block;
int32_t sav_partition = partition;
get_pos (mt);
if (sav_partition != partition)
{
@ -758,12 +762,10 @@ mtinfo_drive::get_status (HANDLE mt, struct mtget *get)
if (!get)
return ERROR_INVALID_PARAMETER;
if ((tstat = GetTapeStatus (mt)) == ERROR_NO_MEDIA_IN_DRIVE)
if ((tstat = GetTapeStatus (mt)) == ERROR_NO_MEDIA_IN_DRIVE
|| get_mp (mt) == ERROR_NO_MEDIA_IN_DRIVE)
notape = 1;
if (get_mp (mt))
return lasterr;
memset (get, 0, sizeof *get);
get->mt_type = MT_ISUNKNOWN;
@ -1082,7 +1084,7 @@ mtinfo_drive::ioctl (HANDLE mt, unsigned int cmd, void *buf)
break;
case MTTELL:
if (!get_pos (mt))
op->mt_count = block;
op->mt_count = (int) block;
break;
case MTFSS:
set_pos (mt, TAPE_SPACE_SETMARKS, op->mt_count, false);
@ -1123,7 +1125,7 @@ mtinfo_drive::ioctl (HANDLE mt, unsigned int cmd, void *buf)
else if (cmd == MTIOCGET)
get_status (mt, (struct mtget *) buf);
else if (cmd == MTIOCPOS && !get_pos (mt))
((struct mtpos *) buf)->mt_blkno = block;
((struct mtpos *) buf)->mt_blkno = (long) block;
return lasterr;
}

View File

@ -1,6 +1,6 @@
/* mtinfo.h: Defininitions for the Cygwin tape driver class.
Copyright 2004, 2005, 2006, 2008, 2012 Red Hat, Inc.
Copyright 2004, 2005, 2006, 2008, 2012, 2013 Red Hat, Inc.
This file is part of Cygwin.
@ -46,13 +46,13 @@ enum lock_state
class mtinfo_part
{
public:
int32_t block; /* logical block no */
int64_t block; /* logical block no */
int64_t fblock; /* relative block no */
int32_t file; /* current file no */
int32_t fblock; /* relative block no */
bool smark; /* At setmark? */
eom_val emark; /* "end-of"-mark */
void initialize (int32_t nblock = -1);
void initialize (int64_t nblock = -1);
};
class mtinfo_drive
@ -60,7 +60,7 @@ class mtinfo_drive
int drive;
int lasterr;
int32_t partition;
int32_t block;
int64_t block;
dirty_state dirty;
lock_state lock;
TAPE_GET_DRIVE_PARAMETERS _dp;
@ -94,8 +94,8 @@ class mtinfo_drive
? ((_dp.FeaturesHigh & parm) != 0)
: ((_dp.FeaturesLow & parm) != 0));
}
int get_pos (HANDLE mt, int32_t *ppartition = NULL, int32_t *pblock = NULL);
int _set_pos (HANDLE mt, int mode, int32_t count, int partition, BOOL dont_wait);
int get_pos (HANDLE mt, int32_t *ppartition = NULL, int64_t *pblock = NULL);
int _set_pos (HANDLE mt, int mode, int64_t count, int partition, BOOL dont_wait);
int create_partitions (HANDLE mt, int32_t count);
int set_partition (HANDLE mt, int32_t count);
int write_marks (HANDLE mt, int marktype, DWORD count);
@ -116,7 +116,7 @@ public:
int read (HANDLE mt, LPOVERLAPPED pov, void *ptr, size_t &ulen);
int write (HANDLE mt, LPOVERLAPPED pov, const void *ptr, size_t &len);
int ioctl (HANDLE mt, unsigned int cmd, void *buf);
int set_pos (HANDLE mt, int mode, int32_t count, bool sfm_func);
int set_pos (HANDLE mt, int mode, int64_t count, bool sfm_func);
IMPLEMENT_STATUS_FLAG (bool, buffer_writes)
IMPLEMENT_STATUS_FLAG (bool, async_writes)