Hallo, on Alexandre's request here a patch to get the number of bytes available for read in PeekNamedPipe, doing the fd manipulation on the client side. As I don't have a test target, I don't feel yet like filling lpvBuffer and I don't yet have an idea how to do that. I looked at the kernel sources and lseek unconditionally returns error on pipe. So how can we read the pipe and get the filepointer back to the original position afterwards? Long Changelog: wine/server/protocol.def Define a FD_TYPE_PIPE wine/server/file.c: get_handle_fd On type FD_TYPE_PIPE check other end of type wine/server/pipe.c, wine/server/named_pipe.c: get_file_info Return FD_TYPE_PIPE dlls/kernel/sync.c: PeekNamedPipe Use FIONREAD to get number of bytes available to read Changelog: wine/server/protocol.def, wine/server/file.c, wine/server/pipe.c, wine/server/named_pipe.c, dlls/kernel/sync.c: Fill lpcbAvail for PeekNamedPipe -- Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de Free Software: If you contribute nothing, expect nothing -- Index: wine/server/protocol.def =================================================================== RCS file: /home/wine/wine/server/protocol.def,v retrieving revision 1.39 diff -u -r1.39 protocol.def --- wine/server/protocol.def 2 Jun 2002 21:22:22 -0000 1.39 +++ wine/server/protocol.def 23 Jul 2002 19:57:11 -0000 @@ -603,7 +603,8 @@ FD_TYPE_DEFAULT, FD_TYPE_CONSOLE, FD_TYPE_SOCKET, - FD_TYPE_SMB + FD_TYPE_SMB, + FD_TYPE_PIPE }; #define FD_FLAG_OVERLAPPED 0x01 #define FD_FLAG_TIMEOUT 0x02 Index: wine/server/file.c =================================================================== RCS file: /home/wine/wine/server/file.c,v retrieving revision 1.58 diff -u -r1.58 file.c --- wine/server/file.c 30 May 2002 20:12:58 -0000 1.58 +++ wine/server/file.c 23 Jul 2002 19:57:11 -0000 @@ -644,7 +644,11 @@ send_client_fd( current->process, fd, req->handle ); } reply->type = obj->ops->get_file_info( obj, NULL, &reply->flags ); - release_object( obj ); + if (reply->type == FD_TYPE_PIPE) + /* validate that the other end of the pipe is alive*/ + if ((fd = obj->ops->get_fd( obj )) == -1) + reply->fd = -1; + release_object( obj ); } } Index: wine/server/pipe.c =================================================================== RCS file: /home/wine/wine/server/pipe.c,v retrieving revision 1.24 diff -u -r1.24 pipe.c --- wine/server/pipe.c 30 May 2002 20:12:58 -0000 1.24 +++ wine/server/pipe.c 23 Jul 2002 19:57:11 -0000 @@ -155,7 +155,7 @@ reply->serial = 0; } *flags = 0; - return FD_TYPE_DEFAULT; + return FD_TYPE_PIPE; } static void pipe_destroy( struct object *obj ) Index: wine/server/named_pipe.c =================================================================== RCS file: /home/wine/wine/server/named_pipe.c,v retrieving revision 1.14 diff -u -r1.14 named_pipe.c --- wine/server/named_pipe.c 31 May 2002 23:06:53 -0000 1.14 +++ wine/server/named_pipe.c 23 Jul 2002 19:57:11 -0000 @@ -215,7 +215,7 @@ reply->serial = 0; } *flags = 0; - return FD_TYPE_DEFAULT; + return FD_TYPE_PIPE; } static struct named_pipe *create_named_pipe( const WCHAR *name, size_t len ) Index: wine/dlls/kernel/sync.c =================================================================== RCS file: /home/wine/wine/dlls/kernel/sync.c,v retrieving revision 1.20 diff -u -r1.20 sync.c --- wine/dlls/kernel/sync.c 31 May 2002 23:25:48 -0000 1.20 +++ wine/dlls/kernel/sync.c 23 Jul 2002 19:57:12 -0000 @@ -21,6 +21,9 @@ #include "config.h" #include <string.h> +#include <sys/ioctl.h> +#include <unistd.h> +#include <errno.h> #include "winbase.h" #include "winerror.h" @@ -28,6 +31,7 @@ #include "wine/server.h" #include "wine/unicode.h" +#include "file.h" #include "wine/debug.h" @@ -530,9 +534,28 @@ BOOL WINAPI PeekNamedPipe( HANDLE hPipe, LPVOID lpvBuffer, DWORD cbBuffer, LPDWORD lpcbRead, LPDWORD lpcbAvail, LPDWORD lpcbMessage ) { - FIXME("(%08x, %p, %08lx, %p, %p, %p): stub\n", - hPipe, lpvBuffer, cbBuffer, lpcbRead, lpcbAvail, lpcbMessage); + int avail=0,fd; + + fd = FILE_GetUnixHandle(hPipe, GENERIC_READ); + if (fd == -1) + return FALSE; + /* On linux fstat on pipes doesn't work */ + if (ioctl(fd,FIONREAD, &avail ) != 0) + { + TRACE("FINOREAD failed reason: %s\n",strerror(errno)); + return FALSE; + } + else + close(fd); + TRACE(" 0x%08x bytes available\n", avail ); + if (!lpvBuffer && lpcbAvail) + { + *lpcbAvail= avail; + return TRUE; + } + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + FIXME("function not implemented\n"); return FALSE; }