ReactOS  0.4.13-dev-39-g8b6696f
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 
19 DWORD
20 WINAPI
22  IN ULONG Ioctl,
23  IN PVOID Input,
24  IN ULONG InputLength,
25  IN PVOID Output,
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);
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 }
72 
73 /* PUBLIC FUNCTIONS ***********************************************************/
74 
75 /*
76  * @implemented
77  */
78 DWORD
79 WINAPI
81  IN DWORD dwPartitionMethod,
82  IN DWORD dwCount,
83  IN DWORD dwSize)
84 {
86 
87  TapeCreatePartition.Method = dwPartitionMethod;
88  TapeCreatePartition.Count = dwCount;
90  return BasepDoTapeOperation(hDevice,
93  sizeof(TapeCreatePartition),
94  NULL,
95  0);
96 }
97 
98 /*
99  * @implemented
100  */
101 DWORD
102 WINAPI
104  IN DWORD dwEraseType,
105  IN BOOL bImmediate)
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 }
118 
119 /*
120  * @implemented
121  */
122 DWORD
123 WINAPI
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,
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 }
162 
163 /*
164  * @implemented
165  */
166 DWORD
167 WINAPI
169  IN DWORD dwPositionType,
170  IN LPDWORD lpdwPartition,
171  IN LPDWORD lpdwOffsetLow,
172  IN LPDWORD lpdwOffsetHigh)
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 }
200 
201 /*
202  * @implemented
203  */
204 DWORD
205 WINAPI
207 {
208  return BasepDoTapeOperation(hDevice,
210  NULL,
211  0,
212  NULL,
213  0);
214 }
215 
216 /*
217  * @implemented
218  */
219 DWORD
220 WINAPI
222  IN DWORD dwOperation,
223  IN BOOL bImmediate)
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 }
236 
237 /*
238  * @implemented
239  */
240 DWORD
241 WINAPI
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 
265  return ERROR_INVALID_FUNCTION;
266 }
267 
268 /*
269  * @implemented
270  */
271 DWORD
272 WINAPI
274  IN DWORD dwPositionMethod,
275  IN DWORD dwPartition,
276  IN DWORD dwOffsetLow,
277  IN DWORD dwOffsetHigh,
278  IN BOOL bImmediate)
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 }
294 
295 /*
296  * @implemented
297  */
298 DWORD
299 WINAPI
301  IN DWORD dwTapemarkType,
302  IN DWORD dwTapemarkCount,
303  IN BOOL bImmediate)
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 }
317 
318 /* EOF */
#define CreateEvent
Definition: winbase.h:3562
#define IOCTL_TAPE_GET_MEDIA_PARAMS
Definition: ntddtape.h:42
#define IN
Definition: typedefs.h:38
#define CloseHandle
Definition: compat.h:398
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4418
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI EraseTape(IN HANDLE hDevice, IN DWORD dwEraseType, IN BOOL bImmediate)
Definition: tape.c:103
NTSTATUS TapeErase(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
NTSTATUS TapeCreatePartition(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
DWORD WINAPI GetTapePosition(IN HANDLE hDevice, IN DWORD dwPositionType, IN LPDWORD lpdwPartition, IN LPDWORD lpdwOffsetLow, IN LPDWORD lpdwOffsetHigh)
Definition: tape.c:168
#define IOCTL_TAPE_GET_DRIVE_PARAMS
Definition: ntddtape.h:41
#define IOCTL_TAPE_GET_STATUS
Definition: ntddtape.h:44
LONG NTSTATUS
Definition: precomp.h:26
Definition: arc.h:84
#define IOCTL_TAPE_CREATE_PARTITION
Definition: ntddtape.h:38
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD WINAPI GetTapeParameters(IN HANDLE hDevice, IN DWORD dwOperation, IN LPDWORD lpdwSize, IN LPVOID lpTapeInformation)
Definition: tape.c:124
NTSTATUS TapeSetPosition(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
#define IOCTL_TAPE_SET_POSITION
Definition: ntddtape.h:49
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 WriteTapemark(IN HANDLE hDevice, IN DWORD dwTapemarkType, IN DWORD dwTapemarkCount, IN BOOL bImmediate)
Definition: tape.c:300
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define IOCTL_TAPE_PREPARE
Definition: ntddtape.h:46
unsigned int BOOL
Definition: ntddk_ex.h:94
#define IOCTL_TAPE_SET_MEDIA_PARAMS
Definition: ntddtape.h:48
NTSTATUS TapeGetPosition(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
DWORD WINAPI GetTapeStatus(IN HANDLE hDevice)
Definition: tape.c:206
smooth NULL
Definition: ftsmooth.c:416
_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 SetTapeParameters(IN HANDLE hDevice, IN DWORD dwOperation, IN LPVOID lpTapeInformation)
Definition: tape.c:242
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
NTSTATUS TapeWriteMarks(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS TapePrepare(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
#define GET_TAPE_DRIVE_INFORMATION
Definition: winbase.h:269
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define WINAPI
Definition: msvc.h:8
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_SET_DRIVE_PARAMS
Definition: ntddtape.h:47
#define IOCTL_TAPE_GET_POSITION
Definition: ntddtape.h:43
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
Definition: arc.h:85
DWORD WINAPI PrepareTape(IN HANDLE hDevice, IN DWORD dwOperation, IN BOOL bImmediate)
Definition: tape.c:221
#define IOCTL_TAPE_WRITE_MARKS
Definition: ntddtape.h:50
#define ERROR_MORE_DATA
Definition: dderror.h:13
static DWORD LPSTR PDWORD lpdwSize
Definition: process.c:72
Status
Definition: gdiplustypes.h:24
struct _TAPE_GET_DRIVE_PARAMETERS TAPE_GET_DRIVE_PARAMETERS
#define GET_TAPE_MEDIA_INFORMATION
Definition: winbase.h:268
DWORD WINAPI CreateTapePartition(IN HANDLE hDevice, IN DWORD dwPartitionMethod, IN DWORD dwCount, IN DWORD dwSize)
Definition: tape.c:80
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define SET_TAPE_DRIVE_INFORMATION
Definition: winbase.h:271
#define IOCTL_TAPE_ERASE
Definition: ntddtape.h:39
#define BOOLEAN
Definition: pedump.c:73
uint32_t * LPDWORD
Definition: typedefs.h:57
unsigned int ULONG
Definition: retypes.h:1
#define INFINITE
Definition: serial.h:102
struct _TAPE_GET_MEDIA_PARAMETERS TAPE_GET_MEDIA_PARAMETERS
#define SET_TAPE_MEDIA_INFORMATION
Definition: winbase.h:270
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54