ntdll: tape.c portability fixes.
Accept MTCOMP as an alias for MTCOMPRESSION on those systems, having the former, but not the latter. Only enable operations supported by the host OS in TAPE_CreatePartition() and TAPE_Prepare().
This commit is contained in:
parent
f0d6519ef5
commit
c0ca7172a2
|
@ -30,6 +30,11 @@
|
||||||
#include <sys/mtio.h>
|
#include <sys/mtio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* FreeBSD, for example, has MTCOMP instead of MTCOMPRESSION. */
|
||||||
|
#if !defined(MTCOMPRESSION) && defined(MTCOMP)
|
||||||
|
#define MTCOMPRESSION MTCOMP
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NONAMELESSUNION
|
#define NONAMELESSUNION
|
||||||
#define NONAMELESSSTRUCT
|
#define NONAMELESSSTRUCT
|
||||||
#include "ntstatus.h"
|
#include "ntstatus.h"
|
||||||
|
@ -95,6 +100,7 @@ static NTSTATUS TAPE_CreatePartition( int fd, TAPE_CREATE_PARTITION *data )
|
||||||
|
|
||||||
switch (data->Method)
|
switch (data->Method)
|
||||||
{
|
{
|
||||||
|
#ifdef MTMKPART
|
||||||
case TAPE_FIXED_PARTITIONS:
|
case TAPE_FIXED_PARTITIONS:
|
||||||
case TAPE_SELECT_PARTITIONS:
|
case TAPE_SELECT_PARTITIONS:
|
||||||
cmd.mt_op = MTMKPART;
|
cmd.mt_op = MTMKPART;
|
||||||
|
@ -104,6 +110,7 @@ static NTSTATUS TAPE_CreatePartition( int fd, TAPE_CREATE_PARTITION *data )
|
||||||
cmd.mt_op = MTMKPART;
|
cmd.mt_op = MTMKPART;
|
||||||
cmd.mt_count = data->Size;
|
cmd.mt_count = data->Size;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
ERR( "Unhandled method: 0x%08lx\n", data->Method );
|
ERR( "Unhandled method: 0x%08lx\n", data->Method );
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
@ -240,6 +247,7 @@ static NTSTATUS TAPE_GetPosition( int fd, ULONG type, TAPE_GET_POSITION *data )
|
||||||
data->Type = type;
|
data->Type = type;
|
||||||
data->Partition = get.mt_resid;
|
data->Partition = get.mt_resid;
|
||||||
data->OffsetLow = pos.mt_blkno;
|
data->OffsetLow = pos.mt_blkno;
|
||||||
|
break;
|
||||||
case TAPE_LOGICAL_BLOCK:
|
case TAPE_LOGICAL_BLOCK:
|
||||||
case TAPE_PSEUDO_LOGICAL_BLOCK:
|
case TAPE_PSEUDO_LOGICAL_BLOCK:
|
||||||
WARN( "Positioning type not supported\n" );
|
WARN( "Positioning type not supported\n" );
|
||||||
|
@ -269,21 +277,31 @@ static NTSTATUS TAPE_Prepare( int fd, TAPE_PREPARE *data )
|
||||||
|
|
||||||
switch (data->Operation)
|
switch (data->Operation)
|
||||||
{
|
{
|
||||||
|
#ifdef MTLOAD
|
||||||
case TAPE_LOAD:
|
case TAPE_LOAD:
|
||||||
cmd.mt_op = MTLOAD;
|
cmd.mt_op = MTLOAD;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef MTUNLOAD
|
||||||
case TAPE_UNLOAD:
|
case TAPE_UNLOAD:
|
||||||
cmd.mt_op = MTUNLOAD;
|
cmd.mt_op = MTUNLOAD;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef MTRETEN
|
||||||
case TAPE_TENSION:
|
case TAPE_TENSION:
|
||||||
cmd.mt_op = MTRETEN;
|
cmd.mt_op = MTRETEN;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef MTLOCK
|
||||||
case TAPE_LOCK:
|
case TAPE_LOCK:
|
||||||
cmd.mt_op = MTLOCK;
|
cmd.mt_op = MTLOCK;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef MTUNLOCK
|
||||||
case TAPE_UNLOCK:
|
case TAPE_UNLOCK:
|
||||||
cmd.mt_op = MTUNLOCK;
|
cmd.mt_op = MTUNLOCK;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case TAPE_FORMAT:
|
case TAPE_FORMAT:
|
||||||
/* Native ignores this if the drive doesn't support it */
|
/* Native ignores this if the drive doesn't support it */
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
@ -364,13 +382,17 @@ static NTSTATUS TAPE_SetPosition( int fd, TAPE_SET_POSITION *data )
|
||||||
case TAPE_REWIND:
|
case TAPE_REWIND:
|
||||||
cmd.mt_op = MTREW;
|
cmd.mt_op = MTREW;
|
||||||
break;
|
break;
|
||||||
|
#ifdef MTSEEK
|
||||||
case TAPE_ABSOLUTE_BLOCK:
|
case TAPE_ABSOLUTE_BLOCK:
|
||||||
cmd.mt_op = MTSEEK;
|
cmd.mt_op = MTSEEK;
|
||||||
cmd.mt_count = data->Offset.u.LowPart;
|
cmd.mt_count = data->Offset.u.LowPart;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef MTEOM
|
||||||
case TAPE_SPACE_END_OF_DATA:
|
case TAPE_SPACE_END_OF_DATA:
|
||||||
cmd.mt_op = MTEOM;
|
cmd.mt_op = MTEOM;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case TAPE_SPACE_FILEMARKS:
|
case TAPE_SPACE_FILEMARKS:
|
||||||
if (data->Offset.u.LowPart >= 0) {
|
if (data->Offset.u.LowPart >= 0) {
|
||||||
cmd.mt_op = MTFSF;
|
cmd.mt_op = MTFSF;
|
||||||
|
@ -380,6 +402,7 @@ static NTSTATUS TAPE_SetPosition( int fd, TAPE_SET_POSITION *data )
|
||||||
cmd.mt_op = MTBSF;
|
cmd.mt_op = MTBSF;
|
||||||
cmd.mt_count = -data->Offset.u.LowPart;
|
cmd.mt_count = -data->Offset.u.LowPart;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case TAPE_SPACE_SETMARKS:
|
case TAPE_SPACE_SETMARKS:
|
||||||
if (data->Offset.u.LowPart >= 0) {
|
if (data->Offset.u.LowPart >= 0) {
|
||||||
cmd.mt_op = MTFSS;
|
cmd.mt_op = MTFSS;
|
||||||
|
@ -389,6 +412,7 @@ static NTSTATUS TAPE_SetPosition( int fd, TAPE_SET_POSITION *data )
|
||||||
cmd.mt_op = MTBSS;
|
cmd.mt_op = MTBSS;
|
||||||
cmd.mt_count = -data->Offset.u.LowPart;
|
cmd.mt_count = -data->Offset.u.LowPart;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case TAPE_LOGICAL_BLOCK:
|
case TAPE_LOGICAL_BLOCK:
|
||||||
case TAPE_PSEUDO_LOGICAL_BLOCK:
|
case TAPE_PSEUDO_LOGICAL_BLOCK:
|
||||||
case TAPE_SPACE_RELATIVE_BLOCKS:
|
case TAPE_SPACE_RELATIVE_BLOCKS:
|
||||||
|
@ -421,10 +445,12 @@ static NTSTATUS TAPE_WriteMarks( int fd, TAPE_WRITE_MARKS *data )
|
||||||
|
|
||||||
switch (data->Type)
|
switch (data->Type)
|
||||||
{
|
{
|
||||||
|
#ifdef MTWSM
|
||||||
case TAPE_SETMARKS:
|
case TAPE_SETMARKS:
|
||||||
cmd.mt_op = MTWSM;
|
cmd.mt_op = MTWSM;
|
||||||
cmd.mt_count = data->Count;
|
cmd.mt_count = data->Count;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case TAPE_FILEMARKS:
|
case TAPE_FILEMARKS:
|
||||||
case TAPE_SHORT_FILEMARKS:
|
case TAPE_SHORT_FILEMARKS:
|
||||||
case TAPE_LONG_FILEMARKS:
|
case TAPE_LONG_FILEMARKS:
|
||||||
|
|
Loading…
Reference in New Issue