Skip to content
Snippets Groups Projects
Commit fc932611 authored by Michael McCormack's avatar Michael McCormack Committed by Alexandre Julliard
Browse files

Begin to make wine an SMB client.

parent ae6075c0
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ C_SRCS = \
drive.c \
file.c \
profile.c \
smb.c \
tape.c
all: $(MODULE).o
......
......@@ -56,6 +56,8 @@
#include "heap.h"
#include "msdos.h"
#include "wincon.h"
#include "smb.h"
#include "wine/debug.h"
#include "wine/server.h"
......@@ -74,6 +76,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(file);
static HANDLE dos_handles[DOS_TABLE_SIZE];
extern WINAPI HANDLE FILE_SmbOpen(LPCSTR name);
/***********************************************************************
* FILE_ConvertOFMode
......@@ -480,9 +483,8 @@ HANDLE WINAPI CreateFileA( LPCSTR filename, DWORD access, DWORD sharing,
/* If the name still starts with '\\', it's a UNC name. */
if (!strncmp(filename, "\\\\", 2))
{
FIXME("UNC name (%s) not supported.\n", filename );
SetLastError( ERROR_PATH_NOT_FOUND );
return INVALID_HANDLE_VALUE;
ret = SMB_CreateFileA(filename, access, sharing, sa, creation, attributes, template );
goto done;
}
/* If the name contains a DOS wild card (* or ?), do no create a file */
......@@ -1531,6 +1533,8 @@ BOOL WINAPI ReadFile( HANDLE hFile, LPVOID buffer, DWORD bytesToRead,
}
switch(type)
{
case FD_TYPE_SMB:
return SMB_ReadFile(hFile, buffer, bytesToRead, bytesRead, NULL);
case FD_TYPE_CONSOLE:
return ReadConsoleA(hFile, buffer, bytesToRead, bytesRead, NULL);
......
files/smb.c 0 → 100644
This diff is collapsed.
/*
* Copyright (C) 2002 Mike McCormack
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __INC_SMB__
#define __INC_SMB__
#define NBR_ADDWORD(p,word) { (p)[1] = (word & 0xff); (p)[0] = ((word)>>8)&0xff; }
#define NBR_GETWORD(p) ( (((p)[0])<<8) | ((p)[1]) )
#define SMB_ADDWORD(p,word) { (p)[0] = (word & 0xff); (p)[1] = ((word)>>8)&0xff; }
#define SMB_GETWORD(p) ( (((p)[1])<<8) | ((p)[0]) )
#define SMB_ADDDWORD(p,w) { (p)[3]=((w)>>24)&0xff; (p)[2]=((w)>>16)&0xff; (p)[1]=((w)>>8)&0xff; (p)[0]=(w)&0xff; }
#define SMB_COM_CREATE_DIRECTORY 0x00
#define SMB_COM_DELETE_DIRECTORY 0x01
#define SMB_COM_OPEN 0x02
#define SMB_COM_CREATE 0x03
#define SMB_COM_CLOSE 0x04
#define SMB_COM_FLUSH 0x05
#define SMB_COM_DELETE 0x06
#define SMB_COM_RENAME 0x07
#define SMB_COM_QUERY_INFORMATION 0x08
#define SMB_COM_SET_INFORMATION 0x09
#define SMB_COM_READ 0x0A
#define SMB_COM_WRITE 0x0B
#define SMB_COM_LOCK_BYTE_RANGE 0x0C
#define SMB_COM_UNLOCK_BYTE_RANGE 0x0D
#define SMB_COM_CREATE_TEMPORARY 0x0E
#define SMB_COM_CREATE_NEW 0x0F
#define SMB_COM_CHECK_DIRECTORY 0x10
#define SMB_COM_PROCESS_EXIT 0x11
#define SMB_COM_SEEK 0x12
#define SMB_COM_LOCK_AND_READ 0x13
#define SMB_COM_WRITE_AND_UNLOCK 0x14
#define SMB_COM_READ_RAW 0x1A
#define SMB_COM_READ_MPX 0x1B
#define SMB_COM_READ_MPX_SECONDARY 0x1C
#define SMB_COM_WRITE_RAW 0x1D
#define SMB_COM_WRITE_MPX 0x1E
#define SMB_COM_WRITE_COMPLETE 0x20
#define SMB_COM_SET_INFORMATION2 0x22
#define SMB_COM_QUERY_INFORMATION2 0x23
#define SMB_COM_LOCKING_ANDX 0x24
#define SMB_COM_TRANSACTION 0x25
#define SMB_COM_TRANSACTION_SECONDARY 0x26
#define SMB_COM_IOCTL 0x27
#define SMB_COM_IOCTL_SECONDARY 0x28
#define SMB_COM_COPY 0x29
#define SMB_COM_MOVE 0x2A
#define SMB_COM_ECHO 0x2B
#define SMB_COM_WRITE_AND_CLOSE 0x2C
#define SMB_COM_OPEN_ANDX 0x2D
#define SMB_COM_READ_ANDX 0x2E
#define SMB_COM_WRITE_ANDX 0x2F
#define SMB_COM_CLOSE_AND_TREE_DISC 0x31
#define SMB_COM_TRANSACTION2 0x32
#define SMB_COM_TRANSACTION2_SECONDARY 0x33
#define SMB_COM_FIND_CLOSE2 0x34
#define SMB_COM_FIND_NOTIFY_CLOSE 0x35
#define SMB_COM_TREE_CONNECT 0x70
#define SMB_COM_TREE_DISCONNECT 0x71
#define SMB_COM_NEGOTIATE 0x72
#define SMB_COM_SESSION_SETUP_ANDX 0x73
#define SMB_COM_LOGOFF_ANDX 0x74
#define SMB_COM_TREE_CONNECT_ANDX 0x75
#define SMB_COM_QUERY_INFORMATION_DISK 0x80
#define SMB_COM_SEARCH 0x81
#define SMB_COM_FIND 0x82
#define SMB_COM_FIND_UNIQUE 0x83
#define SMB_COM_NT_TRANSACT 0xA0
#define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
#define SMB_COM_NT_CREATE_ANDX 0xA2
#define SMB_COM_NT_CANCEL 0xA4
#define SMB_COM_OPEN_PRINT_FILE 0xC0
#define SMB_COM_WRITE_PRINT_FILE 0xC1
#define SMB_COM_CLOSE_PRINT_FILE 0xC2
#define SMB_COM_GET_PRINT_QUEUE 0xC3
extern WINAPI BOOL SMB_ReadFile(HANDLE hFile, LPVOID buffer, DWORD bytesToRead, LPDWORD bytesRead, LPOVERLAPPED lpOverlapped);
extern HANDLE WINAPI SMB_CreateFileA( LPCSTR filename, DWORD access, DWORD sharing,
LPSECURITY_ATTRIBUTES sa, DWORD creation,
DWORD attributes, HANDLE template );
#endif /* __INC_SMB__ */
......@@ -736,7 +736,8 @@ enum fd_type
{
FD_TYPE_INVALID,
FD_TYPE_DEFAULT,
FD_TYPE_CONSOLE
FD_TYPE_CONSOLE,
FD_TYPE_SMB
};
#define FD_FLAG_OVERLAPPED 0x01
#define FD_FLAG_TIMEOUT 0x02
......@@ -2321,6 +2322,41 @@ struct get_named_pipe_info_reply
};
struct create_smb_request
{
struct request_header __header;
int fd;
unsigned int tree_id;
unsigned int user_id;
unsigned int file_id;
unsigned int dialect;
};
struct create_smb_reply
{
struct reply_header __header;
handle_t handle;
};
struct get_smb_info_request
{
struct request_header __header;
handle_t handle;
unsigned int flags;
unsigned int offset;
};
struct get_smb_info_reply
{
struct reply_header __header;
unsigned int tree_id;
unsigned int user_id;
unsigned int dialect;
unsigned int file_id;
unsigned int offset;
};
#define SMBINFO_SET_OFFSET 0x01
struct create_window_request
{
......@@ -2742,6 +2778,8 @@ enum request
REQ_wait_named_pipe,
REQ_disconnect_named_pipe,
REQ_get_named_pipe_info,
REQ_create_smb,
REQ_get_smb_info,
REQ_create_window,
REQ_link_window,
REQ_destroy_window,
......@@ -2899,6 +2937,8 @@ union generic_request
struct wait_named_pipe_request wait_named_pipe_request;
struct disconnect_named_pipe_request disconnect_named_pipe_request;
struct get_named_pipe_info_request get_named_pipe_info_request;
struct create_smb_request create_smb_request;
struct get_smb_info_request get_smb_info_request;
struct create_window_request create_window_request;
struct link_window_request link_window_request;
struct destroy_window_request destroy_window_request;
......@@ -3054,6 +3094,8 @@ union generic_reply
struct wait_named_pipe_reply wait_named_pipe_reply;
struct disconnect_named_pipe_reply disconnect_named_pipe_reply;
struct get_named_pipe_info_reply get_named_pipe_info_reply;
struct create_smb_reply create_smb_reply;
struct get_smb_info_reply get_smb_info_reply;
struct create_window_reply create_window_reply;
struct link_window_reply link_window_reply;
struct destroy_window_reply destroy_window_reply;
......@@ -3075,6 +3117,6 @@ union generic_reply
struct get_window_properties_reply get_window_properties_reply;
};
#define SERVER_PROTOCOL_VERSION 72
#define SERVER_PROTOCOL_VERSION 73
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
......@@ -31,6 +31,7 @@ C_SRCS = \
select.c \
semaphore.c \
serial.c \
smb.c \
snapshot.c \
sock.c \
thread.c \
......
......@@ -563,7 +563,8 @@ enum fd_type
{
FD_TYPE_INVALID,
FD_TYPE_DEFAULT,
FD_TYPE_CONSOLE
FD_TYPE_CONSOLE,
FD_TYPE_SMB
};
#define FD_FLAG_OVERLAPPED 0x01
#define FD_FLAG_TIMEOUT 0x02
......@@ -1634,6 +1635,31 @@ enum message_type
@END
@REQ(create_smb)
int fd;
unsigned int tree_id;
unsigned int user_id;
unsigned int file_id;
unsigned int dialect;
@REPLY
handle_t handle;
@END
@REQ(get_smb_info)
handle_t handle;
unsigned int flags;
unsigned int offset;
@REPLY
unsigned int tree_id;
unsigned int user_id;
unsigned int dialect;
unsigned int file_id;
unsigned int offset;
@END
#define SMBINFO_SET_OFFSET 0x01
/* Create a window */
@REQ(create_window)
user_handle_t parent; /* parent window */
......
......@@ -232,6 +232,8 @@ DECL_HANDLER(connect_named_pipe);
DECL_HANDLER(wait_named_pipe);
DECL_HANDLER(disconnect_named_pipe);
DECL_HANDLER(get_named_pipe_info);
DECL_HANDLER(create_smb);
DECL_HANDLER(get_smb_info);
DECL_HANDLER(create_window);
DECL_HANDLER(link_window);
DECL_HANDLER(destroy_window);
......@@ -388,6 +390,8 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
(req_handler)req_wait_named_pipe,
(req_handler)req_disconnect_named_pipe,
(req_handler)req_get_named_pipe_info,
(req_handler)req_create_smb,
(req_handler)req_get_smb_info,
(req_handler)req_create_window,
(req_handler)req_link_window,
(req_handler)req_destroy_window,
......
/*
* Server-side smb network file management
*
* Copyright (C) 1998 Alexandre Julliard
* Copyright (C) 2000, 2001, 2002 Mike McCormack
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* FIXME: if you can't find something to fix,
* you're not looking hard enough
*/
#include "config.h"
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#ifdef HAVE_SYS_ERRNO_H
#include <sys/errno.h>
#endif
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <utime.h>
#include <termios.h>
#include <sys/ioctl.h>
#include "winerror.h"
#include "winbase.h"
#include "handle.h"
#include "thread.h"
#include "request.h"
static void smb_dump( struct object *obj, int verbose );
static int smb_get_fd( struct object *obj );
static int smb_get_info( struct object *obj, struct get_file_info_reply *reply, int *flags );
static int smb_get_poll_events( struct object *obj );
static void destroy_smb(struct object *obj);
struct smb
{
struct object obj;
unsigned int tree_id;
unsigned int user_id;
unsigned int dialect;
unsigned int file_id;
unsigned int offset;
};
static const struct object_ops smb_ops =
{
sizeof(struct smb), /* size */
smb_dump, /* dump */
default_poll_add_queue, /* add_queue */
default_poll_remove_queue, /* remove_queue */
default_poll_signaled, /* signaled */
no_satisfied, /* satisfied */
smb_get_poll_events, /* get_poll_events */
default_poll_event, /* poll_event */
smb_get_fd, /* get_fd */
no_flush, /* flush */
smb_get_info, /* get_file_info */
NULL, /* queue_async */
destroy_smb /* destroy */
};
static void destroy_smb( struct object *obj)
{
/* struct smb *smb = (struct smb *)obj; */
assert( obj->ops == &smb_ops );
}
static void smb_dump( struct object *obj, int verbose )
{
struct smb *smb = (struct smb *)obj;
assert( obj->ops == &smb_ops );
fprintf( stderr, "smb file with socket fd=%d \n", smb->obj.fd );
}
struct smb *get_smb_obj( struct process *process, handle_t handle, unsigned int access )
{
return (struct smb *)get_handle_obj( process, handle, access, &smb_ops );
}
static int smb_get_poll_events( struct object *obj )
{
/* struct smb *smb = (struct smb *)obj; */
int events = 0;
assert( obj->ops == &smb_ops );
events |= POLLIN;
/* fprintf(stderr,"poll events are %04x\n",events); */
return events;
}
static int smb_get_fd( struct object *obj )
{
struct smb *smb = (struct smb *)obj;
assert( obj->ops == &smb_ops );
return smb->obj.fd;
}
static int smb_get_info( struct object *obj, struct get_file_info_reply *reply, int *flags )
{
/* struct smb *smb = (struct smb *) obj; */
assert( obj->ops == &smb_ops );
if (reply)
{
reply->type = FILE_TYPE_CHAR;
reply->attr = 0;
reply->access_time = 0;
reply->write_time = 0;
reply->size_high = 0;
reply->size_low = 0;
reply->links = 0;
reply->index_high = 0;
reply->index_low = 0;
reply->serial = 0;
}
*flags = 0;
return FD_TYPE_SMB;
}
/* create a smb */
DECL_HANDLER(create_smb)
{
struct smb *smb;
int fd;
reply->handle = 0;
fd = thread_get_inflight_fd( current, req->fd );
if (fd == -1)
{
set_error( STATUS_INVALID_HANDLE );
return;
}
smb = alloc_object( &smb_ops, fd );
if (smb)
{
smb->tree_id = req->tree_id;
smb->user_id = req->user_id;
smb->dialect = req->dialect;
smb->file_id = req->file_id;
smb->offset = 0;
reply->handle = alloc_handle( current->process, smb, GENERIC_READ, 0);
release_object( smb );
}
}
DECL_HANDLER(get_smb_info)
{
struct smb *smb;
if ((smb = get_smb_obj( current->process, req->handle, 0 )))
{
if(req->flags & SMBINFO_SET_OFFSET)
smb->offset = req->offset;
reply->tree_id = smb->tree_id;
reply->user_id = smb->user_id;
reply->dialect = smb->dialect;
reply->file_id = smb->file_id;
reply->offset = smb->offset;
release_object( smb );
}
}
......@@ -1843,6 +1843,36 @@ static void dump_get_named_pipe_info_reply( const struct get_named_pipe_info_rep
fprintf( stderr, " insize=%08x", req->insize );
}
static void dump_create_smb_request( const struct create_smb_request *req )
{
fprintf( stderr, " fd=%d,", req->fd );
fprintf( stderr, " tree_id=%08x,", req->tree_id );
fprintf( stderr, " user_id=%08x,", req->user_id );
fprintf( stderr, " file_id=%08x,", req->file_id );
fprintf( stderr, " dialect=%08x", req->dialect );
}
static void dump_create_smb_reply( const struct create_smb_reply *req )
{
fprintf( stderr, " handle=%d", req->handle );
}
static void dump_get_smb_info_request( const struct get_smb_info_request *req )
{
fprintf( stderr, " handle=%d,", req->handle );
fprintf( stderr, " flags=%08x,", req->flags );
fprintf( stderr, " offset=%08x", req->offset );
}
static void dump_get_smb_info_reply( const struct get_smb_info_reply *req )
{
fprintf( stderr, " tree_id=%08x,", req->tree_id );
fprintf( stderr, " user_id=%08x,", req->user_id );
fprintf( stderr, " dialect=%08x,", req->dialect );
fprintf( stderr, " file_id=%08x,", req->file_id );
fprintf( stderr, " offset=%08x", req->offset );
}
static void dump_create_window_request( const struct create_window_request *req )
{
fprintf( stderr, " parent=%08x,", req->parent );
......@@ -2193,6 +2223,8 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_wait_named_pipe_request,
(dump_func)dump_disconnect_named_pipe_request,
(dump_func)dump_get_named_pipe_info_request,
(dump_func)dump_create_smb_request,
(dump_func)dump_get_smb_info_request,
(dump_func)dump_create_window_request,
(dump_func)dump_link_window_request,
(dump_func)dump_destroy_window_request,
......@@ -2346,6 +2378,8 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
(dump_func)0,
(dump_func)0,
(dump_func)dump_get_named_pipe_info_reply,
(dump_func)dump_create_smb_reply,
(dump_func)dump_get_smb_info_reply,
(dump_func)dump_create_window_reply,
(dump_func)dump_link_window_reply,
(dump_func)0,
......@@ -2499,6 +2533,8 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
"wait_named_pipe",
"disconnect_named_pipe",
"get_named_pipe_info",
"create_smb",
"get_smb_info",
"create_window",
"link_window",
"destroy_window",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment