summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1997-09-26 19:26:56 +0000
committerJeremy Allison <jra@samba.org>1997-09-26 19:26:56 +0000
commitdff16872ca39c007d32d114af82d3ccd97f9d47a (patch)
tree503e542b459992e3c61945e9f8e5defe273a86f6 /source3/smbd
parentd939350de407db97422cb22ef885afed3fdf7cea (diff)
downloadsamba-dff16872ca39c007d32d114af82d3ccd97f9d47a.tar.gz
samba-dff16872ca39c007d32d114af82d3ccd97f9d47a.tar.bz2
samba-dff16872ca39c007d32d114af82d3ccd97f9d47a.zip
Syncing up current oplock work in progress. #ifdef'ed out
so should have no effect on other work. Jeremy (jallison@whistle.com) (This used to be commit 7e3d4c8b21f63a06d32605d230129e36883ad08c)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/pipes.c2
-rw-r--r--source3/smbd/reply.c79
-rw-r--r--source3/smbd/server.c227
-rw-r--r--source3/smbd/trans2.c6
4 files changed, 195 insertions, 119 deletions
diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c
index feb8d91a5b..a465e91145 100644
--- a/source3/smbd/pipes.c
+++ b/source3/smbd/pipes.c
@@ -127,7 +127,7 @@ int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize)
unixmode = unix_mode(cnum,smb_attr);
open_file_shared(fnum,cnum,fname,smb_mode,smb_ofun,unixmode,
- &rmode,&smb_action);
+ 0, &rmode,&smb_action);
if (!Files[fnum].open)
{
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index c1422bbcf6..94839c227a 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1099,6 +1099,8 @@ int reply_open(char *inbuf,char *outbuf)
int rmode=0;
struct stat sbuf;
BOOL bad_path = False;
+ files_struct *fsp;
+ int oplock_request = CORE_OPLOCK_REQUEST(inbuf);
cnum = SVAL(inbuf,smb_tid);
@@ -1123,9 +1125,12 @@ int reply_open(char *inbuf,char *outbuf)
unixmode = unix_mode(cnum,aARCH);
- open_file_shared(fnum,cnum,fname,share_mode,3,unixmode,&rmode,NULL);
+ open_file_shared(fnum,cnum,fname,share_mode,3,unixmode,
+ oplock_request,&rmode,NULL);
- if (!Files[fnum].open)
+ fsp = &Files[fnum];
+
+ if (!fsp->open)
{
if((errno == ENOENT) && bad_path)
{
@@ -1135,7 +1140,7 @@ int reply_open(char *inbuf,char *outbuf)
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- if (fstat(Files[fnum].fd_ptr->fd,&sbuf) != 0) {
+ if (fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
close_file(fnum);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -1157,10 +1162,12 @@ int reply_open(char *inbuf,char *outbuf)
SIVAL(outbuf,smb_vwv4,size);
SSVAL(outbuf,smb_vwv6,rmode);
- if (lp_fake_oplocks(SNUM(cnum))) {
- CVAL(outbuf,smb_flg) |= (CVAL(inbuf,smb_flg) & (1<<5));
+ if (oplock_request && lp_fake_oplocks(SNUM(cnum))) {
+ fsp->granted_oplock = True;
}
+ if(fsp->granted_oplock)
+ CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
return(outsize);
}
@@ -1175,7 +1182,7 @@ int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize)
int fnum = -1;
int smb_mode = SVAL(inbuf,smb_vwv3);
int smb_attr = SVAL(inbuf,smb_vwv5);
- BOOL oplock_request = BITSETW(inbuf+smb_vwv2,1);
+ BOOL oplock_request = EXTENDED_OPLOCK_REQUEST(inbuf);
#if 0
int open_flags = SVAL(inbuf,smb_vwv2);
int smb_sattr = SVAL(inbuf,smb_vwv4);
@@ -1187,6 +1194,7 @@ int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize)
struct stat sbuf;
int smb_action = 0;
BOOL bad_path = False;
+ files_struct *fsp;
/* If it's an IPC, pass off the pipe handler. */
if (IS_IPC(cnum))
@@ -1214,9 +1222,11 @@ int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize)
unixmode = unix_mode(cnum,smb_attr | aARCH);
open_file_shared(fnum,cnum,fname,smb_mode,smb_ofun,unixmode,
- &rmode,&smb_action);
+ oplock_request, &rmode,&smb_action);
- if (!Files[fnum].open)
+ fsp = &Files[fnum];
+
+ if (!fsp->open)
{
if((errno == ENOENT) && bad_path)
{
@@ -1226,7 +1236,7 @@ int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize)
return(UNIXERROR(ERRDOS,ERRnoaccess));
}
- if (fstat(Files[fnum].fd_ptr->fd,&sbuf) != 0) {
+ if (fstat(fsp->fd_ptr->fd,&sbuf) != 0) {
close_file(fnum);
return(ERROR(ERRDOS,ERRnoaccess));
}
@@ -1240,9 +1250,12 @@ int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize)
}
if (oplock_request && lp_fake_oplocks(SNUM(cnum))) {
- smb_action |= (1<<15);
+ fsp->granted_oplock = True;
}
+ if(fsp->granted_oplock)
+ smb_action |= EXTENDED_OPLOCK_GRANTED;
+
set_message(outbuf,15,0,True);
SSVAL(outbuf,smb_vwv2,fnum);
SSVAL(outbuf,smb_vwv3,fmode);
@@ -1302,6 +1315,8 @@ int reply_mknew(char *inbuf,char *outbuf)
mode_t unixmode;
int ofun = 0;
BOOL bad_path = False;
+ files_struct *fsp;
+ int oplock_request = CORE_OPLOCK_REQUEST(inbuf);
com = SVAL(inbuf,smb_com);
cnum = SVAL(inbuf,smb_tid);
@@ -1343,9 +1358,12 @@ int reply_mknew(char *inbuf,char *outbuf)
}
/* Open file in dos compatibility share mode. */
- open_file_shared(fnum,cnum,fname,(DENY_FCB<<4)|0xF, ofun, unixmode, NULL, NULL);
+ open_file_shared(fnum,cnum,fname,(DENY_FCB<<4)|0xF, ofun, unixmode,
+ oplock_request, NULL, NULL);
- if (!Files[fnum].open)
+ fsp = &Files[fnum];
+
+ if (!fsp->open)
{
if((errno == ENOENT) && bad_path)
{
@@ -1358,10 +1376,13 @@ int reply_mknew(char *inbuf,char *outbuf)
outsize = set_message(outbuf,1,0,True);
SSVAL(outbuf,smb_vwv0,fnum);
- if (lp_fake_oplocks(SNUM(cnum))) {
- CVAL(outbuf,smb_flg) |= (CVAL(inbuf,smb_flg) & (1<<5));
+ if (oplock_request && lp_fake_oplocks(SNUM(cnum))) {
+ fsp->granted_oplock = True;
}
-
+
+ if(fsp->granted_oplock)
+ CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
+
DEBUG(2,("new file %s\n",fname));
DEBUG(3,("%s mknew %s fd=%d fnum=%d cnum=%d dmode=%d umode=%o\n",timestring(),fname,Files[fnum].fd_ptr->fd,fnum,cnum,createmode,unixmode));
@@ -1382,6 +1403,8 @@ int reply_ctemp(char *inbuf,char *outbuf)
int createmode;
mode_t unixmode;
BOOL bad_path = False;
+ files_struct *fsp;
+ int oplock_request = CORE_OPLOCK_REQUEST(inbuf);
cnum = SVAL(inbuf,smb_tid);
createmode = SVAL(inbuf,smb_vwv0);
@@ -1409,9 +1432,12 @@ int reply_ctemp(char *inbuf,char *outbuf)
/* Open file in dos compatibility share mode. */
/* We should fail if file exists. */
- open_file_shared(fnum,cnum,fname2,(DENY_FCB<<4)|0xF, 0x10, unixmode, NULL, NULL);
+ open_file_shared(fnum,cnum,fname2,(DENY_FCB<<4)|0xF, 0x10, unixmode,
+ oplock_request, NULL, NULL);
- if (!Files[fnum].open)
+ fsp = &Files[fnum];
+
+ if (!fsp->open)
{
if((errno == ENOENT) && bad_path)
{
@@ -1426,10 +1452,13 @@ int reply_ctemp(char *inbuf,char *outbuf)
CVAL(smb_buf(outbuf),0) = 4;
strcpy(smb_buf(outbuf) + 1,fname2);
- if (lp_fake_oplocks(SNUM(cnum))) {
- CVAL(outbuf,smb_flg) |= (CVAL(inbuf,smb_flg) & (1<<5));
+ if (oplock_request && lp_fake_oplocks(SNUM(cnum))) {
+ fsp->granted_oplock = True;
}
+ if(fsp->granted_oplock)
+ CVAL(outbuf,smb_flg) |= CORE_OPLOCK_GRANTED;
+
DEBUG(2,("created temp file %s\n",fname2));
DEBUG(3,("%s ctemp %s fd=%d fnum=%d cnum=%d dmode=%d umode=%o\n",timestring(),fname2,Files[fnum].fd_ptr->fd,fnum,cnum,createmode,unixmode));
@@ -2432,7 +2461,8 @@ int reply_printopen(char *inbuf,char *outbuf)
return(ERROR(ERRDOS,ERRnoaccess));
/* Open for exclusive use, write only. */
- open_file_shared(fnum,cnum,fname2,(DENY_ALL<<4)|1, 0x12, unix_mode(cnum,0), NULL, NULL);
+ open_file_shared(fnum,cnum,fname2,(DENY_ALL<<4)|1, 0x12, unix_mode(cnum,0),
+ 0, NULL, NULL);
if (!Files[fnum].open)
return(UNIXERROR(ERRDOS,ERRnoaccess));
@@ -3094,7 +3124,7 @@ static BOOL copy_file(char *src,char *dest1,int cnum,int ofun,
fnum1 = find_free_file();
if (fnum1<0) return(False);
open_file_shared(fnum1,cnum,src,(DENY_NONE<<4),
- 1,0,&Access,&action);
+ 1,0,0,&Access,&action);
if (!Files[fnum1].open) return(False);
@@ -3107,7 +3137,7 @@ static BOOL copy_file(char *src,char *dest1,int cnum,int ofun,
return(False);
}
open_file_shared(fnum2,cnum,dest,(DENY_NONE<<4)|1,
- ofun,st.st_mode,&Access,&action);
+ ofun,st.st_mode,0,&Access,&action);
if (!Files[fnum2].open) {
close_file(fnum1);
@@ -3713,8 +3743,3 @@ int reply_getattrE(char *inbuf,char *outbuf)
return(outsize);
}
-
-
-
-
-
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 22c8448dde..d2ad803c9c 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -88,6 +88,8 @@ static int num_connections_open = 0;
/* Oplock ipc UDP socket. */
int oplock_sock = -1;
uint16 oplock_port = 0;
+/* Current number of oplocks we have outstanding. */
+uint32 oplocks_open = 0;
#endif /* USE_OPLOCKS */
extern fstring remote_machine;
@@ -1052,9 +1054,10 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
pstring fname;
struct stat statbuf;
file_fd_struct *fd_ptr;
+ files_struct *fsp = &Files[fnum];
- Files[fnum].open = False;
- Files[fnum].fd_ptr = 0;
+ fsp->open = False;
+ fsp->fd_ptr = 0;
errno = EPERM;
pstrcpy(fname,fname1);
@@ -1192,7 +1195,7 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
if (sys_disk_free(dname,&dum1,&dum2,&dum3) <
lp_minprintspace(SNUM(cnum))) {
fd_attempt_close(fd_ptr);
- Files[fnum].fd_ptr = 0;
+ fsp->fd_ptr = 0;
if(fd_ptr->ref_count == 0)
sys_unlink(fname);
errno = ENOSPC;
@@ -1228,25 +1231,26 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
fd_ptr->dev = (uint32)sbuf->st_dev;
fd_ptr->inode = (uint32)sbuf->st_ino;
- Files[fnum].fd_ptr = fd_ptr;
+ fsp->fd_ptr = fd_ptr;
Connections[cnum].num_files_open++;
- Files[fnum].mode = sbuf->st_mode;
- GetTimeOfDay(&Files[fnum].open_time);
- Files[fnum].uid = current_user.id;
- Files[fnum].size = 0;
- Files[fnum].pos = -1;
- Files[fnum].open = True;
- Files[fnum].mmap_ptr = NULL;
- Files[fnum].mmap_size = 0;
- Files[fnum].can_lock = True;
- Files[fnum].can_read = ((flags & O_WRONLY)==0);
- Files[fnum].can_write = ((flags & (O_WRONLY|O_RDWR))!=0);
- Files[fnum].share_mode = 0;
- Files[fnum].print_file = Connections[cnum].printer;
- Files[fnum].modified = False;
- Files[fnum].cnum = cnum;
- string_set(&Files[fnum].name,dos_to_unix(fname,False));
- Files[fnum].wbmpx_ptr = NULL;
+ fsp->mode = sbuf->st_mode;
+ GetTimeOfDay(&fsp->open_time);
+ fsp->uid = current_user.id;
+ fsp->size = 0;
+ fsp->pos = -1;
+ fsp->open = True;
+ fsp->mmap_ptr = NULL;
+ fsp->mmap_size = 0;
+ fsp->can_lock = True;
+ fsp->can_read = ((flags & O_WRONLY)==0);
+ fsp->can_write = ((flags & (O_WRONLY|O_RDWR))!=0);
+ fsp->share_mode = 0;
+ fsp->print_file = Connections[cnum].printer;
+ fsp->modified = False;
+ fsp->granted_oplock = False;
+ fsp->cnum = cnum;
+ string_set(&fsp->name,dos_to_unix(fname,False));
+ fsp->wbmpx_ptr = NULL;
/*
* If the printer is marked as postscript output a leading
@@ -1255,8 +1259,8 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
* This has a similar effect as CtrlD=0 in WIN.INI file.
* tim@fsg.com 09/06/94
*/
- if (Files[fnum].print_file && POSTSCRIPT(cnum) &&
- Files[fnum].can_write)
+ if (fsp->print_file && POSTSCRIPT(cnum) &&
+ fsp->can_write)
{
DEBUG(3,("Writing postscript line\n"));
write_file(fnum,"%!\n",3);
@@ -1264,23 +1268,23 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
DEBUG(2,("%s %s opened file %s read=%s write=%s (numopen=%d fnum=%d)\n",
timestring(),Connections[cnum].user,fname,
- BOOLSTR(Files[fnum].can_read),BOOLSTR(Files[fnum].can_write),
+ BOOLSTR(fsp->can_read),BOOLSTR(fsp->can_write),
Connections[cnum].num_files_open,fnum));
}
#if USE_MMAP
/* mmap it if read-only */
- if (!Files[fnum].can_write)
+ if (!fsp->can_write)
{
- Files[fnum].mmap_size = file_size(fname);
- Files[fnum].mmap_ptr = (char *)mmap(NULL,Files[fnum].mmap_size,
- PROT_READ,MAP_SHARED,Files[fnum].fd_ptr->fd,0);
+ fsp->mmap_size = file_size(fname);
+ fsp->mmap_ptr = (char *)mmap(NULL,fsp->mmap_size,
+ PROT_READ,MAP_SHARED,fsp->fd_ptr->fd,0);
- if (Files[fnum].mmap_ptr == (char *)-1 || !Files[fnum].mmap_ptr)
+ if (fsp->mmap_ptr == (char *)-1 || !fsp->mmap_ptr)
{
DEBUG(3,("Failed to mmap() %s - %s\n",fname,strerror(errno)));
- Files[fnum].mmap_ptr = NULL;
+ fsp->mmap_ptr = NULL;
}
}
#endif
@@ -1512,12 +1516,52 @@ static void truncate_unless_locked(int fnum, int cnum, share_lock_token token,
}
}
+/****************************************************************************
+check if we can open a file with a share mode
+****************************************************************************/
+int check_share_mode( min_share_mode_entry *share, int deny_mode, char *fname,
+ BOOL fcbopen, int *flags)
+{
+ int old_open_mode = share->share_mode &0xF;
+ int old_deny_mode = (share->share_mode >>4)&7;
+
+ if (old_deny_mode > 4 || old_open_mode > 2)
+ {
+ DEBUG(0,("Invalid share mode found (%d,%d,%d) on file %s\n",
+ deny_mode,old_deny_mode,old_open_mode,fname));
+ return False;
+ }
+
+ {
+ int access_allowed = access_table(deny_mode,old_deny_mode,old_open_mode,
+ share->pid,fname);
+
+ if ((access_allowed == AFAIL) ||
+ (!fcbopen && (access_allowed == AREAD && *flags == O_RDWR)) ||
+ (access_allowed == AREAD && *flags == O_WRONLY) ||
+ (access_allowed == AWRITE && *flags == O_RDONLY))
+ {
+ DEBUG(2,("Share violation on file (%d,%d,%d,%d,%s) = %d\n",
+ deny_mode,old_deny_mode,old_open_mode,
+ share->pid,fname, access_allowed));
+ return False;
+ }
+
+ if (access_allowed == AREAD)
+ *flags = O_RDONLY;
+
+ if (access_allowed == AWRITE)
+ *flags = O_WRONLY;
+
+ }
+ return True;
+}
/****************************************************************************
open a file with a share mode
****************************************************************************/
void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
- int mode,int *Access,int *action)
+ int mode,int oplock_request, int *Access,int *action)
{
files_struct *fs_p = &Files[fnum];
int flags=0;
@@ -1605,7 +1649,6 @@ void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
int i;
min_share_mode_entry *old_shares = 0;
-
if (file_existed)
{
dev = (uint32)sbuf.st_dev;
@@ -1615,55 +1658,61 @@ void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
num_shares = get_share_modes(cnum, token, dev, inode, &old_shares);
}
- for(i = 0; i < num_shares; i++)
- {
- /* someone else has a share lock on it, check to see
- if we can too */
- int old_open_mode = old_shares[i].share_mode &0xF;
- int old_deny_mode = (old_shares[i].share_mode >>4)&7;
+ /*
+ * Check if the share modes will give us access.
+ */
- if (old_deny_mode > 4 || old_open_mode > 2)
- {
- DEBUG(0,("Invalid share mode found (%d,%d,%d) on file %s\n",
- deny_mode,old_deny_mode,old_open_mode,fname));
- free((char *)old_shares);
- if(share_locked)
- unlock_share_entry(cnum, dev, inode, token);
- errno = EACCES;
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRbadshare;
- return;
- }
+ if(share_locked && (num_shares != 0))
+ {
+ BOOL broke_oplock;
+ do
{
- int access_allowed = access_table(deny_mode,old_deny_mode,old_open_mode,
- old_shares[i].pid,fname);
-
- if ((access_allowed == AFAIL) ||
- (!fcbopen && (access_allowed == AREAD && flags == O_RDWR)) ||
- (access_allowed == AREAD && flags == O_WRONLY) ||
- (access_allowed == AWRITE && flags == O_RDONLY))
+ broke_oplock = False;
+ for(i = 0; i < num_shares; i++)
{
- DEBUG(2,("Share violation on file (%d,%d,%d,%d,%s) = %d\n",
- deny_mode,old_deny_mode,old_open_mode,
- old_shares[i].pid,fname,
- access_allowed));
- free((char *)old_shares);
- if(share_locked)
+ /* someone else has a share lock on it, check to see
+ if we can too */
+ if(check_share_mode(&old_shares[i], deny_mode, fname, fcbopen, &flags) == False)
+ {
+ free((char *)old_shares);
unlock_share_entry(cnum, dev, inode, token);
- errno = EACCES;
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRbadshare;
- return;
+ errno = EACCES;
+ unix_ERR_class = ERRDOS;
+ unix_ERR_code = ERRbadshare;
+ return;
+ }
+#ifdef USE_OPLOCKS
+ /*
+ * The share modes would give us access. Check if someone
+ * has an oplock on this file. If so we must break it before
+ * continuing.
+ */
+ if(old_shares[i].op_type != 0)
+ {
+ /* Oplock break.... */
+ unlock_share_entry(cnum, dev, inode, token);
+#if 0 /* Work in progress..... */
+ if(break_oplock())
+ {
+ free((char *)old_shares);
+ /* Error condition here... */
+ }
+ lock_share_entry(cnum, dev, inode, &token);
+ broke_oplock = True;
+ break;
+#endif
+ }
+#endif /* USE_OPLOCKS */
}
-
- if (access_allowed == AREAD)
- flags = O_RDONLY;
-
- if (access_allowed == AWRITE)
- flags = O_WRONLY;
- }
+ if(broke_oplock)
+ {
+ free((char *)old_shares);
+ num_shares = get_share_modes(cnum, token, dev, inode, &old_shares);
+ }
+ } while(broke_oplock);
}
+
if(old_shares != 0)
free((char *)old_shares);
}
@@ -1720,7 +1769,7 @@ void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
file (which expects the share_mode_entry to be there).
*/
if (lp_share_modes(SNUM(cnum)))
- set_share_mode(token, fnum, 0);
+ set_share_mode(token, fnum, 0, 0);
if ((flags2&O_TRUNC) && file_existed)
truncate_unless_locked(fnum,cnum,token,&share_locked);
@@ -2279,7 +2328,8 @@ static BOOL open_oplock_ipc()
if (oplock_sock == -1)
{
DEBUG(0,("open_oplock_ipc: Failed to get local UDP socket for \
-address %x. Error was %s\n", INADDR_LOOPBACK, strerror(errno)));
+address %x. Error was %s\n", htonl(INADDR_LOOPBACK), strerror(errno)));
+ oplock_port = 0;
return(False);
}
@@ -2290,6 +2340,7 @@ address %x. Error was %s\n", INADDR_LOOPBACK, strerror(errno)));
strerror(errno)));
close(oplock_sock);
oplock_sock = -1;
+ oplock_port = 0;
return False;
}
oplock_port = ntohs(sock_name.sin_port);
@@ -2324,7 +2375,7 @@ static BOOL process_local_message(int oplock_sock, char *buffer, int buf_size)
/* Validate message from address (must be localhost). */
if(from_addr.s_addr != htonl(INADDR_LOOPBACK))
{
- DEBUG(0,("process_local_message: invalid from address \
+ DEBUG(0,("process_local_message: invalid 'from' address \
(was %x should be 127.0.0.1\n", from_addr.s_addr));
return False;
}
@@ -4010,20 +4061,20 @@ int construct_reply(char *inbuf,char *outbuf,int size,int bufsize)
it can be used by the oplock break code.
****************************************************************************/
-static void process_smb(char *InBuffer, char *OutBuffer)
+static void process_smb(char *inbuf, char *outbuf)
{
extern int Client;
static int trans_num = 0;
- int msg_type = CVAL(InBuffer,0);
- int32 len = smb_len(InBuffer);
+ int msg_type = CVAL(inbuf,0);
+ int32 len = smb_len(outbuf);
int nread = len + 4;
DEBUG(6,("got message type 0x%x of len 0x%x\n",msg_type,len));
DEBUG(3,("%s Transaction %d of length %d\n",timestring(),trans_num,nread));
#ifdef WITH_VTP
- if(trans_num == 1 && VT_Check(InBuffer))
+ if(trans_num == 1 && VT_Check(inbuf))
{
VT_Process();
return;
@@ -4031,22 +4082,22 @@ static void process_smb(char *InBuffer, char *OutBuffer)
#endif
if (msg_type == 0)
- show_msg(InBuffer);
+ show_msg(inbuf);
- nread = construct_reply(InBuffer,OutBuffer,nread,max_send);
+ nread = construct_reply(inbuf,outbuf,nread,max_send);
if(nread > 0)
{
- if (CVAL(OutBuffer,0) == 0)
- show_msg(OutBuffer);
+ if (CVAL(outbuf,0) == 0)
+ show_msg(outbuf);
- if (nread != smb_len(OutBuffer) + 4)
+ if (nread != smb_len(outbuf) + 4)
{
DEBUG(0,("ERROR: Invalid message response size! %d %d\n",
- nread, smb_len(OutBuffer)));
+ nread, smb_len(outbuf)));
}
else
- send_smb(Client,OutBuffer);
+ send_smb(Client,outbuf);
}
trans_num++;
}
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 59e9ef21b0..8ab024ded2 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -166,7 +166,7 @@ static int call_trans2open(char *inbuf, char *outbuf, int bufsize, int cnum,
char *params = *pparams;
int16 open_mode = SVAL(params, 2);
int16 open_attr = SVAL(params,6);
- BOOL oplock_request = BITSETW(params,1);
+ BOOL oplock_request = (((SVAL(params,0)|(1<<1))>>1) | ((SVAL(params,0)|(1<<2))>>1));
#if 0
BOOL return_additional_info = BITSETW(params,0);
int16 open_sattr = SVAL(params, 4);
@@ -213,7 +213,7 @@ static int call_trans2open(char *inbuf, char *outbuf, int bufsize, int cnum,
open_file_shared(fnum,cnum,fname,open_mode,open_ofun,unixmode,
- &rmode,&smb_action);
+ oplock_request, &rmode,&smb_action);
if (!Files[fnum].open)
{
@@ -252,7 +252,7 @@ static int call_trans2open(char *inbuf, char *outbuf, int bufsize, int cnum,
SSVAL(params,12,rmode);
if (oplock_request && lp_fake_oplocks(SNUM(cnum))) {
- smb_action |= (1<<15);
+ smb_action |= EXTENDED_OPLOCK_GRANTED;
}
SSVAL(params,18,smb_action);