2 * Copyright 1999, 2000 Juergen Schmied
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "wine/port.h"
30 #ifdef HAVE_SYS_ERRNO_H
31 #include <sys/errno.h>
33 #ifdef HAVE_LINUX_MAJOR_H
34 # include <linux/major.h>
36 #ifdef HAVE_SYS_STATVFS_H
37 # include <sys/statvfs.h>
39 #ifdef HAVE_SYS_PARAM_H
40 # include <sys/param.h>
42 #ifdef HAVE_SYS_TIME_H
43 # include <sys/time.h>
48 #ifdef STATFS_DEFINED_BY_SYS_VFS
51 # ifdef STATFS_DEFINED_BY_SYS_MOUNT
52 # include <sys/mount.h>
54 # ifdef STATFS_DEFINED_BY_SYS_STATFS
55 # include <sys/statfs.h>
60 #define NONAMELESSUNION
61 #define NONAMELESSSTRUCT
62 #include "wine/unicode.h"
63 #include "wine/debug.h"
65 #include "wine/server.h"
66 #include "ntdll_misc.h"
71 WINE_DEFAULT_DEBUG_CHANNEL(ntdll
);
73 mode_t FILE_umask
= 0;
75 #define SECSPERDAY 86400
76 #define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)SECSPERDAY)
78 /**************************************************************************
79 * NtOpenFile [NTDLL.@]
80 * ZwOpenFile [NTDLL.@]
85 * handle [O] Variable that receives the file handle on return
86 * access [I] Access desired by the caller to the file
87 * attr [I] Structure describing the file to be opened
88 * io [O] Receives details about the result of the operation
89 * sharing [I] Type of shared access the caller requires
90 * options [I] Options for the file open
93 * Success: 0. FileHandle and IoStatusBlock are updated.
94 * Failure: An NTSTATUS error code describing the error.
96 NTSTATUS WINAPI
NtOpenFile( PHANDLE handle
, ACCESS_MASK access
,
97 POBJECT_ATTRIBUTES attr
, PIO_STATUS_BLOCK io
,
98 ULONG sharing
, ULONG options
)
100 return NtCreateFile( handle
, access
, attr
, io
, NULL
, 0,
101 sharing
, FILE_OPEN
, options
, NULL
, 0 );
104 /**************************************************************************
105 * NtCreateFile [NTDLL.@]
106 * ZwCreateFile [NTDLL.@]
108 * Either create a new file or directory, or open an existing file, device,
109 * directory or volume.
112 * handle [O] Points to a variable which receives the file handle on return
113 * access [I] Desired access to the file
114 * attr [I] Structure describing the file
115 * io [O] Receives information about the operation on return
116 * alloc_size [I] Initial size of the file in bytes
117 * attributes [I] Attributes to create the file with
118 * sharing [I] Type of shared access the caller would like to the file
119 * disposition [I] Specifies what to do, depending on whether the file already exists
120 * options [I] Options for creating a new file
121 * ea_buffer [I] Pointer to an extended attributes buffer
122 * ea_length [I] Length of ea_buffer
125 * Success: 0. handle and io are updated.
126 * Failure: An NTSTATUS error code describing the error.
128 NTSTATUS WINAPI
NtCreateFile( PHANDLE handle
, ACCESS_MASK access
, POBJECT_ATTRIBUTES attr
,
129 PIO_STATUS_BLOCK io
, PLARGE_INTEGER alloc_size
,
130 ULONG attributes
, ULONG sharing
, ULONG disposition
,
131 ULONG options
, PVOID ea_buffer
, ULONG ea_length
)
133 static const WCHAR pipeW
[] = {'\\','?','?','\\','p','i','p','e','\\'};
134 static const WCHAR mailslotW
[] = {'\\','?','?','\\','M','A','I','L','S','L','O','T','\\'};
135 ANSI_STRING unix_name
;
138 TRACE("handle=%p access=%08lx name=%s objattr=%08lx root=%p sec=%p io=%p alloc_size=%p\n"
139 "attr=%08lx sharing=%08lx disp=%ld options=%08lx ea=%p.0x%08lx\n",
140 handle
, access
, debugstr_us(attr
->ObjectName
), attr
->Attributes
,
141 attr
->RootDirectory
, attr
->SecurityDescriptor
, io
, alloc_size
,
142 attributes
, sharing
, disposition
, options
, ea_buffer
, ea_length
);
144 if (!attr
|| !attr
->ObjectName
) return STATUS_INVALID_PARAMETER
;
146 if (attr
->RootDirectory
)
148 FIXME( "RootDirectory %p not supported\n", attr
->RootDirectory
);
149 return STATUS_OBJECT_NAME_NOT_FOUND
;
151 if (alloc_size
) FIXME( "alloc_size not supported\n" );
153 /* check for named pipe */
155 if (attr
->ObjectName
->Length
> sizeof(pipeW
) &&
156 !memicmpW( attr
->ObjectName
->Buffer
, pipeW
, sizeof(pipeW
)/sizeof(WCHAR
) ))
158 SERVER_START_REQ( open_named_pipe
)
160 req
->access
= access
;
161 req
->inherit
= (attr
->Attributes
& OBJ_INHERIT
) != 0;
162 wine_server_add_data( req
, attr
->ObjectName
->Buffer
+ 4,
163 attr
->ObjectName
->Length
- 4*sizeof(WCHAR
) );
164 io
->u
.Status
= wine_server_call( req
);
165 *handle
= reply
->handle
;
171 /* check for mailslot */
173 if (attr
->ObjectName
->Length
> sizeof(mailslotW
) &&
174 !memicmpW( attr
->ObjectName
->Buffer
, mailslotW
, sizeof(mailslotW
)/sizeof(WCHAR
) ))
176 SERVER_START_REQ( open_mailslot
)
178 req
->access
= access
& GENERIC_WRITE
;
179 req
->sharing
= sharing
;
180 req
->inherit
= (attr
->Attributes
& OBJ_INHERIT
) != 0;
181 wine_server_add_data( req
, attr
->ObjectName
->Buffer
+ 4,
182 attr
->ObjectName
->Length
- 4*sizeof(WCHAR
) );
183 io
->u
.Status
= wine_server_call( req
);
184 *handle
= reply
->handle
;
190 io
->u
.Status
= wine_nt_to_unix_file_name( attr
->ObjectName
, &unix_name
, disposition
,
191 !(attr
->Attributes
& OBJ_CASE_INSENSITIVE
) );
193 if (io
->u
.Status
== STATUS_NO_SUCH_FILE
&&
194 disposition
!= FILE_OPEN
&& disposition
!= FILE_OVERWRITE
)
197 io
->u
.Status
= STATUS_SUCCESS
;
200 if (io
->u
.Status
== STATUS_SUCCESS
)
202 SERVER_START_REQ( create_file
)
204 req
->access
= access
;
205 req
->inherit
= (attr
->Attributes
& OBJ_INHERIT
) != 0;
206 req
->sharing
= sharing
;
207 req
->create
= disposition
;
208 req
->options
= options
;
209 req
->attrs
= attributes
;
210 wine_server_add_data( req
, unix_name
.Buffer
, unix_name
.Length
);
211 io
->u
.Status
= wine_server_call( req
);
212 *handle
= reply
->handle
;
215 RtlFreeAnsiString( &unix_name
);
217 else WARN("%s not found (%lx)\n", debugstr_us(attr
->ObjectName
), io
->u
.Status
);
219 if (io
->u
.Status
== STATUS_SUCCESS
)
221 if (created
) io
->Information
= FILE_CREATED
;
222 else switch(disposition
)
225 io
->Information
= FILE_SUPERSEDED
;
228 io
->Information
= FILE_CREATED
;
232 io
->Information
= FILE_OPENED
;
235 case FILE_OVERWRITE_IF
:
236 io
->Information
= FILE_OVERWRITTEN
;
244 /***********************************************************************
245 * Asynchronous file I/O *
247 static void WINAPI
FILE_AsyncReadService(void*, PIO_STATUS_BLOCK
, ULONG
);
248 static void WINAPI
FILE_AsyncWriteService(void*, PIO_STATUS_BLOCK
, ULONG
);
250 typedef struct async_fileio
258 int queue_apc_on_error
;
264 static void fileio_terminate(async_fileio
*fileio
, IO_STATUS_BLOCK
* iosb
)
266 TRACE("data: %p\n", fileio
);
268 wine_server_release_fd( fileio
->handle
, fileio
->fd
);
269 if ( fileio
->event
!= INVALID_HANDLE_VALUE
)
270 NtSetEvent( fileio
->event
, NULL
);
273 (iosb
->u
.Status
== STATUS_SUCCESS
|| fileio
->queue_apc_on_error
))
274 fileio
->apc( fileio
->apc_user
, iosb
, iosb
->Information
);
276 RtlFreeHeap( GetProcessHeap(), 0, fileio
);
280 static ULONG
fileio_queue_async(async_fileio
* fileio
, IO_STATUS_BLOCK
* iosb
,
283 PIO_APC_ROUTINE apc
= do_read
? FILE_AsyncReadService
: FILE_AsyncWriteService
;
286 SERVER_START_REQ( register_async
)
288 req
->handle
= fileio
->handle
;
291 req
->io_user
= fileio
;
292 req
->type
= do_read
? ASYNC_TYPE_READ
: ASYNC_TYPE_WRITE
;
293 req
->count
= (fileio
->count
< iosb
->Information
) ?
294 0 : fileio
->count
- iosb
->Information
;
295 status
= wine_server_call( req
);
299 if ( status
) iosb
->u
.Status
= status
;
300 if ( iosb
->u
.Status
!= STATUS_PENDING
)
302 (apc
)( fileio
, iosb
, iosb
->u
.Status
);
303 return iosb
->u
.Status
;
305 NtCurrentTeb()->num_async_io
++;
306 return STATUS_SUCCESS
;
309 /***********************************************************************
310 * FILE_GetNtStatus(void)
312 * Retrieve the Nt Status code from errno.
313 * Try to be consistent with FILE_SetDosError().
315 NTSTATUS
FILE_GetNtStatus(void)
319 TRACE( "errno = %d\n", errno
);
322 case EAGAIN
: return STATUS_SHARING_VIOLATION
;
323 case EBADF
: return STATUS_INVALID_HANDLE
;
324 case ENOSPC
: return STATUS_DISK_FULL
;
327 case EACCES
: return STATUS_ACCESS_DENIED
;
328 case ENOTDIR
: return STATUS_OBJECT_PATH_NOT_FOUND
;
329 case ENOENT
: return STATUS_OBJECT_NAME_NOT_FOUND
;
330 case EISDIR
: return STATUS_FILE_IS_A_DIRECTORY
;
332 case ENFILE
: return STATUS_TOO_MANY_OPENED_FILES
;
333 case EINVAL
: return STATUS_INVALID_PARAMETER
;
334 case ENOTEMPTY
: return STATUS_DIRECTORY_NOT_EMPTY
;
335 case EPIPE
: return STATUS_PIPE_BROKEN
;
336 case EIO
: return STATUS_DEVICE_NOT_READY
;
338 case ENOMEDIUM
: return STATUS_NO_MEDIA_IN_DEVICE
;
341 case EOPNOTSUPP
:return STATUS_NOT_SUPPORTED
;
342 case ECONNRESET
:return STATUS_PIPE_DISCONNECTED
;
343 case ENOEXEC
: /* ?? */
344 case ESPIPE
: /* ?? */
345 case EEXIST
: /* ?? */
347 FIXME( "Converting errno %d to STATUS_UNSUCCESSFUL\n", err
);
348 return STATUS_UNSUCCESSFUL
;
352 /***********************************************************************
353 * FILE_AsyncReadService (INTERNAL)
355 * This function is called while the client is waiting on the
356 * server, so we can't make any server calls here.
358 static void WINAPI
FILE_AsyncReadService(void *user
, PIO_STATUS_BLOCK iosb
, ULONG status
)
360 async_fileio
*fileio
= (async_fileio
*)user
;
362 int already
= iosb
->Information
;
364 TRACE("%p %p %lu\n", iosb
, fileio
->buffer
, status
);
368 case STATUS_ALERTED
: /* got some new data */
369 if (iosb
->u
.Status
!= STATUS_PENDING
) FIXME("unexpected status %08lx\n", iosb
->u
.Status
);
370 /* check to see if the data is ready (non-blocking) */
371 if ( fileio
->avail_mode
)
372 result
= read(fileio
->fd
, &fileio
->buffer
[already
],
373 fileio
->count
- already
);
376 result
= pread(fileio
->fd
, &fileio
->buffer
[already
],
377 fileio
->count
- already
,
378 fileio
->offset
+ already
);
379 if ((result
< 0) && (errno
== ESPIPE
))
380 result
= read(fileio
->fd
, &fileio
->buffer
[already
],
381 fileio
->count
- already
);
386 if (errno
== EAGAIN
|| errno
== EINTR
)
388 TRACE("Deferred read %d\n", errno
);
389 iosb
->u
.Status
= STATUS_PENDING
;
391 else /* check to see if the transfer is complete */
392 iosb
->u
.Status
= FILE_GetNtStatus();
394 else if (result
== 0)
396 iosb
->u
.Status
= iosb
->Information
? STATUS_SUCCESS
: STATUS_END_OF_FILE
;
400 iosb
->Information
+= result
;
401 if (iosb
->Information
>= fileio
->count
|| fileio
->avail_mode
)
402 iosb
->u
.Status
= STATUS_SUCCESS
;
405 /* if we only have to read the available data, and none is available,
406 * simply cancel the request. If data was available, it has been read
407 * while in by previous call (NtDelayExecution)
409 iosb
->u
.Status
= (fileio
->avail_mode
) ? STATUS_SUCCESS
: STATUS_PENDING
;
412 TRACE("read %d more bytes %ld/%d so far (%s)\n",
413 result
, iosb
->Information
, fileio
->count
,
414 (iosb
->u
.Status
== STATUS_SUCCESS
) ? "success" : "pending");
416 /* queue another async operation ? */
417 if (iosb
->u
.Status
== STATUS_PENDING
)
418 fileio_queue_async(fileio
, iosb
, TRUE
);
420 fileio_terminate(fileio
, iosb
);
423 iosb
->u
.Status
= status
;
424 fileio_terminate(fileio
, iosb
);
430 /******************************************************************************
431 * NtReadFile [NTDLL.@]
432 * ZwReadFile [NTDLL.@]
434 * Read from an open file handle.
437 * FileHandle [I] Handle returned from ZwOpenFile() or ZwCreateFile()
438 * Event [I] Event to signal upon completion (or NULL)
439 * ApcRoutine [I] Callback to call upon completion (or NULL)
440 * ApcContext [I] Context for ApcRoutine (or NULL)
441 * IoStatusBlock [O] Receives information about the operation on return
442 * Buffer [O] Destination for the data read
443 * Length [I] Size of Buffer
444 * ByteOffset [O] Destination for the new file pointer position (or NULL)
445 * Key [O] Function unknown (may be NULL)
448 * Success: 0. IoStatusBlock is updated, and the Information member contains
449 * The number of bytes read.
450 * Failure: An NTSTATUS error code describing the error.
452 NTSTATUS WINAPI
NtReadFile(HANDLE hFile
, HANDLE hEvent
,
453 PIO_APC_ROUTINE apc
, void* apc_user
,
454 PIO_STATUS_BLOCK io_status
, void* buffer
, ULONG length
,
455 PLARGE_INTEGER offset
, PULONG key
)
457 int unix_handle
, flags
;
459 TRACE("(%p,%p,%p,%p,%p,%p,0x%08lx,%p,%p),partial stub!\n",
460 hFile
,hEvent
,apc
,apc_user
,io_status
,buffer
,length
,offset
,key
);
462 if (!io_status
) return STATUS_ACCESS_VIOLATION
;
464 io_status
->Information
= 0;
465 io_status
->u
.Status
= wine_server_handle_to_fd( hFile
, GENERIC_READ
, &unix_handle
, &flags
);
466 if (io_status
->u
.Status
) return io_status
->u
.Status
;
468 if (flags
& FD_FLAG_RECV_SHUTDOWN
)
470 wine_server_release_fd( hFile
, unix_handle
);
471 return STATUS_PIPE_DISCONNECTED
;
474 if (flags
& FD_FLAG_TIMEOUT
)
478 /* this shouldn't happen, but check it */
479 FIXME("NIY-hEvent\n");
480 wine_server_release_fd( hFile
, unix_handle
);
481 return STATUS_NOT_IMPLEMENTED
;
483 io_status
->u
.Status
= NtCreateEvent(&hEvent
, EVENT_ALL_ACCESS
, NULL
, 0, 0);
484 if (io_status
->u
.Status
)
486 wine_server_release_fd( hFile
, unix_handle
);
487 return io_status
->u
.Status
;
491 if (flags
& (FD_FLAG_OVERLAPPED
|FD_FLAG_TIMEOUT
))
493 async_fileio
* fileio
;
496 if (!(fileio
= RtlAllocateHeap(GetProcessHeap(), 0, sizeof(async_fileio
))))
498 wine_server_release_fd( hFile
, unix_handle
);
499 if (flags
& FD_FLAG_TIMEOUT
) NtClose(hEvent
);
500 return STATUS_NO_MEMORY
;
502 fileio
->handle
= hFile
;
503 fileio
->count
= length
;
504 if ( offset
== NULL
)
508 fileio
->offset
= offset
->QuadPart
;
509 if (offset
->u
.HighPart
&& fileio
->offset
== offset
->u
.LowPart
)
510 FIXME("High part of offset is lost\n");
513 fileio
->apc_user
= apc_user
;
514 fileio
->buffer
= buffer
;
515 fileio
->queue_apc_on_error
= 0;
516 fileio
->avail_mode
= (flags
& FD_FLAG_AVAILABLE
);
517 fileio
->fd
= unix_handle
; /* FIXME */
518 fileio
->event
= hEvent
;
519 NtResetEvent(hEvent
, NULL
);
521 io_status
->u
.Status
= STATUS_PENDING
;
522 ret
= fileio_queue_async(fileio
, io_status
, TRUE
);
523 if (ret
!= STATUS_SUCCESS
)
525 wine_server_release_fd( hFile
, unix_handle
);
526 if (flags
& FD_FLAG_TIMEOUT
) NtClose(hEvent
);
527 RtlFreeHeap(GetProcessHeap(), 0, fileio
);
530 if (flags
& FD_FLAG_TIMEOUT
)
532 ret
= NtWaitForSingleObject(hEvent
, TRUE
, NULL
);
534 if (ret
!= STATUS_USER_APC
)
535 fileio
->queue_apc_on_error
= 1;
539 LARGE_INTEGER timeout
;
541 /* let some APC be run, this will read some already pending data */
542 timeout
.u
.LowPart
= timeout
.u
.HighPart
= 0;
543 ret
= NtDelayExecution( TRUE
, &timeout
);
544 /* the apc didn't run and therefore the completion routine now
545 * needs to be sent errors.
546 * Note that there is no race between setting this flag and
547 * returning errors because apc's are run only during alertable
549 if (ret
!= STATUS_USER_APC
)
550 fileio
->queue_apc_on_error
= 1;
552 TRACE("= 0x%08lx\n", io_status
->u
.Status
);
553 return io_status
->u
.Status
;
558 FILE_POSITION_INFORMATION fpi
;
560 fpi
.CurrentByteOffset
= *offset
;
561 io_status
->u
.Status
= NtSetInformationFile(hFile
, io_status
, &fpi
, sizeof(fpi
),
562 FilePositionInformation
);
563 if (io_status
->u
.Status
)
565 wine_server_release_fd( hFile
, unix_handle
);
566 return io_status
->u
.Status
;
569 /* code for synchronous reads */
570 while ((io_status
->Information
= read( unix_handle
, buffer
, length
)) == -1)
572 if ((errno
== EAGAIN
) || (errno
== EINTR
)) continue;
575 io_status
->Information
= 0;
576 io_status
->u
.Status
= STATUS_ACCESS_VIOLATION
;
578 else io_status
->u
.Status
= FILE_GetNtStatus();
581 wine_server_release_fd( hFile
, unix_handle
);
582 TRACE("= 0x%08lx\n", io_status
->u
.Status
);
583 return io_status
->u
.Status
;
586 /***********************************************************************
587 * FILE_AsyncWriteService (INTERNAL)
589 * This function is called while the client is waiting on the
590 * server, so we can't make any server calls here.
592 static void WINAPI
FILE_AsyncWriteService(void *ovp
, IO_STATUS_BLOCK
*iosb
, ULONG status
)
594 async_fileio
*fileio
= (async_fileio
*) ovp
;
596 int already
= iosb
->Information
;
598 TRACE("(%p %p %lu)\n",iosb
, fileio
->buffer
, status
);
603 /* write some data (non-blocking) */
604 if ( fileio
->avail_mode
)
605 result
= write(fileio
->fd
, &fileio
->buffer
[already
],
606 fileio
->count
- already
);
609 result
= pwrite(fileio
->fd
, &fileio
->buffer
[already
],
610 fileio
->count
- already
, fileio
->offset
+ already
);
611 if ((result
< 0) && (errno
== ESPIPE
))
612 result
= write(fileio
->fd
, &fileio
->buffer
[already
],
613 fileio
->count
- already
);
618 if (errno
== EAGAIN
|| errno
== EINTR
) iosb
->u
.Status
= STATUS_PENDING
;
619 else iosb
->u
.Status
= FILE_GetNtStatus();
623 iosb
->Information
+= result
;
624 iosb
->u
.Status
= (iosb
->Information
< fileio
->count
) ? STATUS_PENDING
: STATUS_SUCCESS
;
625 TRACE("wrote %d more bytes %ld/%d so far\n",
626 result
, iosb
->Information
, fileio
->count
);
628 if (iosb
->u
.Status
== STATUS_PENDING
)
629 fileio_queue_async(fileio
, iosb
, FALSE
);
632 iosb
->u
.Status
= status
;
633 fileio_terminate(fileio
, iosb
);
638 /******************************************************************************
639 * NtWriteFile [NTDLL.@]
640 * ZwWriteFile [NTDLL.@]
642 * Write to an open file handle.
645 * FileHandle [I] Handle returned from ZwOpenFile() or ZwCreateFile()
646 * Event [I] Event to signal upon completion (or NULL)
647 * ApcRoutine [I] Callback to call upon completion (or NULL)
648 * ApcContext [I] Context for ApcRoutine (or NULL)
649 * IoStatusBlock [O] Receives information about the operation on return
650 * Buffer [I] Source for the data to write
651 * Length [I] Size of Buffer
652 * ByteOffset [O] Destination for the new file pointer position (or NULL)
653 * Key [O] Function unknown (may be NULL)
656 * Success: 0. IoStatusBlock is updated, and the Information member contains
657 * The number of bytes written.
658 * Failure: An NTSTATUS error code describing the error.
660 NTSTATUS WINAPI
NtWriteFile(HANDLE hFile
, HANDLE hEvent
,
661 PIO_APC_ROUTINE apc
, void* apc_user
,
662 PIO_STATUS_BLOCK io_status
,
663 const void* buffer
, ULONG length
,
664 PLARGE_INTEGER offset
, PULONG key
)
666 int unix_handle
, flags
;
668 TRACE("(%p,%p,%p,%p,%p,%p,0x%08lx,%p,%p)!\n",
669 hFile
,hEvent
,apc
,apc_user
,io_status
,buffer
,length
,offset
,key
);
671 if (!io_status
) return STATUS_ACCESS_VIOLATION
;
673 io_status
->Information
= 0;
674 io_status
->u
.Status
= wine_server_handle_to_fd( hFile
, GENERIC_WRITE
, &unix_handle
, &flags
);
675 if (io_status
->u
.Status
) return io_status
->u
.Status
;
677 if (flags
& FD_FLAG_SEND_SHUTDOWN
)
679 wine_server_release_fd( hFile
, unix_handle
);
680 return STATUS_PIPE_DISCONNECTED
;
683 if (flags
& FD_FLAG_TIMEOUT
)
687 /* this shouldn't happen, but check it */
688 FIXME("NIY-hEvent\n");
689 wine_server_release_fd( hFile
, unix_handle
);
690 return STATUS_NOT_IMPLEMENTED
;
692 io_status
->u
.Status
= NtCreateEvent(&hEvent
, EVENT_ALL_ACCESS
, NULL
, 0, 0);
693 if (io_status
->u
.Status
)
695 wine_server_release_fd( hFile
, unix_handle
);
696 return io_status
->u
.Status
;
700 if (flags
& (FD_FLAG_OVERLAPPED
|FD_FLAG_TIMEOUT
))
702 async_fileio
* fileio
;
705 if (!(fileio
= RtlAllocateHeap(GetProcessHeap(), 0, sizeof(async_fileio
))))
707 wine_server_release_fd( hFile
, unix_handle
);
708 if (flags
& FD_FLAG_TIMEOUT
) NtClose(hEvent
);
709 return STATUS_NO_MEMORY
;
711 fileio
->handle
= hFile
;
712 fileio
->count
= length
;
715 fileio
->offset
= offset
->QuadPart
;
716 if (offset
->u
.HighPart
&& fileio
->offset
== offset
->u
.LowPart
)
717 FIXME("High part of offset is lost\n");
724 fileio
->apc_user
= apc_user
;
725 fileio
->buffer
= (void*)buffer
;
726 fileio
->queue_apc_on_error
= 0;
727 fileio
->avail_mode
= (flags
& FD_FLAG_AVAILABLE
);
728 fileio
->fd
= unix_handle
; /* FIXME */
729 fileio
->event
= hEvent
;
730 NtResetEvent(hEvent
, NULL
);
732 io_status
->Information
= 0;
733 io_status
->u
.Status
= STATUS_PENDING
;
734 ret
= fileio_queue_async(fileio
, io_status
, FALSE
);
735 if (ret
!= STATUS_SUCCESS
)
737 wine_server_release_fd( hFile
, unix_handle
);
738 if (flags
& FD_FLAG_TIMEOUT
) NtClose(hEvent
);
739 RtlFreeHeap(GetProcessHeap(), 0, fileio
);
742 if (flags
& FD_FLAG_TIMEOUT
)
744 ret
= NtWaitForSingleObject(hEvent
, TRUE
, NULL
);
746 if (ret
!= STATUS_USER_APC
)
747 fileio
->queue_apc_on_error
= 1;
751 LARGE_INTEGER timeout
;
753 /* let some APC be run, this will write as much data as possible */
754 timeout
.u
.LowPart
= timeout
.u
.HighPart
= 0;
755 ret
= NtDelayExecution( TRUE
, &timeout
);
756 /* the apc didn't run and therefore the completion routine now
757 * needs to be sent errors.
758 * Note that there is no race between setting this flag and
759 * returning errors because apc's are run only during alertable
761 if (ret
!= STATUS_USER_APC
)
762 fileio
->queue_apc_on_error
= 1;
764 return io_status
->u
.Status
;
769 FILE_POSITION_INFORMATION fpi
;
771 fpi
.CurrentByteOffset
= *offset
;
772 io_status
->u
.Status
= NtSetInformationFile(hFile
, io_status
, &fpi
, sizeof(fpi
),
773 FilePositionInformation
);
774 if (io_status
->u
.Status
)
776 wine_server_release_fd( hFile
, unix_handle
);
777 return io_status
->u
.Status
;
781 /* synchronous file write */
782 while ((io_status
->Information
= write( unix_handle
, buffer
, length
)) == -1)
784 if ((errno
== EAGAIN
) || (errno
== EINTR
)) continue;
787 io_status
->Information
= 0;
788 io_status
->u
.Status
= STATUS_INVALID_USER_BUFFER
;
790 else if (errno
== ENOSPC
) io_status
->u
.Status
= STATUS_DISK_FULL
;
791 else io_status
->u
.Status
= FILE_GetNtStatus();
794 wine_server_release_fd( hFile
, unix_handle
);
795 return io_status
->u
.Status
;
798 /**************************************************************************
799 * NtDeviceIoControlFile [NTDLL.@]
800 * ZwDeviceIoControlFile [NTDLL.@]
802 * Perform an I/O control operation on an open file handle.
805 * DeviceHandle [I] Handle returned from ZwOpenFile() or ZwCreateFile()
806 * Event [I] Event to signal upon completion (or NULL)
807 * ApcRoutine [I] Callback to call upon completion (or NULL)
808 * ApcContext [I] Context for ApcRoutine (or NULL)
809 * IoStatusBlock [O] Receives information about the operation on return
810 * IoControlCode [I] Control code for the operation to perform
811 * InputBuffer [I] Source for any input data required (or NULL)
812 * InputBufferSize [I] Size of InputBuffer
813 * OutputBuffer [O] Source for any output data returned (or NULL)
814 * OutputBufferSize [I] Size of OutputBuffer
817 * Success: 0. IoStatusBlock is updated.
818 * Failure: An NTSTATUS error code describing the error.
820 NTSTATUS WINAPI
NtDeviceIoControlFile(HANDLE DeviceHandle
, HANDLE hEvent
,
821 PIO_APC_ROUTINE UserApcRoutine
,
822 PVOID UserApcContext
,
823 PIO_STATUS_BLOCK IoStatusBlock
,
826 ULONG InputBufferSize
,
828 ULONG OutputBufferSize
)
830 TRACE("(%p,%p,%p,%p,%p,0x%08lx,%p,0x%08lx,%p,0x%08lx)\n",
831 DeviceHandle
, hEvent
, UserApcRoutine
, UserApcContext
,
832 IoStatusBlock
, IoControlCode
,
833 InputBuffer
, InputBufferSize
, OutputBuffer
, OutputBufferSize
);
835 if (CDROM_DeviceIoControl(DeviceHandle
, hEvent
,
836 UserApcRoutine
, UserApcContext
,
837 IoStatusBlock
, IoControlCode
,
838 InputBuffer
, InputBufferSize
,
839 OutputBuffer
, OutputBufferSize
) == STATUS_NO_SUCH_DEVICE
)
841 /* it wasn't a CDROM */
842 FIXME("Unimplemented dwIoControlCode=%08lx\n", IoControlCode
);
843 IoStatusBlock
->u
.Status
= STATUS_NOT_IMPLEMENTED
;
844 IoStatusBlock
->Information
= 0;
845 if (hEvent
) NtSetEvent(hEvent
, NULL
);
847 return IoStatusBlock
->u
.Status
;
850 /******************************************************************************
851 * NtFsControlFile [NTDLL.@]
852 * ZwFsControlFile [NTDLL.@]
854 NTSTATUS WINAPI
NtFsControlFile(
855 IN HANDLE DeviceHandle
,
856 IN HANDLE Event OPTIONAL
,
857 IN PIO_APC_ROUTINE ApcRoutine OPTIONAL
,
858 IN PVOID ApcContext OPTIONAL
,
859 OUT PIO_STATUS_BLOCK IoStatusBlock
,
860 IN ULONG IoControlCode
,
861 IN PVOID InputBuffer
,
862 IN ULONG InputBufferSize
,
863 OUT PVOID OutputBuffer
,
864 IN ULONG OutputBufferSize
)
866 FIXME("(%p,%p,%p,%p,%p,0x%08lx,%p,0x%08lx,%p,0x%08lx): stub\n",
867 DeviceHandle
,Event
,ApcRoutine
,ApcContext
,IoStatusBlock
,IoControlCode
,
868 InputBuffer
,InputBufferSize
,OutputBuffer
,OutputBufferSize
);
872 /******************************************************************************
873 * NtSetVolumeInformationFile [NTDLL.@]
874 * ZwSetVolumeInformationFile [NTDLL.@]
876 * Set volume information for an open file handle.
879 * FileHandle [I] Handle returned from ZwOpenFile() or ZwCreateFile()
880 * IoStatusBlock [O] Receives information about the operation on return
881 * FsInformation [I] Source for volume information
882 * Length [I] Size of FsInformation
883 * FsInformationClass [I] Type of volume information to set
886 * Success: 0. IoStatusBlock is updated.
887 * Failure: An NTSTATUS error code describing the error.
889 NTSTATUS WINAPI
NtSetVolumeInformationFile(
890 IN HANDLE FileHandle
,
891 PIO_STATUS_BLOCK IoStatusBlock
,
894 FS_INFORMATION_CLASS FsInformationClass
)
896 FIXME("(%p,%p,%p,0x%08lx,0x%08x) stub\n",
897 FileHandle
,IoStatusBlock
,FsInformation
,Length
,FsInformationClass
);
901 /******************************************************************************
902 * NtQueryInformationFile [NTDLL.@]
903 * ZwQueryInformationFile [NTDLL.@]
905 * Get information about an open file handle.
908 * hFile [I] Handle returned from ZwOpenFile() or ZwCreateFile()
909 * io [O] Receives information about the operation on return
910 * ptr [O] Destination for file information
911 * len [I] Size of FileInformation
912 * class [I] Type of file information to get
915 * Success: 0. IoStatusBlock and FileInformation are updated.
916 * Failure: An NTSTATUS error code describing the error.
918 NTSTATUS WINAPI
NtQueryInformationFile( HANDLE hFile
, PIO_STATUS_BLOCK io
,
919 PVOID ptr
, LONG len
, FILE_INFORMATION_CLASS
class )
921 static const size_t info_sizes
[] =
924 sizeof(FILE_DIRECTORY_INFORMATION
), /* FileDirectoryInformation */
925 sizeof(FILE_FULL_DIRECTORY_INFORMATION
), /* FileFullDirectoryInformation */
926 sizeof(FILE_BOTH_DIRECTORY_INFORMATION
), /* FileBothDirectoryInformation */
927 sizeof(FILE_BASIC_INFORMATION
), /* FileBasicInformation */
928 sizeof(FILE_STANDARD_INFORMATION
), /* FileStandardInformation */
929 sizeof(FILE_INTERNAL_INFORMATION
), /* FileInternalInformation */
930 sizeof(FILE_EA_INFORMATION
), /* FileEaInformation */
931 sizeof(FILE_ACCESS_INFORMATION
), /* FileAccessInformation */
932 sizeof(FILE_NAME_INFORMATION
)-sizeof(WCHAR
), /* FileNameInformation */
933 sizeof(FILE_RENAME_INFORMATION
)-sizeof(WCHAR
), /* FileRenameInformation */
934 0, /* FileLinkInformation */
935 sizeof(FILE_NAMES_INFORMATION
)-sizeof(WCHAR
), /* FileNamesInformation */
936 sizeof(FILE_DISPOSITION_INFORMATION
), /* FileDispositionInformation */
937 sizeof(FILE_POSITION_INFORMATION
), /* FilePositionInformation */
938 sizeof(FILE_FULL_EA_INFORMATION
), /* FileFullEaInformation */
939 sizeof(FILE_MODE_INFORMATION
), /* FileModeInformation */
940 sizeof(FILE_ALIGNMENT_INFORMATION
), /* FileAlignmentInformation */
941 sizeof(FILE_ALL_INFORMATION
)-sizeof(WCHAR
), /* FileAllInformation */
942 sizeof(FILE_ALLOCATION_INFORMATION
), /* FileAllocationInformation */
943 sizeof(FILE_END_OF_FILE_INFORMATION
), /* FileEndOfFileInformation */
944 0, /* FileAlternateNameInformation */
945 sizeof(FILE_STREAM_INFORMATION
)-sizeof(WCHAR
), /* FileStreamInformation */
946 0, /* FilePipeInformation */
947 0, /* FilePipeLocalInformation */
948 0, /* FilePipeRemoteInformation */
949 sizeof(FILE_MAILSLOT_QUERY_INFORMATION
), /* FileMailslotQueryInformation */
950 0, /* FileMailslotSetInformation */
951 0, /* FileCompressionInformation */
952 0, /* FileObjectIdInformation */
953 0, /* FileCompletionInformation */
954 0, /* FileMoveClusterInformation */
955 0, /* FileQuotaInformation */
956 0, /* FileReparsePointInformation */
957 0, /* FileNetworkOpenInformation */
958 0, /* FileAttributeTagInformation */
959 0 /* FileTrackingInformation */
965 TRACE("(%p,%p,%p,0x%08lx,0x%08x)\n", hFile
, io
, ptr
, len
, class);
969 if (class <= 0 || class >= FileMaximumInformation
)
970 return io
->u
.Status
= STATUS_INVALID_INFO_CLASS
;
971 if (!info_sizes
[class])
973 FIXME("Unsupported class (%d)\n", class);
974 return io
->u
.Status
= STATUS_NOT_IMPLEMENTED
;
976 if (len
< info_sizes
[class])
977 return io
->u
.Status
= STATUS_INFO_LENGTH_MISMATCH
;
979 if ((io
->u
.Status
= wine_server_handle_to_fd( hFile
, 0, &fd
, NULL
)))
984 case FileBasicInformation
:
986 FILE_BASIC_INFORMATION
*info
= ptr
;
988 if (fstat( fd
, &st
) == -1)
989 io
->u
.Status
= FILE_GetNtStatus();
990 else if (!S_ISREG(st
.st_mode
) && !S_ISDIR(st
.st_mode
))
991 io
->u
.Status
= STATUS_INVALID_INFO_CLASS
;
994 if (S_ISDIR(st
.st_mode
)) info
->FileAttributes
= FILE_ATTRIBUTE_DIRECTORY
;
995 else info
->FileAttributes
= FILE_ATTRIBUTE_ARCHIVE
;
996 if (!(st
.st_mode
& (S_IWUSR
| S_IWGRP
| S_IWOTH
)))
997 info
->FileAttributes
|= FILE_ATTRIBUTE_READONLY
;
998 RtlSecondsSince1970ToTime( st
.st_mtime
, &info
->CreationTime
);
999 RtlSecondsSince1970ToTime( st
.st_mtime
, &info
->LastWriteTime
);
1000 RtlSecondsSince1970ToTime( st
.st_ctime
, &info
->ChangeTime
);
1001 RtlSecondsSince1970ToTime( st
.st_atime
, &info
->LastAccessTime
);
1005 case FileStandardInformation
:
1007 FILE_STANDARD_INFORMATION
*info
= ptr
;
1009 if (fstat( fd
, &st
) == -1) io
->u
.Status
= FILE_GetNtStatus();
1012 if ((info
->Directory
= S_ISDIR(st
.st_mode
)))
1014 info
->AllocationSize
.QuadPart
= 0;
1015 info
->EndOfFile
.QuadPart
= 0;
1016 info
->NumberOfLinks
= 1;
1017 info
->DeletePending
= FALSE
;
1021 info
->AllocationSize
.QuadPart
= (ULONGLONG
)st
.st_blocks
* 512;
1022 info
->EndOfFile
.QuadPart
= st
.st_size
;
1023 info
->NumberOfLinks
= st
.st_nlink
;
1024 info
->DeletePending
= FALSE
; /* FIXME */
1029 case FilePositionInformation
:
1031 FILE_POSITION_INFORMATION
*info
= ptr
;
1032 off_t res
= lseek( fd
, 0, SEEK_CUR
);
1033 if (res
== (off_t
)-1) io
->u
.Status
= FILE_GetNtStatus();
1034 else info
->CurrentByteOffset
.QuadPart
= res
;
1037 case FileInternalInformation
:
1039 FILE_INTERNAL_INFORMATION
*info
= ptr
;
1041 if (fstat( fd
, &st
) == -1) io
->u
.Status
= FILE_GetNtStatus();
1042 else info
->IndexNumber
.QuadPart
= st
.st_ino
;
1045 case FileEaInformation
:
1047 FILE_EA_INFORMATION
*info
= ptr
;
1051 case FileEndOfFileInformation
:
1053 FILE_END_OF_FILE_INFORMATION
*info
= ptr
;
1055 if (fstat( fd
, &st
) == -1) io
->u
.Status
= FILE_GetNtStatus();
1056 else info
->EndOfFile
.QuadPart
= S_ISDIR(st
.st_mode
) ? 0 : st
.st_size
;
1059 case FileAllInformation
:
1061 FILE_ALL_INFORMATION
*info
= ptr
;
1063 if (fstat( fd
, &st
) == -1) io
->u
.Status
= FILE_GetNtStatus();
1064 else if (!S_ISREG(st
.st_mode
) && !S_ISDIR(st
.st_mode
))
1065 io
->u
.Status
= STATUS_INVALID_INFO_CLASS
;
1068 if ((info
->StandardInformation
.Directory
= S_ISDIR(st
.st_mode
)))
1070 info
->BasicInformation
.FileAttributes
= FILE_ATTRIBUTE_DIRECTORY
;
1071 info
->StandardInformation
.AllocationSize
.QuadPart
= 0;
1072 info
->StandardInformation
.EndOfFile
.QuadPart
= 0;
1073 info
->StandardInformation
.NumberOfLinks
= 1;
1074 info
->StandardInformation
.DeletePending
= FALSE
;
1078 info
->BasicInformation
.FileAttributes
= FILE_ATTRIBUTE_ARCHIVE
;
1079 info
->StandardInformation
.AllocationSize
.QuadPart
= (ULONGLONG
)st
.st_blocks
* 512;
1080 info
->StandardInformation
.EndOfFile
.QuadPart
= st
.st_size
;
1081 info
->StandardInformation
.NumberOfLinks
= st
.st_nlink
;
1082 info
->StandardInformation
.DeletePending
= FALSE
; /* FIXME */
1084 if (!(st
.st_mode
& (S_IWUSR
| S_IWGRP
| S_IWOTH
)))
1085 info
->BasicInformation
.FileAttributes
|= FILE_ATTRIBUTE_READONLY
;
1086 RtlSecondsSince1970ToTime( st
.st_mtime
, &info
->BasicInformation
.CreationTime
);
1087 RtlSecondsSince1970ToTime( st
.st_mtime
, &info
->BasicInformation
.LastWriteTime
);
1088 RtlSecondsSince1970ToTime( st
.st_ctime
, &info
->BasicInformation
.ChangeTime
);
1089 RtlSecondsSince1970ToTime( st
.st_atime
, &info
->BasicInformation
.LastAccessTime
);
1090 info
->InternalInformation
.IndexNumber
.QuadPart
= st
.st_ino
;
1091 info
->EaInformation
.EaSize
= 0;
1092 info
->AccessInformation
.AccessFlags
= 0; /* FIXME */
1093 info
->PositionInformation
.CurrentByteOffset
.QuadPart
= lseek( fd
, 0, SEEK_CUR
);
1094 info
->ModeInformation
.Mode
= 0; /* FIXME */
1095 info
->AlignmentInformation
.AlignmentRequirement
= 1; /* FIXME */
1096 info
->NameInformation
.FileNameLength
= 0;
1097 io
->Information
= sizeof(*info
) - sizeof(WCHAR
);
1101 case FileMailslotQueryInformation
:
1103 FILE_MAILSLOT_QUERY_INFORMATION
*info
= ptr
;
1105 SERVER_START_REQ( set_mailslot_info
)
1107 req
->handle
= hFile
;
1109 io
->u
.Status
= wine_server_call( req
);
1110 if( io
->u
.Status
== STATUS_SUCCESS
)
1112 info
->MaximumMessageSize
= reply
->max_msgsize
;
1113 info
->MailslotQuota
= 0;
1114 info
->NextMessageSize
= reply
->next_msgsize
;
1115 info
->MessagesAvailable
= reply
->msg_count
;
1116 info
->ReadTimeout
.QuadPart
= reply
->read_timeout
* -10000;
1123 FIXME("Unsupported class (%d)\n", class);
1124 io
->u
.Status
= STATUS_NOT_IMPLEMENTED
;
1127 wine_server_release_fd( hFile
, fd
);
1128 if (io
->u
.Status
== STATUS_SUCCESS
&& !io
->Information
) io
->Information
= info_sizes
[class];
1129 return io
->u
.Status
;
1132 /******************************************************************************
1133 * NtSetInformationFile [NTDLL.@]
1134 * ZwSetInformationFile [NTDLL.@]
1136 * Set information about an open file handle.
1139 * handle [I] Handle returned from ZwOpenFile() or ZwCreateFile()
1140 * io [O] Receives information about the operation on return
1141 * ptr [I] Source for file information
1142 * len [I] Size of FileInformation
1143 * class [I] Type of file information to set
1146 * Success: 0. io is updated.
1147 * Failure: An NTSTATUS error code describing the error.
1149 NTSTATUS WINAPI
NtSetInformationFile(HANDLE handle
, PIO_STATUS_BLOCK io
,
1150 PVOID ptr
, ULONG len
, FILE_INFORMATION_CLASS
class)
1154 TRACE("(%p,%p,%p,0x%08lx,0x%08x)\n", handle
, io
, ptr
, len
, class);
1156 if ((io
->u
.Status
= wine_server_handle_to_fd( handle
, 0, &fd
, NULL
)))
1157 return io
->u
.Status
;
1159 io
->u
.Status
= STATUS_SUCCESS
;
1162 case FileBasicInformation
:
1163 if (len
>= sizeof(FILE_BASIC_INFORMATION
))
1166 const FILE_BASIC_INFORMATION
*info
= ptr
;
1168 if (info
->LastAccessTime
.QuadPart
|| info
->LastWriteTime
.QuadPart
)
1170 ULONGLONG sec
, nsec
;
1171 struct timeval tv
[2];
1173 if (!info
->LastAccessTime
.QuadPart
|| !info
->LastWriteTime
.QuadPart
)
1176 tv
[0].tv_sec
= tv
[0].tv_usec
= 0;
1177 tv
[1].tv_sec
= tv
[1].tv_usec
= 0;
1178 if (!fstat( fd
, &st
))
1180 tv
[0].tv_sec
= st
.st_atime
;
1181 tv
[1].tv_sec
= st
.st_mtime
;
1184 if (info
->LastAccessTime
.QuadPart
)
1186 sec
= RtlLargeIntegerDivide( info
->LastAccessTime
.QuadPart
, 10000000, &nsec
);
1187 tv
[0].tv_sec
= sec
- SECS_1601_TO_1970
;
1188 tv
[0].tv_usec
= (UINT
)nsec
/ 10;
1190 if (info
->LastWriteTime
.QuadPart
)
1192 sec
= RtlLargeIntegerDivide( info
->LastWriteTime
.QuadPart
, 10000000, &nsec
);
1193 tv
[1].tv_sec
= sec
- SECS_1601_TO_1970
;
1194 tv
[1].tv_usec
= (UINT
)nsec
/ 10;
1196 if (futimes( fd
, tv
) == -1) io
->u
.Status
= FILE_GetNtStatus();
1199 if (io
->u
.Status
== STATUS_SUCCESS
&& info
->FileAttributes
)
1201 if (fstat( fd
, &st
) == -1) io
->u
.Status
= FILE_GetNtStatus();
1204 if (info
->FileAttributes
& FILE_ATTRIBUTE_READONLY
)
1206 if (S_ISDIR( st
.st_mode
))
1207 WARN("FILE_ATTRIBUTE_READONLY ignored for directory.\n");
1209 st
.st_mode
&= ~0222; /* clear write permission bits */
1213 /* add write permission only where we already have read permission */
1214 st
.st_mode
|= (0600 | ((st
.st_mode
& 044) >> 1)) & (~FILE_umask
);
1216 if (fchmod( fd
, st
.st_mode
) == -1) io
->u
.Status
= FILE_GetNtStatus();
1220 else io
->u
.Status
= STATUS_INVALID_PARAMETER_3
;
1223 case FilePositionInformation
:
1224 if (len
>= sizeof(FILE_POSITION_INFORMATION
))
1226 const FILE_POSITION_INFORMATION
*info
= ptr
;
1228 if (lseek( fd
, info
->CurrentByteOffset
.QuadPart
, SEEK_SET
) == (off_t
)-1)
1229 io
->u
.Status
= FILE_GetNtStatus();
1231 else io
->u
.Status
= STATUS_INVALID_PARAMETER_3
;
1234 case FileEndOfFileInformation
:
1235 if (len
>= sizeof(FILE_END_OF_FILE_INFORMATION
))
1238 const FILE_END_OF_FILE_INFORMATION
*info
= ptr
;
1240 /* first try normal truncate */
1241 if (ftruncate( fd
, (off_t
)info
->EndOfFile
.QuadPart
) != -1) break;
1243 /* now check for the need to extend the file */
1244 if (fstat( fd
, &st
) != -1 && (off_t
)info
->EndOfFile
.QuadPart
> st
.st_size
)
1246 static const char zero
;
1248 /* extend the file one byte beyond the requested size and then truncate it */
1249 /* this should work around ftruncate implementations that can't extend files */
1250 if (pwrite( fd
, &zero
, 1, (off_t
)info
->EndOfFile
.QuadPart
) != -1 &&
1251 ftruncate( fd
, (off_t
)info
->EndOfFile
.QuadPart
) != -1) break;
1253 io
->u
.Status
= FILE_GetNtStatus();
1255 else io
->u
.Status
= STATUS_INVALID_PARAMETER_3
;
1258 case FileMailslotSetInformation
:
1260 FILE_MAILSLOT_SET_INFORMATION
*info
= ptr
;
1262 SERVER_START_REQ( set_mailslot_info
)
1264 req
->handle
= handle
;
1265 req
->flags
= MAILSLOT_SET_READ_TIMEOUT
;
1266 req
->read_timeout
= info
->ReadTimeout
.QuadPart
/ -10000;
1267 io
->u
.Status
= wine_server_call( req
);
1274 FIXME("Unsupported class (%d)\n", class);
1275 io
->u
.Status
= STATUS_NOT_IMPLEMENTED
;
1278 wine_server_release_fd( handle
, fd
);
1279 io
->Information
= 0;
1280 return io
->u
.Status
;
1284 /******************************************************************************
1285 * NtQueryFullAttributesFile (NTDLL.@)
1287 NTSTATUS WINAPI
NtQueryFullAttributesFile( const OBJECT_ATTRIBUTES
*attr
,
1288 FILE_NETWORK_OPEN_INFORMATION
*info
)
1290 ANSI_STRING unix_name
;
1293 if (!(status
= wine_nt_to_unix_file_name( attr
->ObjectName
, &unix_name
, FILE_OPEN
,
1294 !(attr
->Attributes
& OBJ_CASE_INSENSITIVE
) )))
1298 if (stat( unix_name
.Buffer
, &st
) == -1)
1299 status
= FILE_GetNtStatus();
1300 else if (!S_ISREG(st
.st_mode
) && !S_ISDIR(st
.st_mode
))
1301 status
= STATUS_INVALID_INFO_CLASS
;
1304 if (S_ISDIR(st
.st_mode
))
1306 info
->FileAttributes
= FILE_ATTRIBUTE_DIRECTORY
;
1307 info
->AllocationSize
.QuadPart
= 0;
1308 info
->EndOfFile
.QuadPart
= 0;
1312 info
->FileAttributes
= FILE_ATTRIBUTE_ARCHIVE
;
1313 info
->AllocationSize
.QuadPart
= (ULONGLONG
)st
.st_blocks
* 512;
1314 info
->EndOfFile
.QuadPart
= st
.st_size
;
1316 if (!(st
.st_mode
& (S_IWUSR
| S_IWGRP
| S_IWOTH
)))
1317 info
->FileAttributes
|= FILE_ATTRIBUTE_READONLY
;
1318 RtlSecondsSince1970ToTime( st
.st_mtime
, &info
->CreationTime
);
1319 RtlSecondsSince1970ToTime( st
.st_mtime
, &info
->LastWriteTime
);
1320 RtlSecondsSince1970ToTime( st
.st_ctime
, &info
->ChangeTime
);
1321 RtlSecondsSince1970ToTime( st
.st_atime
, &info
->LastAccessTime
);
1322 if (DIR_is_hidden_file( attr
->ObjectName
))
1323 info
->FileAttributes
|= FILE_ATTRIBUTE_HIDDEN
;
1325 RtlFreeAnsiString( &unix_name
);
1327 else WARN("%s not found (%lx)\n", debugstr_us(attr
->ObjectName
), status
);
1332 /******************************************************************************
1333 * NtQueryAttributesFile (NTDLL.@)
1334 * ZwQueryAttributesFile (NTDLL.@)
1336 NTSTATUS WINAPI
NtQueryAttributesFile( const OBJECT_ATTRIBUTES
*attr
, FILE_BASIC_INFORMATION
*info
)
1338 FILE_NETWORK_OPEN_INFORMATION full_info
;
1341 if (!(status
= NtQueryFullAttributesFile( attr
, &full_info
)))
1343 info
->CreationTime
.QuadPart
= full_info
.CreationTime
.QuadPart
;
1344 info
->LastAccessTime
.QuadPart
= full_info
.LastAccessTime
.QuadPart
;
1345 info
->LastWriteTime
.QuadPart
= full_info
.LastWriteTime
.QuadPart
;
1346 info
->ChangeTime
.QuadPart
= full_info
.ChangeTime
.QuadPart
;
1347 info
->FileAttributes
= full_info
.FileAttributes
;
1353 /******************************************************************************
1354 * NtQueryVolumeInformationFile [NTDLL.@]
1355 * ZwQueryVolumeInformationFile [NTDLL.@]
1357 * Get volume information for an open file handle.
1360 * handle [I] Handle returned from ZwOpenFile() or ZwCreateFile()
1361 * io [O] Receives information about the operation on return
1362 * buffer [O] Destination for volume information
1363 * length [I] Size of FsInformation
1364 * info_class [I] Type of volume information to set
1367 * Success: 0. io and buffer are updated.
1368 * Failure: An NTSTATUS error code describing the error.
1370 NTSTATUS WINAPI
NtQueryVolumeInformationFile( HANDLE handle
, PIO_STATUS_BLOCK io
,
1371 PVOID buffer
, ULONG length
,
1372 FS_INFORMATION_CLASS info_class
)
1377 if ((io
->u
.Status
= wine_server_handle_to_fd( handle
, 0, &fd
, NULL
)) != STATUS_SUCCESS
)
1378 return io
->u
.Status
;
1380 io
->u
.Status
= STATUS_NOT_IMPLEMENTED
;
1381 io
->Information
= 0;
1383 switch( info_class
)
1385 case FileFsVolumeInformation
:
1386 FIXME( "%p: volume info not supported\n", handle
);
1388 case FileFsLabelInformation
:
1389 FIXME( "%p: label info not supported\n", handle
);
1391 case FileFsSizeInformation
:
1392 if (length
< sizeof(FILE_FS_SIZE_INFORMATION
))
1393 io
->u
.Status
= STATUS_BUFFER_TOO_SMALL
;
1396 FILE_FS_SIZE_INFORMATION
*info
= buffer
;
1398 if (fstat( fd
, &st
) < 0)
1400 io
->u
.Status
= FILE_GetNtStatus();
1403 if (!S_ISREG(st
.st_mode
) && !S_ISDIR(st
.st_mode
))
1405 io
->u
.Status
= STATUS_INVALID_DEVICE_REQUEST
;
1409 /* Linux's fstatvfs is buggy */
1410 #if !defined(linux) || !defined(HAVE_FSTATFS)
1411 struct statvfs stfs
;
1413 if (fstatvfs( fd
, &stfs
) < 0)
1415 io
->u
.Status
= FILE_GetNtStatus();
1418 info
->BytesPerSector
= stfs
.f_frsize
;
1421 if (fstatfs( fd
, &stfs
) < 0)
1423 io
->u
.Status
= FILE_GetNtStatus();
1426 info
->BytesPerSector
= stfs
.f_bsize
;
1428 info
->TotalAllocationUnits
.QuadPart
= stfs
.f_blocks
;
1429 info
->AvailableAllocationUnits
.QuadPart
= stfs
.f_bavail
;
1430 info
->SectorsPerAllocationUnit
= 1;
1431 io
->Information
= sizeof(*info
);
1432 io
->u
.Status
= STATUS_SUCCESS
;
1436 case FileFsDeviceInformation
:
1437 if (length
< sizeof(FILE_FS_DEVICE_INFORMATION
))
1438 io
->u
.Status
= STATUS_BUFFER_TOO_SMALL
;
1441 FILE_FS_DEVICE_INFORMATION
*info
= buffer
;
1443 info
->Characteristics
= 0;
1444 if (fstat( fd
, &st
) < 0)
1446 io
->u
.Status
= FILE_GetNtStatus();
1449 if (S_ISCHR( st
.st_mode
))
1451 info
->DeviceType
= FILE_DEVICE_UNKNOWN
;
1453 switch(major(st
.st_rdev
))
1456 info
->DeviceType
= FILE_DEVICE_NULL
;
1459 info
->DeviceType
= FILE_DEVICE_SERIAL_PORT
;
1462 info
->DeviceType
= FILE_DEVICE_PARALLEL_PORT
;
1467 else if (S_ISBLK( st
.st_mode
))
1469 info
->DeviceType
= FILE_DEVICE_DISK
;
1471 else if (S_ISFIFO( st
.st_mode
) || S_ISSOCK( st
.st_mode
))
1473 info
->DeviceType
= FILE_DEVICE_NAMED_PIPE
;
1475 else /* regular file or directory */
1477 #if defined(linux) && defined(HAVE_FSTATFS)
1480 /* check for floppy disk */
1481 if (major(st
.st_dev
) == FLOPPY_MAJOR
)
1482 info
->Characteristics
|= FILE_REMOVABLE_MEDIA
;
1484 if (fstatfs( fd
, &stfs
) < 0) stfs
.f_type
= 0;
1485 switch (stfs
.f_type
)
1487 case 0x9660: /* iso9660 */
1488 case 0x15013346: /* udf */
1489 info
->DeviceType
= FILE_DEVICE_CD_ROM_FILE_SYSTEM
;
1490 info
->Characteristics
|= FILE_REMOVABLE_MEDIA
|FILE_READ_ONLY_DEVICE
;
1492 case 0x6969: /* nfs */
1493 case 0x517B: /* smbfs */
1494 case 0x564c: /* ncpfs */
1495 info
->DeviceType
= FILE_DEVICE_NETWORK_FILE_SYSTEM
;
1496 info
->Characteristics
|= FILE_REMOTE_DEVICE
;
1498 case 0x01021994: /* tmpfs */
1499 case 0x28cd3d45: /* cramfs */
1500 case 0x1373: /* devfs */
1501 case 0x9fa0: /* procfs */
1502 info
->DeviceType
= FILE_DEVICE_VIRTUAL_DISK
;
1505 info
->DeviceType
= FILE_DEVICE_DISK_FILE_SYSTEM
;
1508 #elif defined(__FreeBSD__)
1511 /* The proper way to do this in FreeBSD seems to be with the
1512 * name rather than the type, since their linux-compatible
1513 * fstatfs call converts the name to one of the Linux types.
1515 if (fstatfs( fd
, &stfs
) < 0)
1516 info
->DeviceType
= FILE_DEVICE_DISK_FILE_SYSTEM
;
1517 else if (!strncmp("cd9660", stfs
.f_fstypename
,
1518 sizeof(stfs
.f_fstypename
)))
1520 info
->DeviceType
= FILE_DEVICE_CD_ROM_FILE_SYSTEM
;
1521 /* Don't assume read-only, let the mount options set it
1524 info
->Characteristics
|= FILE_REMOVABLE_MEDIA
;
1526 else if (!strncmp("nfs", stfs
.f_fstypename
,
1527 sizeof(stfs
.f_fstypename
)))
1529 info
->DeviceType
= FILE_DEVICE_NETWORK_FILE_SYSTEM
;
1530 info
->Characteristics
|= FILE_REMOTE_DEVICE
;
1532 else if (!strncmp("nwfs", stfs
.f_fstypename
,
1533 sizeof(stfs
.f_fstypename
)))
1535 info
->DeviceType
= FILE_DEVICE_NETWORK_FILE_SYSTEM
;
1536 info
->Characteristics
|= FILE_REMOTE_DEVICE
;
1538 else if (!strncmp("procfs", stfs
.f_fstypename
,
1539 sizeof(stfs
.f_fstypename
)))
1540 info
->DeviceType
= FILE_DEVICE_VIRTUAL_DISK
;
1542 info
->DeviceType
= FILE_DEVICE_DISK_FILE_SYSTEM
;
1543 if (stfs
.f_flags
& MNT_RDONLY
)
1544 info
->Characteristics
|= FILE_READ_ONLY_DEVICE
;
1545 if (!(stfs
.f_flags
& MNT_LOCAL
))
1547 info
->DeviceType
= FILE_DEVICE_NETWORK_FILE_SYSTEM
;
1548 info
->Characteristics
|= FILE_REMOTE_DEVICE
;
1550 #elif defined (__APPLE__)
1551 # include <IOKit/IOKitLib.h>
1552 # include <CoreFoundation/CFNumber.h> /* for kCFBooleanTrue, kCFBooleanFalse */
1556 info
->DeviceType
= FILE_DEVICE_DISK_FILE_SYSTEM
;
1558 if (fstatfs( fd
, &stfs
) < 0) break;
1560 /* stfs.f_type is reserved (always set to 0) so use IOKit */
1561 kern_return_t kernResult
= KERN_FAILURE
;
1562 mach_port_t masterPort
;
1564 char bsdName
[6]; /* disk#\0 */
1565 const char *name
= stfs
.f_mntfromname
+ strlen(_PATH_DEV
);
1566 memcpy( bsdName
, name
, min(strlen(name
)+1,sizeof(bsdName
)) );
1567 bsdName
[sizeof(bsdName
)-1] = 0;
1569 kernResult
= IOMasterPort(MACH_PORT_NULL
, &masterPort
);
1571 if (kernResult
== KERN_SUCCESS
)
1573 CFMutableDictionaryRef matching
= IOBSDNameMatching(masterPort
, 0, bsdName
);
1577 CFMutableDictionaryRef properties
;
1578 io_service_t devService
= IOServiceGetMatchingService(masterPort
, matching
);
1580 if (IORegistryEntryCreateCFProperties(devService
,
1582 kCFAllocatorDefault
, 0) != KERN_SUCCESS
)
1585 CFDictionaryGetValue(properties
, CFSTR("Removable")),
1587 ) info
->Characteristics
|= FILE_REMOVABLE_MEDIA
;
1590 CFDictionaryGetValue(properties
, CFSTR("Writable")),
1592 ) info
->Characteristics
|= FILE_READ_ONLY_DEVICE
;
1595 NB : mounted disk image (.img/.dmg) don't provide specific type
1598 if ( (type
= CFDictionaryGetValue(properties
, CFSTR("Type"))) )
1600 if ( CFStringCompare(type
, CFSTR("CD-ROM"), 0) == kCFCompareEqualTo
1601 || CFStringCompare(type
, CFSTR("DVD-ROM"), 0) == kCFCompareEqualTo
1604 info
->DeviceType
= FILE_DEVICE_CD_ROM_FILE_SYSTEM
;
1609 CFRelease(properties
);
1613 /* Use dkio to work out device types */
1615 # include <sys/dkio.h>
1616 # include <sys/vtoc.h>
1617 struct dk_cinfo dkinf
;
1618 int retval
= ioctl(fd
, DKIOCINFO
, &dkinf
);
1620 WARN("Unable to get disk device type information - assuming a disk like device\n");
1621 info
->DeviceType
= FILE_DEVICE_DISK_FILE_SYSTEM
;
1623 switch (dkinf
.dki_ctype
)
1626 info
->DeviceType
= FILE_DEVICE_CD_ROM_FILE_SYSTEM
;
1627 info
->Characteristics
|= FILE_REMOVABLE_MEDIA
|FILE_READ_ONLY_DEVICE
;
1631 case DKC_INTEL82072
:
1632 case DKC_INTEL82077
:
1633 info
->DeviceType
= FILE_DEVICE_DISK_FILE_SYSTEM
;
1634 info
->Characteristics
|= FILE_REMOVABLE_MEDIA
;
1637 info
->DeviceType
= FILE_DEVICE_VIRTUAL_DISK
;
1640 info
->DeviceType
= FILE_DEVICE_DISK_FILE_SYSTEM
;
1645 if (!warned
++) FIXME( "device info not properly supported on this platform\n" );
1646 info
->DeviceType
= FILE_DEVICE_DISK_FILE_SYSTEM
;
1648 info
->Characteristics
|= FILE_DEVICE_IS_MOUNTED
;
1650 io
->Information
= sizeof(*info
);
1651 io
->u
.Status
= STATUS_SUCCESS
;
1654 case FileFsAttributeInformation
:
1655 FIXME( "%p: attribute info not supported\n", handle
);
1657 case FileFsControlInformation
:
1658 FIXME( "%p: control info not supported\n", handle
);
1660 case FileFsFullSizeInformation
:
1661 FIXME( "%p: full size info not supported\n", handle
);
1663 case FileFsObjectIdInformation
:
1664 FIXME( "%p: object id info not supported\n", handle
);
1666 case FileFsMaximumInformation
:
1667 FIXME( "%p: maximum info not supported\n", handle
);
1670 io
->u
.Status
= STATUS_INVALID_PARAMETER
;
1673 wine_server_release_fd( handle
, fd
);
1674 return io
->u
.Status
;
1678 /******************************************************************
1679 * NtFlushBuffersFile (NTDLL.@)
1681 * Flush any buffered data on an open file handle.
1684 * FileHandle [I] Handle returned from ZwOpenFile() or ZwCreateFile()
1685 * IoStatusBlock [O] Receives information about the operation on return
1688 * Success: 0. IoStatusBlock is updated.
1689 * Failure: An NTSTATUS error code describing the error.
1691 NTSTATUS WINAPI
NtFlushBuffersFile( HANDLE hFile
, IO_STATUS_BLOCK
* IoStatusBlock
)
1694 HANDLE hEvent
= NULL
;
1696 SERVER_START_REQ( flush_file
)
1698 req
->handle
= hFile
;
1699 ret
= wine_server_call( req
);
1700 hEvent
= reply
->event
;
1705 ret
= NtWaitForSingleObject( hEvent
, FALSE
, NULL
);
1711 /******************************************************************
1712 * NtLockFile (NTDLL.@)
1716 NTSTATUS WINAPI
NtLockFile( HANDLE hFile
, HANDLE lock_granted_event
,
1717 PIO_APC_ROUTINE apc
, void* apc_user
,
1718 PIO_STATUS_BLOCK io_status
, PLARGE_INTEGER offset
,
1719 PLARGE_INTEGER count
, ULONG
* key
, BOOLEAN dont_wait
,
1726 if (apc
|| io_status
|| key
)
1728 FIXME("Unimplemented yet parameter\n");
1729 return STATUS_NOT_IMPLEMENTED
;
1734 SERVER_START_REQ( lock_file
)
1736 req
->handle
= hFile
;
1737 req
->offset_low
= offset
->u
.LowPart
;
1738 req
->offset_high
= offset
->u
.HighPart
;
1739 req
->count_low
= count
->u
.LowPart
;
1740 req
->count_high
= count
->u
.HighPart
;
1741 req
->shared
= !exclusive
;
1742 req
->wait
= !dont_wait
;
1743 ret
= wine_server_call( req
);
1744 handle
= reply
->handle
;
1745 async
= reply
->overlapped
;
1748 if (ret
!= STATUS_PENDING
)
1750 if (!ret
&& lock_granted_event
) NtSetEvent(lock_granted_event
, NULL
);
1756 FIXME( "Async I/O lock wait not implemented, might deadlock\n" );
1757 if (handle
) NtClose( handle
);
1758 return STATUS_PENDING
;
1762 NtWaitForSingleObject( handle
, FALSE
, NULL
);
1769 /* Unix lock conflict, sleep a bit and retry */
1770 time
.QuadPart
= 100 * (ULONGLONG
)10000;
1771 time
.QuadPart
= -time
.QuadPart
;
1772 NtDelayExecution( FALSE
, &time
);
1778 /******************************************************************
1779 * NtUnlockFile (NTDLL.@)
1783 NTSTATUS WINAPI
NtUnlockFile( HANDLE hFile
, PIO_STATUS_BLOCK io_status
,
1784 PLARGE_INTEGER offset
, PLARGE_INTEGER count
,
1789 TRACE( "%p %lx%08lx %lx%08lx\n",
1790 hFile
, offset
->u
.HighPart
, offset
->u
.LowPart
, count
->u
.HighPart
, count
->u
.LowPart
);
1792 if (io_status
|| key
)
1794 FIXME("Unimplemented yet parameter\n");
1795 return STATUS_NOT_IMPLEMENTED
;
1798 SERVER_START_REQ( unlock_file
)
1800 req
->handle
= hFile
;
1801 req
->offset_low
= offset
->u
.LowPart
;
1802 req
->offset_high
= offset
->u
.HighPart
;
1803 req
->count_low
= count
->u
.LowPart
;
1804 req
->count_high
= count
->u
.HighPart
;
1805 status
= wine_server_call( req
);
1811 /******************************************************************
1812 * NtCreateNamedPipeFile (NTDLL.@)
1816 NTSTATUS WINAPI
NtCreateNamedPipeFile( PHANDLE handle
, ULONG access
,
1817 POBJECT_ATTRIBUTES oa
, PIO_STATUS_BLOCK iosb
,
1818 ULONG sharing
, ULONG dispo
, ULONG options
,
1819 ULONG pipe_type
, ULONG read_mode
,
1820 ULONG completion_mode
, ULONG max_inst
,
1821 ULONG inbound_quota
, ULONG outbound_quota
,
1822 PLARGE_INTEGER timeout
)
1825 static const WCHAR leadin
[] = {'\\','?','?','\\','P','I','P','E','\\'};
1827 TRACE("(%p %lx %p %p %lx %ld %lx %ld %ld %ld %ld %ld %ld %p): stub\n",
1828 handle
, access
, oa
, iosb
, sharing
, dispo
, options
, pipe_type
,
1829 read_mode
, completion_mode
, max_inst
, inbound_quota
, outbound_quota
,
1832 if (oa
->ObjectName
->Length
< sizeof(leadin
) ||
1833 strncmpiW( oa
->ObjectName
->Buffer
,
1834 leadin
, sizeof(leadin
)/sizeof(leadin
[0]) ))
1835 return STATUS_OBJECT_NAME_INVALID
;
1836 /* assume we only get relative timeout, and storable in a DWORD as ms */
1837 if (timeout
->QuadPart
> 0 || (timeout
->QuadPart
/ -10000) >> 32)
1838 FIXME("Wrong time %s\n", wine_dbgstr_longlong(timeout
->QuadPart
));
1840 SERVER_START_REQ( create_named_pipe
)
1842 req
->options
= options
; /* FIXME not used in server yet !!!! */
1844 (pipe_type
) ? NAMED_PIPE_MESSAGE_STREAM_WRITE
: 0 |
1845 (read_mode
) ? NAMED_PIPE_MESSAGE_STREAM_READ
: 0 |
1846 (completion_mode
) ? NAMED_PIPE_NONBLOCKING_MODE
: 0;
1847 req
->maxinstances
= max_inst
;
1848 req
->outsize
= outbound_quota
;
1849 req
->insize
= inbound_quota
;
1850 req
->timeout
= timeout
->QuadPart
/ -10000;
1851 req
->inherit
= (oa
->Attributes
& OBJ_INHERIT
) != 0;
1852 wine_server_add_data( req
, oa
->ObjectName
->Buffer
+ 4,
1853 oa
->ObjectName
->Length
- 4 * sizeof(WCHAR
) );
1854 status
= wine_server_call( req
);
1855 if (!status
) *handle
= reply
->handle
;
1861 /******************************************************************
1862 * NtDeleteFile (NTDLL.@)
1866 NTSTATUS WINAPI
NtDeleteFile( POBJECT_ATTRIBUTES ObjectAttributes
)
1872 TRACE("%p\n", ObjectAttributes
);
1873 status
= NtCreateFile( &hFile
, GENERIC_READ
| GENERIC_WRITE
, ObjectAttributes
,
1875 FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
1876 FILE_OPEN
, FILE_DELETE_ON_CLOSE
, NULL
, 0 );
1877 if (status
== STATUS_SUCCESS
) status
= NtClose(hFile
);
1881 /******************************************************************
1882 * NtCancelIoFile (NTDLL.@)
1886 NTSTATUS WINAPI
NtCancelIoFile( HANDLE hFile
, PIO_STATUS_BLOCK io_status
)
1888 LARGE_INTEGER timeout
;
1890 TRACE("%p %p\n", hFile
, io_status
);
1892 SERVER_START_REQ( cancel_async
)
1894 req
->handle
= hFile
;
1895 wine_server_call( req
);
1898 /* Let some APC be run, so that we can run the remaining APCs on hFile
1899 * either the cancelation of the pending one, but also the execution
1900 * of the queued APC, but not yet run. This is needed to ensure proper
1901 * clean-up of allocated data.
1903 timeout
.u
.LowPart
= timeout
.u
.HighPart
= 0;
1904 return io_status
->u
.Status
= NtDelayExecution( TRUE
, &timeout
);
1907 /******************************************************************************
1908 * NtCreateMailslotFile [NTDLL.@]
1909 * ZwCreateMailslotFile [NTDLL.@]
1912 * pHandle [O] pointer to receive the handle created
1913 * DesiredAccess [I] access mode (read, write, etc)
1914 * ObjectAttributes [I] fully qualified NT path of the mailslot
1915 * IoStatusBlock [O] receives completion status and other info
1918 * MaxMessageSize [I]
1924 NTSTATUS WINAPI
NtCreateMailslotFile(PHANDLE pHandle
, ULONG DesiredAccess
,
1925 POBJECT_ATTRIBUTES attr
, PIO_STATUS_BLOCK IoStatusBlock
,
1926 ULONG CreateOptions
, ULONG MailslotQuota
, ULONG MaxMessageSize
,
1927 PLARGE_INTEGER TimeOut
)
1929 static const WCHAR leadin
[] = {
1930 '\\','?','?','\\','M','A','I','L','S','L','O','T','\\'};
1933 TRACE("%p %08lx %p %p %08lx %08lx %08lx %p\n",
1934 pHandle
, DesiredAccess
, attr
, IoStatusBlock
,
1935 CreateOptions
, MailslotQuota
, MaxMessageSize
, TimeOut
);
1937 if (attr
->ObjectName
->Length
< sizeof(leadin
) ||
1938 strncmpiW( attr
->ObjectName
->Buffer
,
1939 leadin
, sizeof(leadin
)/sizeof(leadin
[0]) ))
1941 return STATUS_OBJECT_NAME_INVALID
;
1944 SERVER_START_REQ( create_mailslot
)
1946 req
->max_msgsize
= MaxMessageSize
;
1947 req
->read_timeout
= TimeOut
->QuadPart
/ -10000;
1948 req
->inherit
= (attr
->Attributes
& OBJ_INHERIT
) != 0;
1949 wine_server_add_data( req
, attr
->ObjectName
->Buffer
+ 4,
1950 attr
->ObjectName
->Length
- 4*sizeof(WCHAR
) );
1951 ret
= wine_server_call( req
);
1952 if( ret
== STATUS_SUCCESS
)
1953 *pHandle
= reply
->handle
;