ReactOS 0.4.15-dev-8127-g6338913
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);
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}
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CloseHandle
Definition: compat.h:739
#define INFINITE
Definition: serial.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ __in WDFIOTARGET __in_opt WDFREQUEST __in ULONG Ioctl
Status
Definition: gdiplustypes.h:25
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
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)
#define STATUS_PENDING
Definition: ntstatus.h:82
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
@ Input
Definition: arc.h:84
@ Output
Definition: arc.h:85
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CreateEvent
Definition: winbase.h:3748

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{
85 TAPE_CREATE_PARTITION TapeCreatePartition;
86
87 TapeCreatePartition.Method = dwPartitionMethod;
88 TapeCreatePartition.Count = dwCount;
89 TapeCreatePartition.Size = dwSize;
90 return BasepDoTapeOperation(hDevice,
92 &TapeCreatePartition,
93 sizeof(TapeCreatePartition),
94 NULL,
95 0);
96}
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define IOCTL_TAPE_CREATE_PARTITION
Definition: ntddtape.h:38
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

◆ EraseTape()

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

Definition at line 103 of file tape.c.

106{
107 TAPE_ERASE TapeErase;
108
109 TapeErase.Type = dwEraseType;
110 TapeErase.Immediate = (BOOLEAN)bImmediate;
111 return BasepDoTapeOperation(hDevice,
113 &TapeErase,
114 sizeof(TapeErase),
115 NULL,
116 0);
117}
#define IOCTL_TAPE_ERASE
Definition: ntddtape.h:39
#define BOOLEAN
Definition: pedump.c:73
DWORD Type
Definition: winnt_old.h:2540
BOOLEAN Immediate
Definition: winnt_old.h:2541

◆ 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,
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,
158 }
159
161}
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
static DWORD LPSTR PDWORD lpdwSize
Definition: process.c:72
#define IOCTL_TAPE_GET_MEDIA_PARAMS
Definition: ntddtape.h:42
#define IOCTL_TAPE_GET_DRIVE_PARAMS
Definition: ntddtape.h:41
#define GET_TAPE_DRIVE_INFORMATION
Definition: winbase.h:272
#define GET_TAPE_MEDIA_INFORMATION
Definition: winbase.h:271
struct _TAPE_GET_MEDIA_PARAMETERS TAPE_GET_MEDIA_PARAMETERS
struct _TAPE_GET_DRIVE_PARAMETERS TAPE_GET_DRIVE_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{
174 TAPE_GET_POSITION TapeGetPosition;
176
177 TapeGetPosition.Type = dwPositionType;
180 &TapeGetPosition,
181 sizeof(TapeGetPosition),
182 &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}
#define IOCTL_TAPE_GET_POSITION
Definition: ntddtape.h:43
LARGE_INTEGER Offset
Definition: winnt_old.h:2569
struct _LARGE_INTEGER::@2300 u
_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:409

◆ 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

◆ PrepareTape()

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

Definition at line 221 of file tape.c.

224{
225 TAPE_PREPARE TapePrepare;
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
DWORD Operation
Definition: winnt_old.h:2573
BOOLEAN Immediate
Definition: winnt_old.h:2574

◆ 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
266}
#define IOCTL_TAPE_SET_MEDIA_PARAMS
Definition: ntddtape.h:48
#define IOCTL_TAPE_SET_DRIVE_PARAMS
Definition: ntddtape.h:47
#define SET_TAPE_MEDIA_INFORMATION
Definition: winbase.h:273
#define SET_TAPE_DRIVE_INFORMATION
Definition: winbase.h:274

◆ 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{
280 TAPE_SET_POSITION TapeSetPosition;
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,
289 &TapeSetPosition,
290 sizeof(TapeSetPosition),
291 NULL,
292 0);
293}
#define IOCTL_TAPE_SET_POSITION
Definition: ntddtape.h:49
LARGE_INTEGER Offset
Definition: winnt_old.h:2592

◆ 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{
305 TAPE_WRITE_MARKS TapeWriteMarks;
306
307 TapeWriteMarks.Type = dwTapemarkType;
308 TapeWriteMarks.Count = dwTapemarkCount;
309 TapeWriteMarks.Immediate = (BOOLEAN)bImmediate;
310 return BasepDoTapeOperation(hDevice,
312 &TapeWriteMarks,
313 sizeof(TapeWriteMarks),
314 NULL,
315 0);
316}
#define IOCTL_TAPE_WRITE_MARKS
Definition: ntddtape.h:50