ReactOS 0.4.15-dev-7660-g0086d05
tape.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: dll/win32/kernel32/client/file/tape.c
5 * PURPOSE: Tape functions
6 * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
7 * UPDATE HISTORY:
8 * Created 01/11/98
9 */
10
11/* INCLUDES *******************************************************************/
12
13#include <k32.h>
14#define NDEBUG
15#include <debug.h>
16
17/* PRIVATE FUNCTIONS **********************************************************/
18
24 IN ULONG InputLength,
26 IN ULONG OutputLength)
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}
72
73/* PUBLIC FUNCTIONS ***********************************************************/
74
75/*
76 * @implemented
77 */
81 IN DWORD dwPartitionMethod,
82 IN DWORD dwCount,
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}
97
98/*
99 * @implemented
100 */
101DWORD
102WINAPI
104 IN DWORD dwEraseType,
105 IN BOOL bImmediate)
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}
118
119/*
120 * @implemented
121 */
122DWORD
123WINAPI
125 IN DWORD dwOperation,
127 IN LPVOID lpTapeInformation)
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}
162
163/*
164 * @implemented
165 */
166DWORD
167WINAPI
169 IN DWORD dwPositionType,
170 IN LPDWORD lpdwPartition,
171 IN LPDWORD lpdwOffsetLow,
172 IN LPDWORD lpdwOffsetHigh)
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}
200
201/*
202 * @implemented
203 */
204DWORD
205WINAPI
207{
208 return BasepDoTapeOperation(hDevice,
210 NULL,
211 0,
212 NULL,
213 0);
214}
215
216/*
217 * @implemented
218 */
219DWORD
220WINAPI
222 IN DWORD dwOperation,
223 IN BOOL bImmediate)
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}
236
237/*
238 * @implemented
239 */
240DWORD
241WINAPI
243 IN DWORD dwOperation,
244 IN LPVOID lpTapeInformation)
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}
267
268/*
269 * @implemented
270 */
271DWORD
272WINAPI
274 IN DWORD dwPositionMethod,
275 IN DWORD dwPartition,
276 IN DWORD dwOffsetLow,
277 IN DWORD dwOffsetHigh,
278 IN BOOL bImmediate)
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}
294
295/*
296 * @implemented
297 */
298DWORD
299WINAPI
301 IN DWORD dwTapemarkType,
302 IN DWORD dwTapemarkCount,
303 IN BOOL bImmediate)
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}
317
318/* EOF */
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#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 int BOOL
Definition: ntddk_ex.h:94
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
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static DWORD LPSTR PDWORD lpdwSize
Definition: process.c:72
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 IOCTL_TAPE_GET_STATUS
Definition: ntddtape.h:44
#define IOCTL_TAPE_SET_MEDIA_PARAMS
Definition: ntddtape.h:48
#define IOCTL_TAPE_GET_POSITION
Definition: ntddtape.h:43
#define IOCTL_TAPE_GET_MEDIA_PARAMS
Definition: ntddtape.h:42
#define IOCTL_TAPE_WRITE_MARKS
Definition: ntddtape.h:50
#define IOCTL_TAPE_SET_DRIVE_PARAMS
Definition: ntddtape.h:47
#define IOCTL_TAPE_GET_DRIVE_PARAMS
Definition: ntddtape.h:41
#define IOCTL_TAPE_CREATE_PARTITION
Definition: ntddtape.h:38
#define IOCTL_TAPE_SET_POSITION
Definition: ntddtape.h:49
#define IOCTL_TAPE_PREPARE
Definition: ntddtape.h:46
#define IOCTL_TAPE_ERASE
Definition: ntddtape.h:39
#define STATUS_PENDING
Definition: ntstatus.h:82
#define BOOLEAN
Definition: pedump.c:73
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
@ Input
Definition: arc.h:84
@ Output
Definition: arc.h:85
DWORD Type
Definition: winnt_old.h:2540
BOOLEAN Immediate
Definition: winnt_old.h:2541
LARGE_INTEGER Offset
Definition: winnt_old.h:2569
DWORD Operation
Definition: winnt_old.h:2573
BOOLEAN Immediate
Definition: winnt_old.h:2574
LARGE_INTEGER Offset
Definition: winnt_old.h:2592
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
DWORD WINAPI CreateTapePartition(IN HANDLE hDevice, IN DWORD dwPartitionMethod, IN DWORD dwCount, IN DWORD dwSize)
Definition: tape.c:80
DWORD WINAPI SetTapePosition(IN HANDLE hDevice, IN DWORD dwPositionMethod, IN DWORD dwPartition, IN DWORD dwOffsetLow, IN DWORD dwOffsetHigh, IN BOOL bImmediate)
Definition: tape.c:273
DWORD WINAPI PrepareTape(IN HANDLE hDevice, IN DWORD dwOperation, IN BOOL bImmediate)
Definition: tape.c:221
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
DWORD WINAPI SetTapeParameters(IN HANDLE hDevice, IN DWORD dwOperation, IN LPVOID lpTapeInformation)
Definition: tape.c:242
DWORD WINAPI WriteTapemark(IN HANDLE hDevice, IN DWORD dwTapemarkType, IN DWORD dwTapemarkCount, IN BOOL bImmediate)
Definition: tape.c:300
DWORD WINAPI GetTapePosition(IN HANDLE hDevice, IN DWORD dwPositionType, IN LPDWORD lpdwPartition, IN LPDWORD lpdwOffsetLow, IN LPDWORD lpdwOffsetHigh)
Definition: tape.c:168
DWORD WINAPI EraseTape(IN HANDLE hDevice, IN DWORD dwEraseType, IN BOOL bImmediate)
Definition: tape.c:103
DWORD WINAPI GetTapeParameters(IN HANDLE hDevice, IN DWORD dwOperation, IN LPDWORD lpdwSize, IN LPVOID lpTapeInformation)
Definition: tape.c:124
DWORD WINAPI GetTapeStatus(IN HANDLE hDevice)
Definition: tape.c:206
uint32_t * LPDWORD
Definition: typedefs.h:59
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
struct _LARGE_INTEGER::@2291 u
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SET_TAPE_MEDIA_INFORMATION
Definition: winbase.h:273
#define CreateEvent
Definition: winbase.h:3683
#define SET_TAPE_DRIVE_INFORMATION
Definition: winbase.h:274
#define GET_TAPE_DRIVE_INFORMATION
Definition: winbase.h:272
#define GET_TAPE_MEDIA_INFORMATION
Definition: winbase.h:271
#define WINAPI
Definition: msvc.h:6
struct _TAPE_GET_MEDIA_PARAMETERS TAPE_GET_MEDIA_PARAMETERS
struct _TAPE_GET_DRIVE_PARAMETERS TAPE_GET_DRIVE_PARAMETERS
_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