Implement tape IO functions.

svn path=/trunk/; revision=9078
This commit is contained in:
Eric Kohl 2004-04-10 23:20:17 +00:00
parent dbb520a63f
commit eddb2f5168
4 changed files with 435 additions and 124 deletions

View file

@ -1,6 +1,6 @@
#ifndef _NTOS_H
#define _NTOS_H
/* $Id: ntos.h,v 1.20 2004/01/23 21:18:27 ekohl Exp $ */
/* $Id: ntos.h,v 1.21 2004/04/10 23:19:42 ekohl Exp $ */
#if defined(NTOS_MODE_USER)
/*
@ -14,6 +14,7 @@
#include "ntos/cdrom.h"
#include "ntos/console.h"
#include "ntos/disk.h"
#include "ntos/tape.h"
#include "ntos/except.h"
#include "ntos/file.h"
#include "ntos/gditypes.h"
@ -55,6 +56,7 @@
#include "ntos/cdrom.h"
#include "ntos/console.h"
#include "ntos/disk.h"
#include "ntos/tape.h"
#include "ntos/except.h"
#include "ntos/file.h"
#include "ntos/gditypes.h"

View file

@ -0,0 +1,57 @@
/* $Id: tape.h,v 1.1 2004/04/10 23:18:42 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/ntos/tape.h
* PURPOSE: Tape drive definitions
* PROGRAMMER: Eric Kohl
*/
#ifndef __INCLUDE_TAPE_H
#define __INCLUDE_TAPE_H
#define IOCTL_TAPE_BASE FILE_DEVICE_TAPE
#define IOCTL_TAPE_CHECK_VERIFY \
CTL_CODE(IOCTL_TAPE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_TAPE_CREATE_PARTITION \
CTL_CODE(IOCTL_TAPE_BASE, 0x000a, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_TAPE_ERASE \
CTL_CODE(IOCTL_TAPE_BASE, 0x0000, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_TAPE_FIND_NEW_DEVICES \
CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_TAPE_GET_DRIVE_PARAMS \
CTL_CODE(IOCTL_TAPE_BASE, 0x0005, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_TAPE_GET_MEDIA_PARAMS \
CTL_CODE(IOCTL_TAPE_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_TAPE_GET_POSITION \
CTL_CODE(IOCTL_TAPE_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_TAPE_GET_STATUS \
CTL_CODE(IOCTL_TAPE_BASE, 0x0009, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_TAPE_PREPARE \
CTL_CODE(IOCTL_TAPE_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_TAPE_SET_DRIVE_PARAMS \
CTL_CODE(IOCTL_TAPE_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_TAPE_SET_MEDIA_PARAMS \
CTL_CODE(IOCTL_TAPE_BASE, 0x0008, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_TAPE_SET_POSITION \
CTL_CODE(IOCTL_TAPE_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS)
#define IOCTL_TAPE_WRITE_MARKS \
CTL_CODE(IOCTL_TAPE_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#endif /* __INCLUDE_TAPE_H */

View file

@ -5285,65 +5285,74 @@ typedef struct _SYSTEM_POWER_STATUS {
} SYSTEM_POWER_STATUS;
typedef SYSTEM_POWER_STATUS *LPSYSTEM_POWER_STATUS;
typedef struct _TAPE_CREATE_PARTITION {
ULONG Method;
ULONG Count;
ULONG Size;
} TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
typedef struct _TAPE_ERASE {
ULONG Type;
} TAPE_ERASE;
BOOLEAN Immediate;
} TAPE_ERASE, *PTAPE_ERASE;
typedef struct _TAPE_GET_DRIVE_PARAMETERS {
BOOLEAN ECC;
BOOLEAN Compression;
BOOLEAN DataPadding;
BOOLEAN ReportSetmarks;
ULONG DefaultBlockSize;
ULONG MaximumBlockSize;
ULONG MinimumBlockSize;
ULONG MaximumPartitionCount;
ULONG FeaturesLow;
ULONG FeaturesHigh;
ULONG EOTWarningZoneSize;
} TAPE_GET_DRIVE_PARAMETERS;
ULONG DefaultBlockSize;
ULONG MaximumBlockSize;
ULONG MinimumBlockSize;
ULONG MaximumPartitionCount;
ULONG FeaturesLow;
ULONG FeaturesHigh;
ULONG EOTWarningZoneSize;
} TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
typedef struct _TAPE_GET_MEDIA_PARAMETERS {
LARGE_INTEGER Capacity;
LARGE_INTEGER Remaining;
DWORD BlockSize;
DWORD PartitionCount;
LARGE_INTEGER Capacity;
LARGE_INTEGER Remaining;
ULONG BlockSize;
ULONG PartitionCount;
BOOLEAN WriteProtected;
} TAPE_GET_MEDIA_PARAMETERS;
} TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
typedef struct _TAPE_GET_POSITION {
ULONG Type;
ULONG Partition;
LARGE_INTEGER Offset;
} TAPE_GET_POSITION;
} TAPE_GET_POSITION, *PTAPE_GET_POSITION;
typedef struct _TAPE_PREPARE {
ULONG Operation;
} TAPE_PREPARE;
BOOLEAN Immediate;
} TAPE_PREPARE, *PTAPE_PREPARE;
typedef struct _TAPE_SET_DRIVE_PARAMETERS {
BOOLEAN ECC;
BOOLEAN Compression;
BOOLEAN DataPadding;
BOOLEAN ReportSetmarks;
ULONG EOTWarningZoneSize;
} TAPE_SET_DRIVE_PARAMETERS;
ULONG EOTWarningZoneSize;
} TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
typedef struct _TAPE_SET_MEDIA_PARAMETERS {
ULONG BlockSize;
} TAPE_SET_MEDIA_PARAMETERS;
} TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS;
typedef struct _TAPE_SET_POSITION {
ULONG Method;
ULONG Partition;
LARGE_INTEGER Offset;
BOOLEAN Immediate;
} TAPE_SET_POSITION;
} TAPE_SET_POSITION, *PTAPE_SET_POSITION;
typedef struct _TAPE_WRITE_MARKS {
ULONG Type;
ULONG Count;
} TAPE_WRITE_MARKS;
BOOLEAN Immediate;
} TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
typedef struct {
HINSTANCE hInst;

View file

@ -1,11 +1,10 @@
/* $Id: tape.c,v 1.7 2004/01/23 21:16:03 ekohl Exp $
/* $Id: tape.c,v 1.8 2004/04/10 23:20:17 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/kernel32/file/tape.c
* PURPOSE: Tape functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
* GetTempFileName is modified from WINE [ Alexandre Juiliard ]
* UPDATE HISTORY:
* Created 01/11/98
*/
@ -20,151 +19,395 @@
/* FUNCTIONS ****************************************************************/
/*
* @unimplemented
* @implemented
*/
DWORD
STDCALL
CreateTapePartition (
HANDLE hDevice,
DWORD dwPartitionMethod,
DWORD dwCount,
DWORD dwSize
)
DWORD STDCALL
CreateTapePartition (HANDLE hDevice,
DWORD dwPartitionMethod,
DWORD dwCount,
DWORD dwSize)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
TAPE_CREATE_PARTITION TapeCreatePartition;
IO_STATUS_BLOCK IoStatusBlock;
DWORD ErrorCode;
NTSTATUS Status;
TapeCreatePartition.Method = dwPartitionMethod;
TapeCreatePartition.Count = dwCount;
TapeCreatePartition.Size = dwSize;
Status = NtDeviceIoControlFile (hDevice,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_TAPE_CREATE_PARTITION,
&TapeCreatePartition,
sizeof(TAPE_CREATE_PARTITION),
NULL,
0);
if (!NT_SUCCESS(Status))
{
ErrorCode = RtlNtStatusToDosError(Status);
SetLastError (ErrorCode);
return ErrorCode;
}
return ERROR_SUCCESS;
}
/*
* @unimplemented
* @implemented
*/
DWORD
STDCALL
EraseTape (
HANDLE hDevice,
DWORD dwEraseType,
BOOL bImmediate
)
DWORD STDCALL
EraseTape (HANDLE hDevice,
DWORD dwEraseType,
BOOL bImmediate)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
TAPE_ERASE TapeErase;
IO_STATUS_BLOCK IoStatusBlock;
DWORD ErrorCode;
NTSTATUS Status;
/*
* @unimplemented
*/
DWORD
STDCALL
GetTapeParameters (
HANDLE hDevice,
DWORD dwOperation,
LPDWORD lpdwSize,
LPVOID lpTapeInformation
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
TapeErase.Type = dwEraseType;
TapeErase.Immediate = (BOOLEAN)bImmediate;
Status = NtDeviceIoControlFile (hDevice,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_TAPE_ERASE,
&TapeErase,
sizeof(TAPE_ERASE),
NULL,
0);
if (!NT_SUCCESS(Status))
{
ErrorCode = RtlNtStatusToDosError(Status);
SetLastError (ErrorCode);
return ErrorCode;
}
return ERROR_SUCCESS;
}
/*
* @unimplemented
* @implemented
*/
DWORD
STDCALL
GetTapeStatus (
HANDLE hDevice
)
DWORD STDCALL
GetTapeParameters (HANDLE hDevice,
DWORD dwOperation,
LPDWORD lpdwSize,
LPVOID lpTapeInformation)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
IO_STATUS_BLOCK IoStatusBlock;
DWORD ErrorCode;
NTSTATUS Status;
if (dwOperation == GET_TAPE_MEDIA_INFORMATION)
{
if (*lpdwSize < sizeof(TAPE_GET_MEDIA_PARAMETERS))
{
*lpdwSize = sizeof(TAPE_GET_MEDIA_PARAMETERS);
return ERROR_MORE_DATA;
}
Status = NtDeviceIoControlFile (hDevice,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_TAPE_GET_MEDIA_PARAMS,
NULL,
0,
lpTapeInformation,
sizeof(TAPE_GET_MEDIA_PARAMETERS));
}
else if (dwOperation == GET_TAPE_DRIVE_INFORMATION)
{
if (*lpdwSize < sizeof(TAPE_GET_DRIVE_PARAMETERS))
{
*lpdwSize = sizeof(TAPE_GET_DRIVE_PARAMETERS);
return ERROR_MORE_DATA;
}
Status = NtDeviceIoControlFile (hDevice,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_TAPE_GET_DRIVE_PARAMS,
NULL,
0,
lpTapeInformation,
sizeof(TAPE_GET_DRIVE_PARAMETERS));
}
else
{
return ERROR_INVALID_FUNCTION;
}
if (!NT_SUCCESS(Status))
{
ErrorCode = RtlNtStatusToDosError(Status);
SetLastError (ErrorCode);
return ErrorCode;
}
return ERROR_SUCCESS;
}
/*
* @unimplemented
* @implemented
*/
DWORD
STDCALL
PrepareTape (
HANDLE hDevice,
DWORD dwOperation,
BOOL bImmediate
)
DWORD STDCALL
GetTapePosition (HANDLE hDevice,
DWORD dwPositionType,
LPDWORD lpdwPartition,
LPDWORD lpdwOffsetLow,
LPDWORD lpdwOffsetHigh)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
TAPE_GET_POSITION TapeGetPosition;
IO_STATUS_BLOCK IoStatusBlock;
DWORD ErrorCode;
NTSTATUS Status;
TapeGetPosition.Type = dwPositionType;
Status = NtDeviceIoControlFile (hDevice,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_TAPE_GET_POSITION,
&TapeGetPosition,
sizeof(TAPE_GET_POSITION),
&TapeGetPosition,
sizeof(TAPE_GET_POSITION));
if (!NT_SUCCESS(Status))
{
*lpdwPartition = 0;
*lpdwOffsetLow = 0;
*lpdwOffsetHigh = 0;
ErrorCode = RtlNtStatusToDosError(Status);
SetLastError (ErrorCode);
return ErrorCode;
}
*lpdwPartition = TapeGetPosition.Partition;
*lpdwOffsetLow = TapeGetPosition.Offset.u.LowPart;
*lpdwOffsetHigh = TapeGetPosition.Offset.u.HighPart;
return ERROR_SUCCESS;
}
/*
* @unimplemented
* @implemented
*/
DWORD
STDCALL
SetTapeParameters (
HANDLE hDevice,
DWORD dwOperation,
LPVOID lpTapeInformation
)
DWORD STDCALL
GetTapeStatus (HANDLE hDevice)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
IO_STATUS_BLOCK IoStatusBlock;
DWORD ErrorCode;
NTSTATUS Status;
Status = NtDeviceIoControlFile (hDevice,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_TAPE_GET_STATUS,
NULL,
0,
NULL,
0);
if (!NT_SUCCESS(Status))
{
ErrorCode = RtlNtStatusToDosError(Status);
SetLastError (ErrorCode);
return ErrorCode;
}
return ERROR_SUCCESS;
}
/*
* @unimplemented
* @implemented
*/
DWORD
STDCALL
SetTapePosition (
HANDLE hDevice,
DWORD dwPositionMethod,
DWORD dwPartition,
DWORD dwOffsetLow,
DWORD dwOffsetHigh,
BOOL bImmediate
)
DWORD STDCALL
PrepareTape (HANDLE hDevice,
DWORD dwOperation,
BOOL bImmediate)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
TAPE_PREPARE TapePrepare;
IO_STATUS_BLOCK IoStatusBlock;
DWORD ErrorCode;
NTSTATUS Status;
TapePrepare.Operation = dwOperation;
TapePrepare.Immediate = (BOOLEAN)bImmediate;
Status = NtDeviceIoControlFile (hDevice,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_TAPE_PREPARE,
&TapePrepare,
sizeof(TAPE_PREPARE),
NULL,
0);
if (!NT_SUCCESS(Status))
{
ErrorCode = RtlNtStatusToDosError(Status);
SetLastError (ErrorCode);
return ErrorCode;
}
return ERROR_SUCCESS;
}
/*
* @unimplemented
* @implemented
*/
DWORD
STDCALL
WriteTapemark (
HANDLE hDevice,
DWORD dwTapemarkType,
DWORD dwTapemarkCount,
BOOL bImmediate
)
DWORD STDCALL
SetTapeParameters (HANDLE hDevice,
DWORD dwOperation,
LPVOID lpTapeInformation)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
IO_STATUS_BLOCK IoStatusBlock;
DWORD ErrorCode;
NTSTATUS Status;
if (dwOperation == SET_TAPE_MEDIA_INFORMATION)
{
Status = NtDeviceIoControlFile (hDevice,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_TAPE_SET_MEDIA_PARAMS,
lpTapeInformation,
sizeof(TAPE_SET_MEDIA_PARAMETERS),
NULL,
0);
}
else if (dwOperation == SET_TAPE_DRIVE_INFORMATION)
{
Status = NtDeviceIoControlFile (hDevice,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_TAPE_SET_DRIVE_PARAMS,
lpTapeInformation,
sizeof(TAPE_SET_DRIVE_PARAMETERS),
NULL,
0);
}
else
{
return ERROR_INVALID_FUNCTION;
}
if (!NT_SUCCESS(Status))
{
ErrorCode = RtlNtStatusToDosError(Status);
SetLastError (ErrorCode);
return ErrorCode;
}
return ERROR_SUCCESS;
}
/*
* @unimplemented
* @implemented
*/
DWORD
STDCALL
GetTapePosition (
HANDLE hDevice,
DWORD dwPositionType,
LPDWORD lpdwPartition,
LPDWORD lpdwOffsetLow,
LPDWORD lpdwOffsetHigh
)
DWORD STDCALL
SetTapePosition (HANDLE hDevice,
DWORD dwPositionMethod,
DWORD dwPartition,
DWORD dwOffsetLow,
DWORD dwOffsetHigh,
BOOL bImmediate)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
TAPE_SET_POSITION TapeSetPosition;
IO_STATUS_BLOCK IoStatusBlock;
DWORD ErrorCode;
NTSTATUS Status;
TapeSetPosition.Method = dwPositionMethod;
TapeSetPosition.Partition = dwPartition;
TapeSetPosition.Offset.u.LowPart = dwOffsetLow;
TapeSetPosition.Offset.u.HighPart = dwOffsetHigh;
TapeSetPosition.Immediate = (BOOLEAN)bImmediate;
Status = NtDeviceIoControlFile (hDevice,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_TAPE_SET_POSITION,
&TapeSetPosition,
sizeof(TAPE_SET_POSITION),
NULL,
0);
if (!NT_SUCCESS(Status))
{
ErrorCode = RtlNtStatusToDosError(Status);
SetLastError (ErrorCode);
return ErrorCode;
}
return ERROR_SUCCESS;
}
/*
* @implemented
*/
DWORD STDCALL
WriteTapemark (HANDLE hDevice,
DWORD dwTapemarkType,
DWORD dwTapemarkCount,
BOOL bImmediate)
{
TAPE_WRITE_MARKS TapeWriteMarks;
IO_STATUS_BLOCK IoStatusBlock;
DWORD ErrorCode;
NTSTATUS Status;
TapeWriteMarks.Type = dwTapemarkType;
TapeWriteMarks.Count = dwTapemarkCount;
TapeWriteMarks.Immediate = (BOOLEAN)bImmediate;
Status = NtDeviceIoControlFile (hDevice,
NULL,
NULL,
NULL,
&IoStatusBlock,
IOCTL_TAPE_WRITE_MARKS,
&TapeWriteMarks,
sizeof(TAPE_WRITE_MARKS),
NULL,
0);
if (!NT_SUCCESS(Status))
{
ErrorCode = RtlNtStatusToDosError(Status);
SetLastError (ErrorCode);
return ErrorCode;
}
return ERROR_SUCCESS;
}
/* EOF */