ReactOS  0.4.14-dev-41-g31d7680
tape.c File Reference
#include <k32.h>
#include <debug.h>
Include dependency graph for tape.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

DWORD WINAPI BasepDoTapeOperation (IN HANDLE DeviceHandle, IN ULONG Ioctl, IN PVOID Input, IN ULONG InputLength, IN PVOID Output, IN ULONG OutputLength)
 
DWORD WINAPI CreateTapePartition (IN HANDLE hDevice, IN DWORD dwPartitionMethod, IN DWORD dwCount, IN DWORD dwSize)
 
DWORD WINAPI EraseTape (IN HANDLE hDevice, IN DWORD dwEraseType, IN BOOL bImmediate)
 
DWORD WINAPI GetTapeParameters (IN HANDLE hDevice, IN DWORD dwOperation, IN LPDWORD lpdwSize, IN LPVOID lpTapeInformation)
 
DWORD WINAPI GetTapePosition (IN HANDLE hDevice, IN DWORD dwPositionType, IN LPDWORD lpdwPartition, IN LPDWORD lpdwOffsetLow, IN LPDWORD lpdwOffsetHigh)
 
DWORD WINAPI GetTapeStatus (IN HANDLE hDevice)
 
DWORD WINAPI PrepareTape (IN HANDLE hDevice, IN DWORD dwOperation, IN BOOL bImmediate)
 
DWORD WINAPI SetTapeParameters (IN HANDLE hDevice, IN DWORD dwOperation, IN LPVOID lpTapeInformation)
 
DWORD WINAPI SetTapePosition (IN HANDLE hDevice, IN DWORD dwPositionMethod, IN DWORD dwPartition, IN DWORD dwOffsetLow, IN DWORD dwOffsetHigh, IN BOOL bImmediate)
 
DWORD WINAPI WriteTapemark (IN HANDLE hDevice, IN DWORD dwTapemarkType, IN DWORD dwTapemarkCount, IN BOOL bImmediate)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file tape.c.

Function Documentation

◆ BasepDoTapeOperation()

DWORD WINAPI BasepDoTapeOperation ( IN HANDLE  DeviceHandle,
IN ULONG  Ioctl,
IN PVOID  Input,
IN ULONG  InputLength,
IN PVOID  Output,
IN ULONG  OutputLength 
)

Definition at line 21 of file tape.c.

27 {
28  HANDLE TapeEvent;
32 
33  /* Create the wait event */
34  TapeEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
35  if (!TapeEvent) return GetLastError();
36 
37  /* Send the IOCTL */
39  TapeEvent,
40  0,
41  0,
43  Ioctl,
44  Input,
45  InputLength,
46  Output,
47  OutputLength);
48  if (Status == STATUS_PENDING)
49  {
50  /* Wait for its completion */
51  WaitForSingleObject(TapeEvent, INFINITE);
53  }
54 
55  /* Get rid of the wait event and check status */
56  CloseHandle(TapeEvent);
57  if (!NT_SUCCESS(Status))
58  {
59  /* Convert to Win32 */
62  }
63  else
64  {
65  /* Set success */
67  }
68 
69  /* Return the Win32 error code */
70  return ErrorCode;
71 }
#define CreateEvent
Definition: winbase.h:3565
#define CloseHandle
Definition: compat.h:398
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG NTSTATUS
Definition: precomp.h:26
Definition: arc.h:84
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: arc.h:85
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define INFINITE
Definition: serial.h:102

Referenced by CreateTapePartition(), EraseTape(), GetTapeParameters(), GetTapePosition(), GetTapeStatus(), PrepareTape(), SetTapeParameters(), SetTapePosition(), and WriteTapemark().

◆ CreateTapePartition()

DWORD WINAPI CreateTapePartition ( IN HANDLE  hDevice,
IN DWORD  dwPartitionMethod,
IN DWORD  dwCount,
IN DWORD  dwSize 
)

Definition at line 80 of file tape.c.

84 {
86 
87  TapeCreatePartition.Method = dwPartitionMethod;
88  TapeCreatePartition.Count = dwCount;
90  return BasepDoTapeOperation(hDevice,
93  sizeof(TapeCreatePartition),
94  NULL,
95  0);
96 }
NTSTATUS TapeCreatePartition(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
#define IOCTL_TAPE_CREATE_PARTITION
Definition: ntddtape.h:38
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI BasepDoTapeOperation(IN HANDLE DeviceHandle, IN ULONG Ioctl, IN PVOID Input, IN ULONG InputLength, IN PVOID Output, IN ULONG OutputLength)
Definition: tape.c:21
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

◆ EraseTape()

DWORD WINAPI EraseTape ( IN HANDLE  hDevice,
IN DWORD  dwEraseType,
IN BOOL  bImmediate 
)

Definition at line 103 of file tape.c.

106 {
108 
109  TapeErase.Type = dwEraseType;
110  TapeErase.Immediate = (BOOLEAN)bImmediate;
111  return BasepDoTapeOperation(hDevice,
113  &TapeErase,
114  sizeof(TapeErase),
115  NULL,
116  0);
117 }
NTSTATUS TapeErase(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI BasepDoTapeOperation(IN HANDLE DeviceHandle, IN ULONG Ioctl, IN PVOID Input, IN ULONG InputLength, IN PVOID Output, IN ULONG OutputLength)
Definition: tape.c:21
#define IOCTL_TAPE_ERASE
Definition: ntddtape.h:39
#define BOOLEAN
Definition: pedump.c:73

◆ GetTapeParameters()

DWORD WINAPI GetTapeParameters ( IN HANDLE  hDevice,
IN DWORD  dwOperation,
IN LPDWORD  lpdwSize,
IN LPVOID  lpTapeInformation 
)

Definition at line 124 of file tape.c.

128 {
129  if (dwOperation == GET_TAPE_MEDIA_INFORMATION)
130  {
131  if (*lpdwSize < sizeof(TAPE_GET_MEDIA_PARAMETERS))
132  {
134  return ERROR_MORE_DATA;
135  }
136 
137  return BasepDoTapeOperation(hDevice,
139  NULL,
140  0,
141  lpTapeInformation,
142  sizeof(TAPE_GET_MEDIA_PARAMETERS));
143  }
144  else if (dwOperation == GET_TAPE_DRIVE_INFORMATION)
145  {
146  if (*lpdwSize < sizeof(TAPE_GET_DRIVE_PARAMETERS))
147  {
149  return ERROR_MORE_DATA;
150  }
151 
152  return BasepDoTapeOperation(hDevice,
154  NULL,
155  0,
156  lpTapeInformation,
157  sizeof(TAPE_GET_DRIVE_PARAMETERS));
158  }
159 
160  return ERROR_INVALID_FUNCTION;
161 }
#define IOCTL_TAPE_GET_MEDIA_PARAMS
Definition: ntddtape.h:42
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define IOCTL_TAPE_GET_DRIVE_PARAMS
Definition: ntddtape.h:41
smooth NULL
Definition: ftsmooth.c:416
#define GET_TAPE_DRIVE_INFORMATION
Definition: winbase.h:269
DWORD WINAPI BasepDoTapeOperation(IN HANDLE DeviceHandle, IN ULONG Ioctl, IN PVOID Input, IN ULONG InputLength, IN PVOID Output, IN ULONG OutputLength)
Definition: tape.c:21
#define ERROR_MORE_DATA
Definition: dderror.h:13
static DWORD LPSTR PDWORD lpdwSize
Definition: process.c:72
struct _TAPE_GET_DRIVE_PARAMETERS TAPE_GET_DRIVE_PARAMETERS
#define GET_TAPE_MEDIA_INFORMATION
Definition: winbase.h:268
struct _TAPE_GET_MEDIA_PARAMETERS TAPE_GET_MEDIA_PARAMETERS

◆ GetTapePosition()

DWORD WINAPI GetTapePosition ( IN HANDLE  hDevice,
IN DWORD  dwPositionType,
IN LPDWORD  lpdwPartition,
IN LPDWORD  lpdwOffsetLow,
IN LPDWORD  lpdwOffsetHigh 
)

Definition at line 168 of file tape.c.

173 {
175  DWORD Result;
176 
177  TapeGetPosition.Type = dwPositionType;
178  Result = BasepDoTapeOperation(hDevice,
181  sizeof(TapeGetPosition),
183  sizeof(TapeGetPosition));
184 
185  if (Result)
186  {
187  *lpdwPartition = 0;
188  *lpdwOffsetLow = 0;
189  *lpdwOffsetHigh = 0;
190  }
191  else
192  {
193  *lpdwPartition = TapeGetPosition.Partition;
194  *lpdwOffsetLow = TapeGetPosition.Offset.u.LowPart;
195  *lpdwOffsetHigh = TapeGetPosition.Offset.u.HighPart;
196  }
197 
198  return Result;
199 }
NTSTATUS TapeGetPosition(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
DWORD WINAPI BasepDoTapeOperation(IN HANDLE DeviceHandle, IN ULONG Ioctl, IN PVOID Input, IN ULONG InputLength, IN PVOID Output, IN ULONG OutputLength)
Definition: tape.c:21
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IOCTL_TAPE_GET_POSITION
Definition: ntddtape.h:43

◆ GetTapeStatus()

DWORD WINAPI GetTapeStatus ( IN HANDLE  hDevice)

Definition at line 206 of file tape.c.

207 {
208  return BasepDoTapeOperation(hDevice,
210  NULL,
211  0,
212  NULL,
213  0);
214 }
#define IOCTL_TAPE_GET_STATUS
Definition: ntddtape.h:44
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI BasepDoTapeOperation(IN HANDLE DeviceHandle, IN ULONG Ioctl, IN PVOID Input, IN ULONG InputLength, IN PVOID Output, IN ULONG OutputLength)
Definition: tape.c:21

◆ PrepareTape()

DWORD WINAPI PrepareTape ( IN HANDLE  hDevice,
IN DWORD  dwOperation,
IN BOOL  bImmediate 
)

Definition at line 221 of file tape.c.

224 {
226 
227  TapePrepare.Operation = dwOperation;
228  TapePrepare.Immediate = (BOOLEAN)bImmediate;
229  return BasepDoTapeOperation(hDevice,
231  &TapePrepare,
232  sizeof(TapePrepare),
233  NULL,
234  0);
235 }
#define IOCTL_TAPE_PREPARE
Definition: ntddtape.h:46
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS TapePrepare(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
DWORD WINAPI BasepDoTapeOperation(IN HANDLE DeviceHandle, IN ULONG Ioctl, IN PVOID Input, IN ULONG InputLength, IN PVOID Output, IN ULONG OutputLength)
Definition: tape.c:21
#define BOOLEAN
Definition: pedump.c:73

◆ SetTapeParameters()

DWORD WINAPI SetTapeParameters ( IN HANDLE  hDevice,
IN DWORD  dwOperation,
IN LPVOID  lpTapeInformation 
)

Definition at line 242 of file tape.c.

245 {
246  if (dwOperation == SET_TAPE_MEDIA_INFORMATION)
247  {
248  return BasepDoTapeOperation(hDevice,
250  lpTapeInformation,
252  NULL,
253  0);
254  }
255  else if (dwOperation == SET_TAPE_DRIVE_INFORMATION)
256  {
257  return BasepDoTapeOperation(hDevice,
259  lpTapeInformation,
261  NULL,
262  0);
263  }
264 
265  return ERROR_INVALID_FUNCTION;
266 }
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define IOCTL_TAPE_SET_MEDIA_PARAMS
Definition: ntddtape.h:48
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI BasepDoTapeOperation(IN HANDLE DeviceHandle, IN ULONG Ioctl, IN PVOID Input, IN ULONG InputLength, IN PVOID Output, IN ULONG OutputLength)
Definition: tape.c:21
#define IOCTL_TAPE_SET_DRIVE_PARAMS
Definition: ntddtape.h:47
#define SET_TAPE_DRIVE_INFORMATION
Definition: winbase.h:271
#define SET_TAPE_MEDIA_INFORMATION
Definition: winbase.h:270

◆ SetTapePosition()

DWORD WINAPI SetTapePosition ( IN HANDLE  hDevice,
IN DWORD  dwPositionMethod,
IN DWORD  dwPartition,
IN DWORD  dwOffsetLow,
IN DWORD  dwOffsetHigh,
IN BOOL  bImmediate 
)

Definition at line 273 of file tape.c.

279 {
281 
282  TapeSetPosition.Method = dwPositionMethod;
283  TapeSetPosition.Partition = dwPartition;
284  TapeSetPosition.Offset.u.LowPart = dwOffsetLow;
285  TapeSetPosition.Offset.u.HighPart = dwOffsetHigh;
286  TapeSetPosition.Immediate = (BOOLEAN)bImmediate;
287  return BasepDoTapeOperation(hDevice,
290  sizeof(TapeSetPosition),
291  NULL,
292  0);
293 }
NTSTATUS TapeSetPosition(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
#define IOCTL_TAPE_SET_POSITION
Definition: ntddtape.h:49
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI BasepDoTapeOperation(IN HANDLE DeviceHandle, IN ULONG Ioctl, IN PVOID Input, IN ULONG InputLength, IN PVOID Output, IN ULONG OutputLength)
Definition: tape.c:21
#define BOOLEAN
Definition: pedump.c:73

◆ WriteTapemark()

DWORD WINAPI WriteTapemark ( IN HANDLE  hDevice,
IN DWORD  dwTapemarkType,
IN DWORD  dwTapemarkCount,
IN BOOL  bImmediate 
)

Definition at line 300 of file tape.c.

304 {
306 
307  TapeWriteMarks.Type = dwTapemarkType;
308  TapeWriteMarks.Count = dwTapemarkCount;
309  TapeWriteMarks.Immediate = (BOOLEAN)bImmediate;
310  return BasepDoTapeOperation(hDevice,
313  sizeof(TapeWriteMarks),
314  NULL,
315  0);
316 }
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS TapeWriteMarks(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
DWORD WINAPI BasepDoTapeOperation(IN HANDLE DeviceHandle, IN ULONG Ioctl, IN PVOID Input, IN ULONG InputLength, IN PVOID Output, IN ULONG OutputLength)
Definition: tape.c:21
#define IOCTL_TAPE_WRITE_MARKS
Definition: ntddtape.h:50
#define BOOLEAN
Definition: pedump.c:73