dlls/ntdll/tape.c portability
Gerald Pfeifer
gerald at pfeifer.com
Mon Jan 30 14:22:23 CST 2006
The addition of dlls/ntdll/tape.c broke the build on FreeBSD, and I
assume all other non-Linux platforms.
This is the first set of fixes, which address the majority of issues.
Gerald
ChangeLog:
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().
Add FreeBSD support to TAPE_GetPosition().
Index: tape.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/tape.c,v
retrieving revision 1.2
diff -u -3 -p -r1.2 tape.c
--- tape.c 30 Jan 2006 14:05:05 -0000 1.2
+++ tape.c 30 Jan 2006 20:15:24 -0000
@@ -30,6 +30,11 @@
#include <sys/mtio.h>
#endif
+/* FreeBSD, for example, has MTCOMP instead of MTCOMPRESSION. */
+#if !defined(MTCOMPRESSION) && defined(MTCOMP)
+#define MTCOMPRESSION MTCOMP
+#endif
+
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "ntstatus.h"
@@ -95,6 +100,7 @@ static NTSTATUS TAPE_CreatePartition( in
switch (data->Method)
{
+#ifdef MTMKPART
case TAPE_FIXED_PARTITIONS:
case TAPE_SELECT_PARTITIONS:
cmd.mt_op = MTMKPART;
@@ -104,6 +110,7 @@ static NTSTATUS TAPE_CreatePartition( in
cmd.mt_op = MTMKPART;
cmd.mt_count = data->Size;
break;
+#endif
default:
ERR( "Unhandled method: 0x%08lx\n", data->Method );
return STATUS_INVALID_PARAMETER;
@@ -219,7 +226,9 @@ static NTSTATUS TAPE_GetPosition( int fd
{
#ifdef HAVE_SYS_MTIO_H
struct mtget get;
+#ifndef __FreeBSD__
struct mtpos pos;
+#endif
NTSTATUS status;
TRACE( "fd: %d type: 0x%08lx\n", fd, type );
@@ -230,16 +239,22 @@ static NTSTATUS TAPE_GetPosition( int fd
if (status != STATUS_SUCCESS)
return status;
+#ifndef __FreeBSD__
status = TAPE_GetStatus( ioctl( fd, MTIOCPOS, &pos ) );
if (status != STATUS_SUCCESS)
return status;
+#endif
switch (type)
{
case TAPE_ABSOLUTE_BLOCK:
data->Type = type;
data->Partition = get.mt_resid;
+#ifdef __FreeBSD__
+ data->OffsetLow = get.mt_blkno;
+#else
data->OffsetLow = pos.mt_blkno;
+#endif
case TAPE_LOGICAL_BLOCK:
case TAPE_PSEUDO_LOGICAL_BLOCK:
WARN( "Positioning type not supported\n" );
@@ -269,21 +284,31 @@ static NTSTATUS TAPE_Prepare( int fd, TA
switch (data->Operation)
{
+#ifdef MTLOAD
case TAPE_LOAD:
cmd.mt_op = MTLOAD;
break;
+#endif
+#ifdef MTUNLOAD
case TAPE_UNLOAD:
cmd.mt_op = MTUNLOAD;
break;
+#endif
+#ifdef MTRETEN
case TAPE_TENSION:
cmd.mt_op = MTRETEN;
break;
+#endif
+#ifdef MTLOCK
case TAPE_LOCK:
cmd.mt_op = MTLOCK;
break;
+#endif
+#ifdef MTUNLOCK
case TAPE_UNLOCK:
cmd.mt_op = MTUNLOCK;
break;
+#endif
case TAPE_FORMAT:
/* Native ignores this if the drive doesn't support it */
return STATUS_SUCCESS;
@@ -364,13 +389,17 @@ static NTSTATUS TAPE_SetPosition( int fd
case TAPE_REWIND:
cmd.mt_op = MTREW;
break;
+#ifdef MTSEEK
case TAPE_ABSOLUTE_BLOCK:
cmd.mt_op = MTSEEK;
cmd.mt_count = data->Offset.u.LowPart;
break;
+#endif
+#ifdef MTEOM
case TAPE_SPACE_END_OF_DATA:
cmd.mt_op = MTEOM;
break;
+#endif
case TAPE_SPACE_FILEMARKS:
if (data->Offset.u.LowPart >= 0) {
cmd.mt_op = MTFSF;
@@ -421,10 +450,12 @@ static NTSTATUS TAPE_WriteMarks( int fd,
switch (data->Type)
{
+#ifdef MTWSM
case TAPE_SETMARKS:
cmd.mt_op = MTWSM;
cmd.mt_count = data->Count;
break;
+#endif
case TAPE_FILEMARKS:
case TAPE_SHORT_FILEMARKS:
case TAPE_LONG_FILEMARKS:
More information about the wine-patches
mailing list