diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2014-08-22 13:21:33 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2014-08-22 13:21:33 +0400 |
commit | 3f3bd10104550243781f0b4d9248975e35d91ac7 (patch) | |
tree | c7ac2839d2c3da2321bd9979a1574667ed39bc26 /winsup/cygwin/fhandler_tape.cc | |
parent | 33ed7bb5bc2cb41259df064229968933d9c898ca (diff) |
* Throughout, use __try/__except/__endtry blocks, rather than myfault
handler.
* cygtls.cc (_cygtls::remove): Accommodate the fact that pathbufs
has been moved from _local_storage to _cygtls.
* cygtls.h (class tls_pathbuf): Add comment to hint to gendef usage
of counters. Change type of counters to uint32_t for clarity.
Remove _cygtls as friend class.
(struct _local_storage): Move pathbufs from here...
(struct _cygtls): ...to here, allowing to access it from _sigbe.
(class san): Only define on 32 bit. Remove errno, _c_cnt and _w_cnt
members.
(san::setup): Drop parameter. Don't initialize removed members.
(san::leave): Don't set removed members.
(class myfault): Only define on 32 bit.
(myfault::faulted): Only keep implementation not taking any parameter.
Drop argument in call to sebastian.setup.
(__try/__leave/__except/__endtry): Implement to support real SEH. For
now stick to SJLJ on 32 bit.
* dcrt0.cc (dll_crt0_0): Drop 64 bit call to
exception::install_myfault_handler.
* exception.h (exception_handler): Define with EXCEPTION_DISPOSITION
as return type.
(PDISPATCHER_CONTEXT): Define as void * on 32 bit. Define as pointer
to _DISPATCHER_CONTEXT on 64 bit.
(class exception): Define separately for 32 and 64 bit.
(exception::myfault): Add handler for myfault SEH handling on 64 bit.
(exception::exception): Fix mangled method name to account for change
in type of last parameter.
(exception::install_myfault_handler): Remove.
* exceptions.cc (exception::myfault_handle): Remove.
(exception::myfault): New SEH handler for 64 bit.
* gendef (_sigbe): Set tls_pathbuf counters to 0 explicitely when
returning to the caller.
* ntdll.h: Move a comment to a better place.
(struct _SCOPE_TABLE): Define on 64 bit.
* thread.cc (verifyable_object_isvalid): Remove gcc 4.7 workaround.
* tls_pbuf.cc (tls_pbuf): Fix to accommodate new place of pathbufs.
(tls_pathbuf::destroy): Change type of loop variables to uint32_t.
* tls_pbuf.h (class tmp_pathbuf): Change type of buffer counters to
uint32_t. Accommodate new place of pathbufs.
* tlsoffsets.h: Regenerate.
* tlsoffsets64.h: Regenerate.
Diffstat (limited to 'winsup/cygwin/fhandler_tape.cc')
-rw-r--r-- | winsup/cygwin/fhandler_tape.cc | 290 |
1 files changed, 147 insertions, 143 deletions
diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc index 91d5b12aa..5b09e4262 100644 --- a/winsup/cygwin/fhandler_tape.cc +++ b/winsup/cygwin/fhandler_tape.cc @@ -2,7 +2,7 @@ classes. Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, - 2010, 2011, 2012, 2013 Red Hat, Inc. + 2010, 2011, 2012, 2013, 2014 Red Hat, Inc. This file is part of Cygwin. @@ -977,159 +977,163 @@ mtinfo_drive::set_options (HANDLE mt, int32_t options) int mtinfo_drive::ioctl (HANDLE mt, unsigned int cmd, void *buf) { - myfault efault; - if (efault.faulted ()) - return ERROR_NOACCESS; - if (cmd == MTIOCTOP) + __try { - struct mtop *op = (struct mtop *) buf; - if (lasterr == ERROR_BUS_RESET) + if (cmd == MTIOCTOP) { - /* If a bus reset occurs, block further access to this device - until the user rewinds, unloads or in any other way tries - to maintain a well-known tape position. */ - if (op->mt_op != MTREW && op->mt_op != MTOFFL - && op->mt_op != MTRETEN && op->mt_op != MTERASE - && op->mt_op != MTSEEK && op->mt_op != MTEOM) - return ERROR_BUS_RESET; - /* Try to maintain last lock state after bus reset. */ - if (lock >= auto_locked && PrepareTape (mt, TAPE_LOCK, FALSE)) + struct mtop *op = (struct mtop *) buf; + if (lasterr == ERROR_BUS_RESET) { - debug_printf ("Couldn't relock drive after bus reset."); - lock = unlocked; + /* If a bus reset occurs, block further access to this device + until the user rewinds, unloads or in any other way tries + to maintain a well-known tape position. */ + if (op->mt_op != MTREW && op->mt_op != MTOFFL + && op->mt_op != MTRETEN && op->mt_op != MTERASE + && op->mt_op != MTSEEK && op->mt_op != MTEOM) + return ERROR_BUS_RESET; + /* Try to maintain last lock state after bus reset. */ + if (lock >= auto_locked && PrepareTape (mt, TAPE_LOCK, FALSE)) + { + debug_printf ("Couldn't relock drive after bus reset."); + lock = unlocked; + } } - } - switch (op->mt_op) - { - case MTRESET: - break; - case MTFSF: - set_pos (mt, TAPE_SPACE_FILEMARKS, op->mt_count, false); - break; - case MTBSF: - set_pos (mt, TAPE_SPACE_FILEMARKS, -op->mt_count, false); - break; - case MTFSR: - set_pos (mt, TAPE_SPACE_RELATIVE_BLOCKS, op->mt_count, false); - break; - case MTBSR: - set_pos (mt, TAPE_SPACE_RELATIVE_BLOCKS, -op->mt_count, false); - break; - case MTWEOF: - write_marks (mt, TAPE_FILEMARKS, op->mt_count); - break; - case MTREW: - set_pos (mt, TAPE_REWIND, 0, false); - break; - case MTOFFL: - case MTUNLOAD: - prepare (mt, TAPE_UNLOAD); - break; - case MTNOP: - lasterr = 0; - break; - case MTRETEN: - if (!get_feature (TAPE_DRIVE_TENSION)) - lasterr = ERROR_INVALID_PARAMETER; - else if (!set_pos (mt, TAPE_REWIND, 0, false)) - prepare (mt, TAPE_TENSION); - break; - case MTBSFM: - set_pos (mt, TAPE_SPACE_FILEMARKS, -op->mt_count, true); - break; - case MTFSFM: - set_pos (mt, TAPE_SPACE_FILEMARKS, op->mt_count, true); - break; - case MTEOM: - if (fast_eom () && get_feature (TAPE_DRIVE_END_OF_DATA)) - set_pos (mt, TAPE_SPACE_END_OF_DATA, 0, false); - else - set_pos (mt, TAPE_SPACE_FILEMARKS, 32767, false); - break; - case MTERASE: - erase (mt, TAPE_ERASE_LONG); - break; - case MTRAS1: - case MTRAS2: - case MTRAS3: - lasterr = ERROR_INVALID_PARAMETER; - break; - case MTSETBLK: - if (!get_feature (TAPE_DRIVE_SET_BLOCK_SIZE)) - { - lasterr = ERROR_INVALID_PARAMETER; + switch (op->mt_op) + { + case MTRESET: break; - } - if ((DWORD) op->mt_count == mp ()->BlockSize) - { - /* Nothing has changed. */ + case MTFSF: + set_pos (mt, TAPE_SPACE_FILEMARKS, op->mt_count, false); + break; + case MTBSF: + set_pos (mt, TAPE_SPACE_FILEMARKS, -op->mt_count, false); + break; + case MTFSR: + set_pos (mt, TAPE_SPACE_RELATIVE_BLOCKS, op->mt_count, false); + break; + case MTBSR: + set_pos (mt, TAPE_SPACE_RELATIVE_BLOCKS, -op->mt_count, false); + break; + case MTWEOF: + write_marks (mt, TAPE_FILEMARKS, op->mt_count); + break; + case MTREW: + set_pos (mt, TAPE_REWIND, 0, false); + break; + case MTOFFL: + case MTUNLOAD: + prepare (mt, TAPE_UNLOAD); + break; + case MTNOP: lasterr = 0; break; - } - if ((op->mt_count == 0 && !get_feature (TAPE_DRIVE_VARIABLE_BLOCK)) - || (op->mt_count > 0 - && ((DWORD) op->mt_count < dp ()->MinimumBlockSize - || (DWORD) op->mt_count > dp ()->MaximumBlockSize))) - { + case MTRETEN: + if (!get_feature (TAPE_DRIVE_TENSION)) + lasterr = ERROR_INVALID_PARAMETER; + else if (!set_pos (mt, TAPE_REWIND, 0, false)) + prepare (mt, TAPE_TENSION); + break; + case MTBSFM: + set_pos (mt, TAPE_SPACE_FILEMARKS, -op->mt_count, true); + break; + case MTFSFM: + set_pos (mt, TAPE_SPACE_FILEMARKS, op->mt_count, true); + break; + case MTEOM: + if (fast_eom () && get_feature (TAPE_DRIVE_END_OF_DATA)) + set_pos (mt, TAPE_SPACE_END_OF_DATA, 0, false); + else + set_pos (mt, TAPE_SPACE_FILEMARKS, 32767, false); + break; + case MTERASE: + erase (mt, TAPE_ERASE_LONG); + break; + case MTRAS1: + case MTRAS2: + case MTRAS3: lasterr = ERROR_INVALID_PARAMETER; break; - } - if (set_blocksize (mt, op->mt_count) - && lasterr == ERROR_INVALID_FUNCTION) - lasterr = ERROR_INVALID_BLOCK_LENGTH; - break; - case MTSEEK: - if (get_feature (TAPE_DRIVE_LOGICAL_BLK)) - set_pos (mt, TAPE_LOGICAL_BLOCK, op->mt_count, false); - else if (!get_pos (mt)) - set_pos (mt, TAPE_SPACE_RELATIVE_BLOCKS, - op->mt_count - block, false); - break; - case MTTELL: - if (!get_pos (mt)) - op->mt_count = (int) block; - break; - case MTFSS: - set_pos (mt, TAPE_SPACE_SETMARKS, op->mt_count, false); - break; - case MTBSS: - set_pos (mt, TAPE_SPACE_SETMARKS, -op->mt_count, false); - break; - case MTWSM: - write_marks (mt, TAPE_SETMARKS, op->mt_count); - break; - case MTLOCK: - prepare (mt, TAPE_LOCK); - break; - case MTUNLOCK: - prepare (mt, TAPE_UNLOCK); - break; - case MTLOAD: - prepare (mt, TAPE_LOAD); - break; - case MTCOMPRESSION: - set_compression (mt, op->mt_count); - break; - case MTSETPART: - set_partition (mt, op->mt_count); - break; - case MTMKPART: - create_partitions (mt, op->mt_count); - break; - case MTSETDRVBUFFER: - set_options (mt, op->mt_count); - break; - case MTSETDENSITY: - default: - lasterr = ERROR_INVALID_PARAMETER; - break; + case MTSETBLK: + if (!get_feature (TAPE_DRIVE_SET_BLOCK_SIZE)) + { + lasterr = ERROR_INVALID_PARAMETER; + break; + } + if ((DWORD) op->mt_count == mp ()->BlockSize) + { + /* Nothing has changed. */ + lasterr = 0; + break; + } + if ((op->mt_count == 0 && !get_feature (TAPE_DRIVE_VARIABLE_BLOCK)) + || (op->mt_count > 0 + && ((DWORD) op->mt_count < dp ()->MinimumBlockSize + || (DWORD) op->mt_count > dp ()->MaximumBlockSize))) + { + lasterr = ERROR_INVALID_PARAMETER; + break; + } + if (set_blocksize (mt, op->mt_count) + && lasterr == ERROR_INVALID_FUNCTION) + lasterr = ERROR_INVALID_BLOCK_LENGTH; + break; + case MTSEEK: + if (get_feature (TAPE_DRIVE_LOGICAL_BLK)) + set_pos (mt, TAPE_LOGICAL_BLOCK, op->mt_count, false); + else if (!get_pos (mt)) + set_pos (mt, TAPE_SPACE_RELATIVE_BLOCKS, + op->mt_count - block, false); + break; + case MTTELL: + if (!get_pos (mt)) + op->mt_count = (int) block; + break; + case MTFSS: + set_pos (mt, TAPE_SPACE_SETMARKS, op->mt_count, false); + break; + case MTBSS: + set_pos (mt, TAPE_SPACE_SETMARKS, -op->mt_count, false); + break; + case MTWSM: + write_marks (mt, TAPE_SETMARKS, op->mt_count); + break; + case MTLOCK: + prepare (mt, TAPE_LOCK); + break; + case MTUNLOCK: + prepare (mt, TAPE_UNLOCK); + break; + case MTLOAD: + prepare (mt, TAPE_LOAD); + break; + case MTCOMPRESSION: + set_compression (mt, op->mt_count); + break; + case MTSETPART: + set_partition (mt, op->mt_count); + break; + case MTMKPART: + create_partitions (mt, op->mt_count); + break; + case MTSETDRVBUFFER: + set_options (mt, op->mt_count); + break; + case MTSETDENSITY: + default: + lasterr = ERROR_INVALID_PARAMETER; + break; + } } + else if (cmd == MTIOCGET) + get_status (mt, (struct mtget *) buf); + else if (cmd == MTIOCPOS && !get_pos (mt)) + ((struct mtpos *) buf)->mt_blkno = (long) block; } - else if (cmd == MTIOCGET) - get_status (mt, (struct mtget *) buf); - else if (cmd == MTIOCPOS && !get_pos (mt)) - ((struct mtpos *) buf)->mt_blkno = (long) block; - + __except (NO_ERROR) + { + lasterr = ERROR_NOACCESS; + } + __endtry return lasterr; } |