1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

Added ssize_t to configure code.

Got 'religion' about using size_t and ssize_t for read/write stuff
as part of the code to expose 64 bits to the client.

This checkin does all the 'easy' stuff - such as all the read/write/lock
calls - but now comes the harder parts (open & friends) and all the
file enquiry functions.....

Jeremy.
This commit is contained in:
Jeremy Allison 0001-01-01 00:00:00 +00:00
parent 069efc0454
commit 36544fe547
15 changed files with 609 additions and 635 deletions

337
source/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -55,6 +55,7 @@ AC_TYPE_SIZE_T
AC_TYPE_PID_T
AC_STRUCT_ST_RDEV
AC_CHECK_TYPE(ino_t,unsigned)
AC_CHECK_TYPE(ssize_t, int)
echo $ac_n "checking for errno in errno.h... $ac_c"
AC_TRY_COMPILE([#include <errno.h>],[int i = errno],

View File

@ -63,6 +63,7 @@
#undef HAVE_UNSIGNED_CHAR
#undef HAVE_UTIMBUF
#undef ino_t
#undef ssize_t
#undef HAVE_CONNECT
#undef HAVE_SHORT_INO_T
#undef WITH_AFS

View File

@ -258,18 +258,18 @@ BOOL strhaslower(char *s);
int count_chars(char *s,char c);
void make_dir_struct(char *buf,char *mask,char *fname,SMB_OFF_T size,int mode,time_t date);
void close_low_fds(void);
int write_socket(int fd,char *buf,int len);
int read_udp_socket(int fd,char *buf,int len);
int read_with_timeout(int fd,char *buf,int mincnt,int maxcnt,long time_out);
ssize_t write_socket(int fd,char *buf,size_t len);
ssize_t read_udp_socket(int fd,char *buf,size_t len);
ssize_t read_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,unsigned int time_out);
int TvalDiff(struct timeval *tvalold,struct timeval *tvalnew);
BOOL send_keepalive(int client);
int read_data(int fd,char *buffer,int N);
int write_data(int fd,char *buffer,int N);
ssize_t read_data(int fd,char *buffer,size_t N);
ssize_t write_data(int fd,char *buffer,size_t N);
SMB_OFF_T transfer_file(int infd,int outfd,SMB_OFF_T n,char *header,int headlen,int align);
int read_smb_length(int fd,char *inbuf,int timeout);
BOOL receive_smb(int fd,char *buffer, int timeout);
BOOL client_receive_smb(int fd,char *buffer, int timeout);
BOOL receive_local_message(int fd, char *buffer, int buffer_len, int timeout);
ssize_t read_smb_length(int fd,char *inbuf,unsigned int timeout);
BOOL receive_smb(int fd,char *buffer, unsigned int timeout);
BOOL client_receive_smb(int fd,char *buffer, unsigned int timeout);
BOOL receive_local_message(int fd, char *buffer, int buffer_len, unsigned int timeout);
BOOL push_oplock_pending_smb_message(char *buf, int msg_len);
BOOL receive_message_or_smb(int smbfd, int oplock_fd,
char *buffer, int buffer_len,
@ -289,7 +289,7 @@ void become_daemon(void);
BOOL yesno(char *p);
char *fgets_slash(char *s2,int maxlen,FILE *f);
int set_filelen(int fd, SMB_OFF_T len);
void *Realloc(void *p,int size);
void *Realloc(void *p,size_t size);
BOOL get_myname(char *my_name,struct in_addr *ip);
BOOL ip_equal(struct in_addr ip1,struct in_addr ip2);
int open_socket_in(int type, int port, int dlevel,uint32 socket_addr);
@ -333,7 +333,7 @@ char *tab_depth(int depth);
char *sid_to_string(pstring sidstr_out, DOM_SID *sid);
BOOL string_to_sid(DOM_SID *sidout, char *sidstr);
int str_checksum(char *s);
void zero_free(void *p, int size);
void zero_free(void *p, size_t size);
/*The following definitions come from libsmb/clientgen.c */
@ -1715,8 +1715,8 @@ int error_packet(char *inbuf,char *outbuf,int error_class,uint32 error_code,int
/*The following definitions come from smbd/fileio.c */
SMB_OFF_T seek_file(files_struct *fsp,SMB_OFF_T pos);
int read_file(files_struct *fsp,char *data,uint32 pos,int n);
int write_file(files_struct *fsp,char *data,int n);
ssize_t read_file(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n);
ssize_t write_file(files_struct *fsp,char *data,size_t n);
void sync_file(connection_struct *conn, files_struct *fsp);
/*The following definitions come from smbd/filename.c */
@ -1846,7 +1846,7 @@ int reply_pipe_close(connection_struct *conn, char *inbuf,char *outbuf);
/*The following definitions come from smbd/predict.c */
int read_predict(int fd,SMB_OFF_T offset,char *buf,char **ptr,int num);
ssize_t read_predict(int fd,SMB_OFF_T offset,char *buf,char **ptr,size_t num);
void do_read_prediction(void);
void invalidate_read_prediction(int fd);

View File

@ -458,7 +458,7 @@ typedef struct
/* Structure used when SMBwritebmpx is active */
typedef struct
{
int wr_total_written; /* So we know when to discard this */
size_t wr_total_written; /* So we know when to discard this */
int32 wr_timeout;
int32 wr_errclass;
int32 wr_error; /* Cached errors */
@ -1413,6 +1413,10 @@ enum ssl_version_enum {SMB_SSL_V2,SMB_SSL_V3,SMB_SSL_V23,SMB_SSL_TLS1};
#define SMB_LPID_OFFSET(indx) (10 * (indx))
#define SMB_LKOFF_OFFSET(indx) ( 2 + (10 * (indx)))
#define SMB_LKLEN_OFFSET(indx) ( 6 + (10 * (indx)))
#define SMB_LARGE_LKOFF_OFFSET_HIGH(indx) (4 + (20 * (indx)))
#define SMB_LARGE_LKOFF_OFFSET_LOW(indx) (8 + (20 * (indx)))
#define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx)))
#define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx)))
/* Macro to cache an error in a write_bmpx_struct */
#define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \

View File

@ -1787,9 +1787,9 @@ static int set_blocking(int fd, BOOL set)
/****************************************************************************
write to a socket
****************************************************************************/
int write_socket(int fd,char *buf,int len)
ssize_t write_socket(int fd,char *buf,size_t len)
{
int ret=0;
ssize_t ret=0;
if (passive)
return(len);
@ -1807,16 +1807,16 @@ int write_socket(int fd,char *buf,int len)
/****************************************************************************
read from a socket
****************************************************************************/
int read_udp_socket(int fd,char *buf,int len)
ssize_t read_udp_socket(int fd,char *buf,size_t len)
{
int ret;
ssize_t ret;
struct sockaddr_in sock;
int socklen;
socklen = sizeof(sock);
bzero((char *)&sock,socklen);
bzero((char *)&lastip,sizeof(lastip));
ret = recvfrom(fd,buf,len,0,(struct sockaddr *)&sock,&socklen);
ret = (ssize_t)recvfrom(fd,buf,len,0,(struct sockaddr *)&sock,&socklen);
if (ret <= 0) {
DEBUG(2,("read socket failed. ERRNO=%s\n",strerror(errno)));
return(0);
@ -1835,13 +1835,15 @@ int read_udp_socket(int fd,char *buf,int len)
read data from a device with a timout in msec.
mincount = if timeout, minimum to read before returning
maxcount = number to be read.
time_out = timeout in milliseconds
****************************************************************************/
int read_with_timeout(int fd,char *buf,int mincnt,int maxcnt,long time_out)
ssize_t read_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,unsigned int time_out)
{
fd_set fds;
int selrtn;
int readret;
int nread = 0;
ssize_t readret;
size_t nread = 0;
struct timeval timeout;
/* just checking .... */
@ -1865,48 +1867,48 @@ int read_with_timeout(int fd,char *buf,int mincnt,int maxcnt,long time_out)
#endif /* WITH_SSL */
if (readret == 0) {
smb_read_error = READ_EOF;
return -1;
smb_read_error = READ_EOF;
return -1;
}
if (readret == -1) {
smb_read_error = READ_ERROR;
return -1;
smb_read_error = READ_ERROR;
return -1;
}
nread += readret;
}
return(nread);
return((ssize_t)nread);
}
/* Most difficult - timeout read */
/* If this is ever called on a disk file and
mincnt is greater then the filesize then
system performance will suffer severely as
select always return true on disk files */
mincnt is greater then the filesize then
system performance will suffer severely as
select always returns true on disk files */
/* Set initial timeout */
timeout.tv_sec = time_out / 1000;
timeout.tv_usec = 1000 * (time_out % 1000);
for (nread=0; nread<mincnt; )
{
FD_ZERO(&fds);
FD_SET(fd,&fds);
for (nread=0; nread < mincnt; )
{
FD_ZERO(&fds);
FD_SET(fd,&fds);
selrtn = sys_select(fd+1,&fds,&timeout);
selrtn = sys_select(fd+1,&fds,&timeout);
/* Check if error */
if(selrtn == -1) {
/* something is wrong. Maybe the socket is dead? */
smb_read_error = READ_ERROR;
return -1;
}
/* Check if error */
if(selrtn == -1) {
/* something is wrong. Maybe the socket is dead? */
smb_read_error = READ_ERROR;
return -1;
}
/* Did we timeout ? */
if (selrtn == 0) {
smb_read_error = READ_TIMEOUT;
return -1;
}
/* Did we timeout ? */
if (selrtn == 0) {
smb_read_error = READ_TIMEOUT;
return -1;
}
#ifdef WITH_SSL
if(fd == sslFd){
@ -1918,23 +1920,23 @@ int read_with_timeout(int fd,char *buf,int mincnt,int maxcnt,long time_out)
readret = read(fd, buf+nread, maxcnt-nread);
#endif /* WITH_SSL */
if (readret == 0) {
/* we got EOF on the file descriptor */
smb_read_error = READ_EOF;
return -1;
}
if (readret == -1) {
/* the descriptor is probably dead */
smb_read_error = READ_ERROR;
return -1;
}
nread += readret;
if (readret == 0) {
/* we got EOF on the file descriptor */
smb_read_error = READ_EOF;
return -1;
}
if (readret == -1) {
/* the descriptor is probably dead */
smb_read_error = READ_ERROR;
return -1;
}
nread += readret;
}
/* Return the number we got */
return(nread);
return((ssize_t)nread);
}
/*******************************************************************
@ -1965,10 +1967,10 @@ BOOL send_keepalive(int client)
/****************************************************************************
read data from the client, reading exactly N bytes.
****************************************************************************/
int read_data(int fd,char *buffer,int N)
ssize_t read_data(int fd,char *buffer,size_t N)
{
int ret;
int total=0;
ssize_t ret;
size_t total=0;
smb_read_error = 0;
@ -1996,17 +1998,17 @@ int read_data(int fd,char *buffer,int N)
}
total += ret;
}
return total;
return (ssize_t)total;
}
/****************************************************************************
write data to a fd
****************************************************************************/
int write_data(int fd,char *buffer,int N)
ssize_t write_data(int fd,char *buffer,size_t N)
{
int total=0;
int ret;
size_t total=0;
ssize_t ret;
while (total < N)
{
@ -2025,7 +2027,7 @@ int write_data(int fd,char *buffer,int N)
total += ret;
}
return total;
return (ssize_t)total;
}
@ -2111,28 +2113,30 @@ read 4 bytes of a smb packet and return the smb length of the packet
store the result in the buffer
This version of the function will return a length of zero on receiving
a keepalive packet.
timeout is in milliseconds.
****************************************************************************/
static int read_smb_length_return_keepalive(int fd,char *inbuf,int timeout)
static ssize_t read_smb_length_return_keepalive(int fd,char *inbuf,unsigned int timeout)
{
int len=0, msg_type;
BOOL ok=False;
ssize_t len=0;
int msg_type;
BOOL ok = False;
while (!ok)
{
if (timeout > 0)
ok = (read_with_timeout(fd,inbuf,4,4,timeout) == 4);
else
ok = (read_data(fd,inbuf,4) == 4);
{
if (timeout > 0)
ok = (read_with_timeout(fd,inbuf,4,4,timeout) == 4);
else
ok = (read_data(fd,inbuf,4) == 4);
if (!ok)
return(-1);
if (!ok)
return(-1);
len = smb_len(inbuf);
msg_type = CVAL(inbuf,0);
len = smb_len(inbuf);
msg_type = CVAL(inbuf,0);
if (msg_type == 0x85)
DEBUG(5,("Got keepalive packet\n"));
}
if (msg_type == 0x85)
DEBUG(5,("Got keepalive packet\n"));
}
DEBUG(10,("got smb length of %d\n",len));
@ -2143,10 +2147,11 @@ static int read_smb_length_return_keepalive(int fd,char *inbuf,int timeout)
read 4 bytes of a smb packet and return the smb length of the packet
store the result in the buffer. This version of the function will
never return a session keepalive (length of zero).
timeout is in milliseconds.
****************************************************************************/
int read_smb_length(int fd,char *inbuf,int timeout)
ssize_t read_smb_length(int fd,char *inbuf,unsigned int timeout)
{
int len;
ssize_t len;
for(;;)
{
@ -2166,14 +2171,13 @@ int read_smb_length(int fd,char *inbuf,int timeout)
/****************************************************************************
read an smb from a fd. Note that the buffer *MUST* be of size
BUFFER_SIZE+SAFETY_MARGIN.
The timeout is in milli seconds.
The timeout is in milliseconds.
This function will return on a
receipt of a session keepalive packet.
****************************************************************************/
BOOL receive_smb(int fd,char *buffer, int timeout)
BOOL receive_smb(int fd,char *buffer, unsigned int timeout)
{
int len,ret;
ssize_t len,ret;
smb_read_error = 0;
@ -2202,7 +2206,7 @@ BOOL receive_smb(int fd,char *buffer, int timeout)
/****************************************************************************
read an smb from a fd ignoring all keepalive packets. Note that the buffer
*MUST* be of size BUFFER_SIZE+SAFETY_MARGIN.
The timeout is in milli seconds
The timeout is in milliseconds
This is exactly the same as receive_smb except that it never returns
a session keepalive packet (just as receive_smb used to do).
@ -2210,7 +2214,7 @@ BOOL receive_smb(int fd,char *buffer, int timeout)
should never go into a blocking read.
****************************************************************************/
BOOL client_receive_smb(int fd,char *buffer, int timeout)
BOOL client_receive_smb(int fd,char *buffer, unsigned int timeout)
{
BOOL ret;
@ -2230,9 +2234,9 @@ BOOL client_receive_smb(int fd,char *buffer, int timeout)
/****************************************************************************
read a message from a udp fd.
The timeout is in milli seconds
The timeout is in milliseconds
****************************************************************************/
BOOL receive_local_message(int fd, char *buffer, int buffer_len, int timeout)
BOOL receive_local_message(int fd, char *buffer, int buffer_len, unsigned int timeout)
{
struct sockaddr_in from;
int fromlen = sizeof(from);
@ -2451,22 +2455,22 @@ BOOL receive_message_or_smb(int smbfd, int oplock_fd,
****************************************************************************/
BOOL send_smb(int fd,char *buffer)
{
int len;
int ret,nwritten=0;
size_t len;
size_t nwritten=0;
ssize_t ret;
len = smb_len(buffer) + 4;
while (nwritten < len)
{
ret = write_socket(fd,buffer+nwritten,len - nwritten);
if (ret <= 0)
{
ret = write_socket(fd,buffer+nwritten,len - nwritten);
if (ret <= 0)
{
DEBUG(0,("Error writing %d bytes to client. %d. Exiting\n",len,ret));
close_sockets();
exit(1);
}
nwritten += ret;
DEBUG(0,("Error writing %d bytes to client. %d. Exiting\n",len,ret));
close_sockets();
exit(1);
}
nwritten += ret;
}
return True;
}
@ -2509,7 +2513,7 @@ int name_extract(char *buf,int ofs,char *name)
return the total storage length of a mangled name
****************************************************************************/
int name_len( char *s )
{
{
int len;
/* If the two high bits of the byte are set, return 2. */
@ -2523,7 +2527,7 @@ int name_len( char *s )
}
return( len );
} /* name_len */
} /* name_len */
/****************************************************************************
send a single packet to a port on another machine
@ -2601,16 +2605,15 @@ BOOL in_list(char *s,char *list,BOOL casesensitive)
if (!list) return(False);
while (next_token(&p,tok,LIST_SEP,sizeof(tok)))
{
if (casesensitive) {
if (strcmp(tok,s) == 0)
return(True);
} else {
if (StrCaseCmp(tok,s) == 0)
return(True);
}
while (next_token(&p,tok,LIST_SEP,sizeof(tok))) {
if (casesensitive) {
if (strcmp(tok,s) == 0)
return(True);
} else {
if (StrCaseCmp(tok,s) == 0)
return(True);
}
}
return(False);
}
@ -3312,7 +3315,7 @@ static char *filename_dos(char *path,char *buf)
/****************************************************************************
expand a pointer to be a particular size
****************************************************************************/
void *Realloc(void *p,int size)
void *Realloc(void *p,size_t size)
{
void *ret=NULL;
@ -4996,7 +4999,7 @@ int str_checksum(char *s)
/*****************************************************************
zero a memory area then free it. Used to catch bugs faster
*****************************************************************/
void zero_free(void *p, int size)
void zero_free(void *p, size_t size)
{
memset(p, 0, size);
free(p);

View File

@ -139,25 +139,15 @@ static int shm_get_share_modes(connection_struct *conn,
if(!found)
{
#ifdef LARGE_SMB_INO_T
DEBUG(5,("get_share_modes no entry for file dev = %x ino = %.0f\n",
(unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(5,("get_share_modes no entry for file dev = %x ino = %lx\n",
(unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
return (0);
}
if(file_scanner_p->locking_version != LOCKING_VERSION)
{
#ifdef LARGE_SMB_INO_T
DEBUG(0,("ERROR: get_share_modes Deleting old share mode v1 %d dev=%x ino=%.0f\n",
file_scanner_p->locking_version, (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(0,("ERROR: get_share_modes Deleting old share mode v1 %d dev=%x ino=%lx\n",
file_scanner_p->locking_version, (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
if(file_prev_p == file_scanner_p)
mode_array[hash_entry] = file_scanner_p->next_offset;
@ -214,13 +204,8 @@ static int shm_get_share_modes(connection_struct *conn,
/* PARANOIA TEST */
if(file_scanner_p->num_share_mode_entries < 0)
{
#ifdef LARGE_SMB_INO_T
DEBUG(0,("PANIC ERROR: get_share_mode: entries=%d dev=%x ino=%.0f\n",
file_scanner_p->num_share_mode_entries, (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(0,("PANIC ERROR: get_share_mode: entries=%d dev=%x ino=%lx\n",
file_scanner_p->num_share_mode_entries, (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
return 0;
}
@ -251,13 +236,9 @@ static int shm_get_share_modes(connection_struct *conn,
/* If no valid share mode entries were found then this record shouldn't exist ! */
if(num_entries_copied == 0)
{
#ifdef LARGE_SMB_INO_T
DEBUG(0,("get_share_modes: file with dev %x inode %.0f empty\n",
(unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(0,("get_share_modes: file with dev %x inode %lx empty\n",
(unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
if(*old_shares)
free((char *)*old_shares);
*old_shares = 0;
@ -269,13 +250,8 @@ static int shm_get_share_modes(connection_struct *conn,
shmops->shm_free(shmops->addr2offset(file_scanner_p));
}
#ifdef LARGE_SMB_INO_T
DEBUG(5,("get_share_modes: file with dev %x inode %.0f -> %d entries\n",
(unsigned int)dev, (double)inode, num_entries_copied));
#else /* LARGE_SMB_INO_T */
DEBUG(5,("get_share_modes: file with dev %x inode %lx -> %d entries\n",
(unsigned int)dev, (unsigned long)inode, num_entries_copied));
#endif /* LARGE_SMB_INO_T */
return(num_entries_copied);
}
@ -330,25 +306,15 @@ static void shm_del_share_mode(int token, files_struct *fsp)
if(!found)
{
#ifdef LARGE_SMB_INO_T
DEBUG(0,("ERROR: del_share_mode no entry for dev %x inode %.0f\n",
(unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(0,("ERROR: del_share_mode no entry for dev %x inode %lx\n",
(unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
return;
}
if(file_scanner_p->locking_version != LOCKING_VERSION)
{
#ifdef LARGE_SMB_INO_T
DEBUG(0,("ERROR: del_share_modes Deleting old share mode v1 %d dev=%x ino=%.0f\n",
file_scanner_p->locking_version, (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(0,("ERROR: del_share_modes Deleting old share mode v1 %d dev=%x ino=%lx\n",
file_scanner_p->locking_version, (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
if(file_prev_p == file_scanner_p)
mode_array[hash_entry] = file_scanner_p->next_offset;
@ -384,13 +350,8 @@ static void shm_del_share_mode(int token, files_struct *fsp)
/* Decrement the number of entries in the record. */
file_scanner_p->num_share_mode_entries -= 1;
#ifdef LARGE_SMB_INO_T
DEBUG(2,("del_share_modes Deleting share mode entry dev=%x ino=%.0f\n",
(unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(2,("del_share_modes Deleting share mode entry dev=%x ino=%lx\n",
(unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
if(entry_prev_p == entry_scanner_p)
/* We are at start of list */
@ -410,13 +371,8 @@ static void shm_del_share_mode(int token, files_struct *fsp)
/* If we deleted the last share mode entry then remove the share mode record. */
if(file_scanner_p->num_share_mode_entries == 0)
{
#ifdef LARGE_SMB_INO_T
DEBUG(2,("del_share_modes num entries = 0, deleting share_mode dev=%x ino=%.0f\n",
(unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(2,("del_share_modes num entries = 0, deleting share_mode dev=%x ino=%lx\n",
(unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
if(file_prev_p == file_scanner_p)
mode_array[hash_entry] = file_scanner_p->next_offset;
@ -427,13 +383,8 @@ static void shm_del_share_mode(int token, files_struct *fsp)
}
else
{
#ifdef LARGE_SMB_INO_T
DEBUG(0,("ERROR: del_share_modes No share mode dev=%x ino=%.0f\n",
(unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(0,("ERROR: del_share_modes No share mode dev=%x ino=%lx\n",
(unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
}
}
@ -501,13 +452,8 @@ static BOOL shm_set_share_mode(int token, files_struct *fsp, uint16 port, uint16
file_scanner_p = new_mode_p;
#ifdef LARGE_SMB_INO_T
DEBUG(3,("set_share_mode: Created share record for %s (dev %x inode %.0f)\n",
fsp->fsp_name, (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(3,("set_share_mode: Created share record for %s (dev %x inode %lx)\n",
fsp->fsp_name, (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
}
/* Now create the share mode entry */
@ -601,25 +547,15 @@ static BOOL shm_remove_share_oplock(files_struct *fsp, int token)
if(!found)
{
#ifdef LARGE_SMB_INO_T
DEBUG(0,("ERROR:remove_share_oplock: no entry found for dev=%x ino=%.0f\n",
(unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(0,("ERROR:remove_share_oplock: no entry found for dev=%x ino=%lx\n",
(unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
return False;
}
if(file_scanner_p->locking_version != LOCKING_VERSION)
{
#ifdef LARGE_SMB_INO_T
DEBUG(0,("ERROR: remove_share_oplock: Deleting old share mode v1=%d dev=%x ino=%.0f\n",
file_scanner_p->locking_version, (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(0,("ERROR: remove_share_oplock: Deleting old share mode v1=%d dev=%x ino=%lx\n",
file_scanner_p->locking_version, (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
if(file_prev_p == file_scanner_p)
mode_array[hash_entry] = file_scanner_p->next_offset;
@ -656,13 +592,8 @@ static BOOL shm_remove_share_oplock(files_struct *fsp, int token)
if(!found)
{
#ifdef LARGE_SMB_INO_T
DEBUG(0,("ERROR: remove_share_oplock: No oplock granted. dev=%x ino=%.0f\n",
(unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(0,("ERROR: remove_share_oplock: No oplock granted. dev=%x ino=%lx\n",
(unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
return False;
}

View File

@ -80,7 +80,7 @@ END {
next;
}
!/^connection_struct|^pipes_struct|^file_fd_struct|^files_struct|^connection_struct|^uid_t|^gid_t|^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t|^enum remote_arch_types|^FILE|^SMB_OFF_T/ {
!/^connection_struct|^pipes_struct|^file_fd_struct|^files_struct|^connection_struct|^uid_t|^gid_t|^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t|^enum remote_arch_types|^FILE|^SMB_OFF_T|^size_t|^ssize_t/ {
next;
}

View File

@ -195,11 +195,13 @@ static void reply_lockingX_error(blocking_lock_record *blr, int eclass, int32 ec
files_struct *fsp = blr->fsp;
connection_struct *conn = conn_find(SVAL(inbuf,smb_tid));
uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
uint32 count, offset;
SMB_OFF_T count, offset;
unsigned char locktype = CVAL(inbuf,smb_vwv3);
BOOL large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES);
char *data;
int i;
data = smb_buf(inbuf) + 10*num_ulocks;
data = smb_buf(inbuf) + ((large_file_format ? 20 : 10)*num_ulocks);
/*
* Data now points at the beginning of the list
@ -209,8 +211,18 @@ static void reply_lockingX_error(blocking_lock_record *blr, int eclass, int32 ec
for(i = blr->lock_num; i >= 0; i--) {
int dummy1;
uint32 dummy2;
count = IVAL(data,SMB_LKLEN_OFFSET(i));
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
if(!large_file_format) {
count = IVAL(data,SMB_LKLEN_OFFSET(i));
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
}
#ifdef LARGE_SMB_OFF_T
else {
count = (((SMB_OFF_T) IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(i))) << 32) |
((SMB_OFF_T) IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(i)));
offset = (((SMB_OFF_T) IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(i))) << 32) |
((SMB_OFF_T) IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(i)));
}
#endif
do_unlock(fsp,conn,count,offset,&dummy1,&dummy2);
}
@ -248,10 +260,11 @@ static BOOL process_lockread(blocking_lock_record *blr)
{
char *outbuf = OutBuffer;
char *inbuf = blr->inbuf;
int nread = -1;
ssize_t nread = -1;
char *data;
int outsize = 0;
uint32 startpos, numtoread;
SMB_OFF_T startpos;
size_t numtoread;
int eclass;
uint32 ecode;
connection_struct *conn = conn_find(SVAL(inbuf,smb_tid));
@ -316,7 +329,7 @@ static BOOL process_lock(blocking_lock_record *blr)
char *outbuf = OutBuffer;
char *inbuf = blr->inbuf;
int outsize;
uint32 count,offset;
SMB_OFF_T count,offset;
int eclass;
uint32 ecode;
connection_struct *conn = conn_find(SVAL(inbuf,smb_tid));
@ -352,8 +365,8 @@ static BOOL process_lock(blocking_lock_record *blr)
* Success - we got the lock.
*/
DEBUG(3,("process_lock : file=%s fnum=%d ofs=%d cnt=%d\n",
fsp->fsp_name, fsp->fnum, (int)offset, (int)count));
DEBUG(3,("process_lock : file=%s fnum=%d offset=%.0f count=%.0f\n",
fsp->fsp_name, fsp->fnum, (double)offset, (double)count));
construct_reply_common(inbuf, outbuf);
outsize = set_message(outbuf,0,0,True);
@ -374,12 +387,13 @@ static BOOL process_lockingX(blocking_lock_record *blr)
connection_struct *conn = conn_find(SVAL(inbuf,smb_tid));
uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
uint16 num_locks = SVAL(inbuf,smb_vwv7);
uint32 count, offset;
SMB_OFF_T count, offset;
BOOL large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES);
char *data;
int eclass=0;
uint32 ecode=0;
data = smb_buf(inbuf) + 10*num_ulocks;
data = smb_buf(inbuf) + ((large_file_format ? 20 : 10)*num_ulocks);
/*
* Data now points at the beginning of the list
@ -387,8 +401,18 @@ static BOOL process_lockingX(blocking_lock_record *blr)
*/
for(; blr->lock_num < num_locks; blr->lock_num++) {
count = IVAL(data,SMB_LKLEN_OFFSET(blr->lock_num));
offset = IVAL(data,SMB_LKOFF_OFFSET(blr->lock_num));
if(!large_file_format) {
count = IVAL(data,SMB_LKLEN_OFFSET(blr->lock_num));
offset = IVAL(data,SMB_LKOFF_OFFSET(blr->lock_num));
}
#ifdef LARGE_SMB_OFF_T
else {
count = (((SMB_OFF_T) IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(blr->lock_num))) << 32) |
((SMB_OFF_T) IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(blr->lock_num)));
offset = (((SMB_OFF_T) IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(blr->lock_num))) << 32) |
((SMB_OFF_T) IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(blr->lock_num)));
}
#endif
errno = 0;
if(!do_lock(fsp,conn,count,offset, ((locktype & 1) ? F_RDLCK : F_WRLCK),
&eclass, &ecode))

View File

@ -27,6 +27,7 @@ extern int DEBUGLEVEL;
/****************************************************************************
seek a file. Try to avoid the seek if possible
****************************************************************************/
SMB_OFF_T seek_file(files_struct *fsp,SMB_OFF_T pos)
{
SMB_OFF_T offset = 0;
@ -41,45 +42,43 @@ SMB_OFF_T seek_file(files_struct *fsp,SMB_OFF_T pos)
/****************************************************************************
read from a file
****************************************************************************/
int read_file(files_struct *fsp,char *data,uint32 pos,int n)
ssize_t read_file(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n)
{
int ret=0,readret;
ssize_t ret=0,readret;
#if USE_READ_PREDICTION
if (!fsp->can_write)
{
ret = read_predict(fsp->fd_ptr->fd,pos,data,NULL,n);
if (!fsp->can_write) {
ret = read_predict(fsp->fd_ptr->fd,pos,data,NULL,n);
data += ret;
n -= ret;
pos += ret;
}
data += ret;
n -= ret;
pos += ret;
}
#endif
#if WITH_MMAP
if (fsp->mmap_ptr)
{
int num = (fsp->mmap_size > pos) ? (fsp->mmap_size - pos) : -1;
num = MIN(n,num);
if (num > 0)
{
memcpy(data,fsp->mmap_ptr+pos,num);
data += num;
pos += num;
n -= num;
ret += num;
}
if (fsp->mmap_ptr) {
SMB_OFF_T num = (fsp->mmap_size > pos) ? (fsp->mmap_size - pos) : -1;
num = MIN(n,num);
#ifdef LARGE_SMB_OFF_T
if ((num > 0) && (num < (1<<(sizeof(size_t)*8))) {
#else /* LARGE_SMB_OFF_T */
if (num > 0) {
#endif /* LARGE_SMB_OFF_T */
memcpy(data,fsp->mmap_ptr+pos,num);
data += num;
pos += num;
n -= num;
ret += num;
}
}
#endif
if (n <= 0)
if (seek_file(fsp,pos) != pos) {
DEBUG(3,("Failed to seek to %.0f\n",(double)pos));
return(ret);
if (seek_file(fsp,pos) != pos)
{
DEBUG(3,("Failed to seek to %d\n",pos));
return(ret);
}
}
if (n > 0) {
readret = read(fsp->fd_ptr->fd,data,n);
@ -93,7 +92,8 @@ int read_file(files_struct *fsp,char *data,uint32 pos,int n)
/****************************************************************************
write to a file
****************************************************************************/
int write_file(files_struct *fsp,char *data,int n)
ssize_t write_file(files_struct *fsp,char *data,size_t n)
{
if (!fsp->can_write) {
@ -119,6 +119,7 @@ int write_file(files_struct *fsp,char *data,int n)
/*******************************************************************
sync a file
********************************************************************/
void sync_file(connection_struct *conn, files_struct *fsp)
{
#ifdef HAVE_FSYNC
@ -126,4 +127,3 @@ void sync_file(connection_struct *conn, files_struct *fsp)
fsync(fsp->fd_ptr->fd);
#endif
}

View File

@ -890,12 +890,12 @@ static int call_nt_transact_create(connection_struct *conn,
p += 8;
SIVAL(p,0,fmode); /* File Attributes. */
p += 12;
#if OFF_T_IS_64_BITS
SIVAL(p,0, file_len & 0xFFFFFFFF);
SIVAL(p,4, (file_len >> 32));
#else /* OFF_T_IS_64_BITS */
SIVAL(p,0,file_len);
#endif /* OFF_T_IS_64_BITS */
#ifdef LARGE_SMB_OFF_T
SIVAL(p,0, file_len & 0xFFFFFFFF);
SIVAL(p,4, (file_len >> 32));
#else /* LARGE_SMB_OFF_T */
SIVAL(p,0,file_len);
#endif /* LARGE_SMB_OFF_T */
}
/* Send the required number of replies */

View File

@ -815,13 +815,8 @@ void open_file_shared(files_struct *fsp,connection_struct *conn,char *fname,int
if(share_entry->op_type & (EXCLUSIVE_OPLOCK|BATCH_OPLOCK))
{
#ifdef LARGE_SMB_INO_T
DEBUG(5,("open_file_shared: breaking oplock (%x) on file %s, \
dev = %x, inode = %.0f\n", share_entry->op_type, fname, (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(5,("open_file_shared: breaking oplock (%x) on file %s, \
dev = %x, inode = %lx\n", share_entry->op_type, fname, (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
/* Oplock break.... */
unlock_share_entry(conn, dev, inode, token);
@ -829,13 +824,8 @@ dev = %x, inode = %lx\n", share_entry->op_type, fname, (unsigned int)dev, (unsig
{
free((char *)old_shares);
#ifdef LARGE_SMB_INO_T
DEBUG(0,("open_file_shared: FAILED when breaking oplock (%x) on file %s, \
dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(0,("open_file_shared: FAILED when breaking oplock (%x) on file %s, \
dev = %x, inode = %lx\n", old_shares[i].op_type, fname, (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
errno = EACCES;
unix_ERR_class = ERRDOS;
@ -940,13 +930,8 @@ dev = %x, inode = %lx\n", old_shares[i].op_type, fname, (unsigned int)dev, (unsi
global_oplocks_open++;
port = oplock_port;
#ifdef LARGE_SMB_INO_T
DEBUG(5,("open_file_shared: granted oplock (%x) on file %s, \
dev = %x, inode = %.0f\n", oplock_request, fname, (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(5,("open_file_shared: granted oplock (%x) on file %s, \
dev = %x, inode = %lx\n", oplock_request, fname, (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
}
else
@ -1114,13 +1099,8 @@ BOOL check_file_sharing(connection_struct *conn,char *fname, BOOL rename_op)
if(rename_op && (share_entry->pid == pid))
{
#ifdef LARGE_SMB_INO_T
DEBUG(0,("check_file_sharing: NT redirector workaround - rename attempted on \
batch oplocked file %s, dev = %x, inode = %.0f\n", fname, (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(0,("check_file_sharing: NT redirector workaround - rename attempted on \
batch oplocked file %s, dev = %x, inode = %lx\n", fname, (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
/*
* This next line is a test that allows the deny-mode
@ -1135,13 +1115,8 @@ batch oplocked file %s, dev = %x, inode = %lx\n", fname, (unsigned int)dev, (uns
else
{
#ifdef LARGE_SMB_INO_T
DEBUG(5,("check_file_sharing: breaking oplock (%x) on file %s, \
dev = %x, inode = %.0f\n", share_entry->op_type, fname, (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(5,("check_file_sharing: breaking oplock (%x) on file %s, \
dev = %x, inode = %lx\n", share_entry->op_type, fname, (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
/* Oplock break.... */
unlock_share_entry(conn, dev, inode, token);
@ -1149,13 +1124,8 @@ dev = %x, inode = %lx\n", share_entry->op_type, fname, (unsigned int)dev, (unsig
{
free((char *)old_shares);
#ifdef LARGE_SMB_INO_T
DEBUG(0,("check_file_sharing: FAILED when breaking oplock (%x) on file %s, \
dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(0,("check_file_sharing: FAILED when breaking oplock (%x) on file %s, \
dev = %x, inode = %lx\n", old_shares[i].op_type, fname, (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
return False;
}

View File

@ -124,13 +124,8 @@ should be %d).\n", msg_len, OPLOCK_BREAK_MSG_LEN));
tval.tv_sec = IVAL(msg_start, OPLOCK_BREAK_SEC_OFFSET);
tval.tv_usec = IVAL(msg_start, OPLOCK_BREAK_USEC_OFFSET);
#ifdef LARGE_SMB_INO_T
DEBUG(5,("process_local_message: oplock break request from \
pid %d, port %d, dev = %x, inode = %.0f\n", remotepid, from_port, (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(5,("process_local_message: oplock break request from \
pid %d, port %d, dev = %x, inode = %lx\n", remotepid, from_port, (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
/*
* If we have no record of any currently open oplocks,
@ -170,15 +165,9 @@ oplocks. Returning success.\n"));
return False;
}
#ifdef LARGE_SMB_INO_T
DEBUG(5,("process_local_message: oplock break reply sent to \
pid %d, port %d, for file dev = %x, inode = %.0f\n",
remotepid, from_port, (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(5,("process_local_message: oplock break reply sent to \
pid %d, port %d, for file dev = %x, inode = %lx\n",
remotepid, from_port, (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
}
break;
@ -210,13 +199,8 @@ reply - dumping info.\n"));
SMB_INO_T inode = IVAL(msg_start, OPLOCK_BREAK_INODE_OFFSET);
#endif /* LARGE_SMB_INO_T */
#ifdef LARGE_SMB_INO_T
DEBUG(0,("process_local_message: unsolicited oplock break reply from \
pid %d, port %d, dev = %x, inode = %.0f\n", remotepid, from_port, (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(0,("process_local_message: unsolicited oplock break reply from \
pid %d, port %d, dev = %x, inode = %lx\n", remotepid, from_port, (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
}
return False;
@ -247,11 +231,7 @@ static BOOL oplock_break(SMB_DEV_T dev, SMB_INO_T inode, struct timeval *tval)
if( DEBUGLVL( 3 ) )
{
#ifdef LARGE_SMB_INO_T
dbgtext( "oplock_break: called for dev = %x, inode = %.0f.\n", (unsigned int)dev, (double)inode );
#else /* LARGE_SMB_INO_T */
dbgtext( "oplock_break: called for dev = %x, inode = %lx.\n", (unsigned int)dev, (unsigned long)inode );
#endif /* LARGE_SMB_INO_T */
dbgtext( "Current global_oplocks_open = %d\n", global_oplocks_open );
}
@ -266,11 +246,7 @@ static BOOL oplock_break(SMB_DEV_T dev, SMB_INO_T inode, struct timeval *tval)
if( DEBUGLVL( 0 ) )
{
dbgtext( "oplock_break: cannot find open file with " );
#ifdef LARGE_SMB_INO_T
dbgtext( "dev = %x, inode = %.0f ", (unsigned int)dev, (double)inode);
#else /* LARGE_SMB_INO_T */
dbgtext( "dev = %x, inode = %lx ", (unsigned int)dev, (unsigned long)inode);
#endif /* LARGE_SMB_INO_T */
dbgtext( "allowing break to succeed.\n" );
}
return True;
@ -290,11 +266,7 @@ static BOOL oplock_break(SMB_DEV_T dev, SMB_INO_T inode, struct timeval *tval)
if( DEBUGLVL( 0 ) )
{
dbgtext( "oplock_break: file %s ", fsp->fsp_name );
#ifdef LARGE_SMB_INO_T
dbgtext( "(dev = %x, inode = %.0f) has no oplock.\n", (unsigned int)dev, (double)inode );
#else /* LARGE_SMB_INO_T */
dbgtext( "(dev = %x, inode = %lx) has no oplock.\n", (unsigned int)dev, (unsigned long)inode );
#endif /* LARGE_SMB_INO_T */
dbgtext( "Allowing break to succeed regardless.\n" );
}
return True;
@ -307,11 +279,7 @@ static BOOL oplock_break(SMB_DEV_T dev, SMB_INO_T inode, struct timeval *tval)
{
dbgtext( "oplock_break: ERROR: oplock_break already sent for " );
dbgtext( "file %s ", fsp->fsp_name);
#ifdef LARGE_SMB_INO_T
dbgtext( "(dev = %x, inode = %.0f)\n", (unsigned int)dev, (double)inode );
#else /* LARGE_SMB_INO_T */
dbgtext( "(dev = %x, inode = %lx)\n", (unsigned int)dev, (unsigned long)inode );
#endif /* LARGE_SMB_INO_T */
}
/* We have to fail the open here as we cannot send another oplock break on
@ -403,11 +371,7 @@ static BOOL oplock_break(SMB_DEV_T dev, SMB_INO_T inode, struct timeval *tval)
OPLOCK_BREAK_TIMEOUT ) );
DEBUGADD( 0, ( "oplock_break failed for file %s ", fsp->fsp_name ) );
#ifdef LARGE_SMB_INO_T
DEBUGADD( 0, ( "(dev = %x, inode = %.0f).\n", (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUGADD( 0, ( "(dev = %x, inode = %lx).\n", (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
shutdown_server = True;
break;
@ -435,11 +399,7 @@ static BOOL oplock_break(SMB_DEV_T dev, SMB_INO_T inode, struct timeval *tval)
dbgtext( "oplock_break: no break received from client " );
dbgtext( "within %d seconds.\n", OPLOCK_BREAK_TIMEOUT );
dbgtext( "oplock_break failed for file %s ", fsp->fsp_name );
#ifdef LARGE_SMB_INO_T
dbgtext( "(dev = %x, inode = %.0f).\n", (unsigned int)dev, (double)inode );
#else /* LARGE_SMB_INO_T */
dbgtext( "(dev = %x, inode = %lx).\n", (unsigned int)dev, (unsigned long)inode );
#endif /* LARGE_SMB_INO_T */
}
shutdown_server = True;
@ -507,11 +467,7 @@ static BOOL oplock_break(SMB_DEV_T dev, SMB_INO_T inode, struct timeval *tval)
if( DEBUGLVL( 3 ) )
{
dbgtext( "oplock_break: returning success for " );
#ifdef LARGE_SMB_INO_T
dbgtext( "dev = %x, inode = %.0f\n", (unsigned int)dev, (double)inode );
#else /* LARGE_SMB_INO_T */
dbgtext( "dev = %x, inode = %lx\n", (unsigned int)dev, (unsigned long)inode );
#endif /* LARGE_SMB_INO_T */
dbgtext( "Current global_oplocks_open = %d\n", global_oplocks_open );
}
@ -576,11 +532,7 @@ should be %d\n", pid, share_entry->op_port, oplock_port));
{
dbgtext( "request_oplock_break: sending a oplock break message to " );
dbgtext( "pid %d on port %d ", share_entry->pid, share_entry->op_port );
#ifdef LARGE_SMB_INO_T
dbgtext( "for dev = %x, inode = %.0f\n", (unsigned int)dev, (double)inode );
#else /* LARGE_SMB_INO_T */
dbgtext( "for dev = %x, inode = %lx\n", (unsigned int)dev, (unsigned long)inode );
#endif /* LARGE_SMB_INO_T */
}
@ -592,11 +544,7 @@ should be %d\n", pid, share_entry->op_port, oplock_port));
dbgtext( "request_oplock_break: failed when sending a oplock " );
dbgtext( "break message to pid %d ", share_entry->pid );
dbgtext( "on port %d ", share_entry->op_port );
#ifdef LARGE_SMB_INO_T
dbgtext( "for dev = %x, inode = %.0f\n", (unsigned int)dev, (double)inode );
#else /* LARGE_SMB_INO_T */
dbgtext( "for dev = %x, inode = %lx\n", (unsigned int)dev, (unsigned long)inode );
#endif /* LARGE_SMB_INO_T */
dbgtext( "Error was %s\n", strerror(errno) );
}
return False;
@ -629,11 +577,7 @@ should be %d\n", pid, share_entry->op_port, oplock_port));
dbgtext( "request_oplock_break: no response received to oplock " );
dbgtext( "break request to pid %d ", share_entry->pid );
dbgtext( "on port %d ", share_entry->op_port );
#ifdef LARGE_SMB_INO_T
dbgtext( "for dev = %x, inode = %.0f\n", (unsigned int)dev, (double)inode );
#else /* LARGE_SMB_INO_T */
dbgtext( "for dev = %x, inode = %lx\n", (unsigned int)dev, (unsigned long)inode );
#endif /* LARGE_SMB_INO_T */
}
/*
@ -651,11 +595,7 @@ should be %d\n", pid, share_entry->op_port, oplock_port));
dbgtext( "request_oplock_break: error in response received " );
dbgtext( "to oplock break request to pid %d ", share_entry->pid );
dbgtext( "on port %d ", share_entry->op_port );
#ifdef LARGE_SMB_INO_T
dbgtext( "for dev = %x, inode = %.0f\n", (unsigned int)dev, (double)inode );
#else /* LARGE_SMB_INO_T */
dbgtext( "for dev = %x, inode = %lx\n", (unsigned int)dev, (unsigned long)inode );
#endif /* LARGE_SMB_INO_T */
dbgtext( "Error was (%s).\n", strerror(errno) );
}
return False;

View File

@ -28,11 +28,11 @@ extern int DEBUGLEVEL;
/* variables used by the read prediction module */
static int rp_fd = -1;
static SMB_OFF_T rp_offset = 0;
static int rp_length = 0;
static int rp_alloced = 0;
static ssize_t rp_length = 0;
static ssize_t rp_alloced = 0;
static int rp_predict_fd = -1;
static SMB_OFF_T rp_predict_offset = 0;
static int rp_predict_length = 0;
static size_t rp_predict_length = 0;
static int rp_timeout = 5;
static time_t rp_time = 0;
static char *rp_buffer = NULL;
@ -42,10 +42,10 @@ extern time_t smb_last_time;
/****************************************************************************
handle read prediction on a file
****************************************************************************/
int read_predict(int fd,SMB_OFF_T offset,char *buf,char **ptr,int num)
ssize_t read_predict(int fd,SMB_OFF_T offset,char *buf,char **ptr,size_t num)
{
int ret = 0;
int possible = rp_length - (offset - rp_offset);
ssize_t ret = 0;
ssize_t possible = rp_length - (offset - rp_offset);
possible = MIN(possible,num);
@ -97,7 +97,7 @@ pre-read some data
****************************************************************************/
void do_read_prediction(void)
{
static int readsize = 0;
static size_t readsize = 0;
if (predict_skip) return;

View File

@ -1765,11 +1765,11 @@ int reply_unlink(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
****************************************************************************/
int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_size, int dum_buffsize)
{
int maxcount,mincount;
int nread = 0;
uint32 startpos;
size_t maxcount,mincount;
size_t nread = 0;
SMB_OFF_T startpos;
char *header = outbuf;
SMB_OFF_T ret=0;
ssize_t ret=0;
int fd;
char *fname;
files_struct *fsp;
@ -1791,8 +1791,23 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
fsp = file_fsp(inbuf,smb_vwv0);
startpos = IVAL(inbuf,smb_vwv1);
maxcount = SVAL(inbuf,smb_vwv3);
mincount = SVAL(inbuf,smb_vwv4);
#ifdef LARGE_SMB_OFF_T
if(SVAL(inbuf,smb_wct) == 10) {
/*
* This is a large offset (64 bit) read.
*/
startpos |= (((SMB_OFF_T)IVAL(inbuf,smb_vwv8)) << 32);
if(startpos < 0) {
DEBUG(0,("readbraw - negative 64 bit readraw offset (%.0f) !\n",
(double)startpos ));
_smb_setlen(header,0);
transfer_file(0,Client,(SMB_OFF_T)0,header,4,0);
return(-1);
}
}
#endif /* LARGE_SMB_OFF_T */
maxcount = (SVAL(inbuf,smb_vwv3) & 0xFFFF);
mincount = (SVAL(inbuf,smb_vwv4) & 0xFFFF);
/* ensure we don't overrun the packet size */
maxcount = MIN(65535,maxcount);
@ -1812,9 +1827,10 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
if (!is_locked(fsp,conn,maxcount,startpos, F_RDLCK))
{
SMB_OFF_T size = fsp->size;
int sizeneeded = startpos + maxcount;
SMB_OFF_T sizeneeded = startpos + maxcount;
if (size < sizeneeded) {
if (size < sizeneeded)
{
SMB_STRUCT_STAT st;
if (sys_fstat(fsp->fd_ptr->fd,&st) == 0)
size = st.st_size;
@ -1822,14 +1838,14 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
fsp->size = size;
}
nread = MIN(maxcount,(int)(size - startpos));
nread = MIN(maxcount,(size - startpos));
}
if (nread < mincount)
nread = 0;
DEBUG( 3, ( "readbraw fnum=%d start=%d max=%d min=%d nread=%d\n",
fsp->fnum, startpos,
DEBUG( 3, ( "readbraw fnum=%d start=%.0f max=%d min=%d nread=%d\n",
fsp->fnum, (double)startpos,
maxcount, mincount, nread ) );
#if UNSAFE_READRAW
@ -1840,12 +1856,12 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
#if USE_READ_PREDICTION
if (!fsp->can_write)
predict = read_predict(fd,startpos,header+4,NULL,nread);
#endif
#endif /* USE_READ_PREDICTION */
if ((nread-predict) > 0)
seek_file(fsp,startpos + predict);
ret = transfer_file(fd,Client,(SMB_OFF_T)(nread-predict),header,4+predict,
ret = (ssize_t)transfer_file(fd,Client,(SMB_OFF_T)(nread-predict),header,4+predict,
startpos+predict);
}
@ -1853,13 +1869,13 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
DEBUG(0,("ERROR: file read failure on %s at %d for %d bytes (%d)\n",
fname,startpos,nread,ret));
#else
#else /* UNSAFE_READRAW */
ret = read_file(fsp,header+4,startpos,nread);
if (ret < mincount) ret = 0;
_smb_setlen(header,ret);
transfer_file(0,Client,0,header,4+ret,0);
#endif
#endif /* UNSAFE_READRAW */
DEBUG(5,("readbraw finished\n"));
return -1;
@ -1871,10 +1887,11 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
****************************************************************************/
int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int length, int dum_buffsiz)
{
int nread = -1;
ssize_t nread = -1;
char *data;
int outsize = 0;
uint32 startpos, numtoread;
SMB_OFF_T startpos;
size_t numtoread;
int eclass;
uint32 ecode;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
@ -1925,10 +1942,10 @@ int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int length
****************************************************************************/
int reply_read(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int numtoread;
int nread = 0;
size_t numtoread;
ssize_t nread = 0;
char *data;
uint32 startpos;
SMB_OFF_T startpos;
int outsize = 0;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
@ -1971,10 +1988,10 @@ int reply_read(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
int reply_read_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize)
{
files_struct *fsp = file_fsp(inbuf,smb_vwv2);
uint32 smb_offs = IVAL(inbuf,smb_vwv3);
int smb_maxcnt = SVAL(inbuf,smb_vwv5);
int smb_mincnt = SVAL(inbuf,smb_vwv6);
int nread = -1;
SMB_OFF_T startpos = IVAL(inbuf,smb_vwv3);
size_t smb_maxcnt = SVAL(inbuf,smb_vwv5);
size_t smb_mincnt = SVAL(inbuf,smb_vwv6);
ssize_t nread = -1;
char *data;
BOOL ok = False;
@ -1989,9 +2006,18 @@ int reply_read_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
set_message(outbuf,12,0,True);
data = smb_buf(outbuf);
if (is_locked(fsp,conn,smb_maxcnt,smb_offs, F_RDLCK))
#ifdef LARGE_SMB_INO_T
if(SVAL(inbuf,smb_wct) == 12) {
/*
* This is a large offset (64 bit) read.
*/
startpos |= (((SMB_OFF_T)IVAL(inbuf,smb_vwv10)) << 32);
}
#endif /* LARGE_SMB_INO_T */
if (is_locked(fsp,conn,smb_maxcnt,startpos, F_RDLCK))
return(ERROR(ERRDOS,ERRlock));
nread = read_file(fsp,data,smb_offs,smb_maxcnt);
nread = read_file(fsp,data,startpos,smb_maxcnt);
ok = True;
if (nread < 0)
@ -2007,21 +2033,20 @@ int reply_read_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
return chain_reply(inbuf,outbuf,length,bufsize);
}
/****************************************************************************
reply to a writebraw (core+ or LANMAN1.0 protocol)
****************************************************************************/
int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int nwritten=0;
int total_written=0;
int numtowrite=0;
int outsize = 0;
long startpos;
ssize_t nwritten=0;
ssize_t total_written=0;
size_t numtowrite=0;
size_t tcount;
SMB_OFF_T startpos;
char *data=NULL;
BOOL write_through;
int tcount;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
int outsize = 0;
CHECK_FSP(fsp,conn);
CHECK_WRITE(fsp);
@ -2049,13 +2074,13 @@ int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int dum_s
return(ERROR(ERRDOS,ERRlock));
if (seek_file(fsp,startpos) != startpos)
DEBUG(0,("couldn't seek to %ld in writebraw\n",startpos));
DEBUG(0,("couldn't seek to %.0f in writebraw\n",(double)startpos));
if (numtowrite>0)
nwritten = write_file(fsp,data,numtowrite);
DEBUG(3,("writebraw1 fnum=%d start=%ld num=%d wrote=%d sync=%d\n",
fsp->fnum, startpos, numtowrite, nwritten, write_through));
DEBUG(3,("writebraw1 fnum=%d start=%.0f num=%d wrote=%d sync=%d\n",
fsp->fnum, (double)startpos, numtowrite, nwritten, write_through));
if (nwritten < numtowrite)
return(UNIXERROR(ERRHRD,ERRdiskfull));
@ -2092,7 +2117,7 @@ int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int dum_s
CVAL(outbuf,smb_com) = SMBwritec;
SSVAL(outbuf,smb_vwv0,total_written);
if (nwritten < numtowrite) {
if (nwritten < (ssize_t)numtowrite) {
CVAL(outbuf,smb_rcls) = ERRHRD;
SSVAL(outbuf,smb_err,ERRdiskfull);
}
@ -2100,8 +2125,8 @@ int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int dum_s
if (lp_syncalways(SNUM(conn)) || write_through)
sync_file(conn,fsp);
DEBUG(3,("writebraw2 fnum=%d start=%ld num=%d wrote=%d\n",
fsp->fnum, startpos, numtowrite, total_written));
DEBUG(3,("writebraw2 fnum=%d start=%.0f num=%d wrote=%d\n",
fsp->fnum, (double)startpos, numtowrite, total_written));
/* we won't return a status if write through is not selected - this
follows what WfWg does */
@ -2111,19 +2136,19 @@ int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int dum_s
return(outsize);
}
/****************************************************************************
reply to a writeunlock (core+)
****************************************************************************/
int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int nwritten = -1;
int outsize = 0;
ssize_t nwritten = -1;
size_t numtowrite;
SMB_OFF_T startpos;
char *data;
uint32 numtowrite,startpos;
int eclass;
uint32 ecode;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
int outsize = 0;
CHECK_FSP(fsp,conn);
CHECK_WRITE(fsp);
@ -2165,18 +2190,17 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, int dum
return(outsize);
}
/****************************************************************************
reply to a write
****************************************************************************/
int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int dum_size,int dum_buffsize)
{
int numtowrite;
int nwritten = -1;
int outsize = 0;
int startpos;
size_t numtowrite;
ssize_t nwritten = -1;
SMB_OFF_T startpos;
char *data;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
int outsize = 0;
CHECK_FSP(fsp,conn);
CHECK_WRITE(fsp);
@ -2209,7 +2233,7 @@ int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int dum_size,i
SSVAL(outbuf,smb_vwv0,nwritten);
if (nwritten < numtowrite) {
if (nwritten < (ssize_t)numtowrite) {
CVAL(outbuf,smb_rcls) = ERRHRD;
SSVAL(outbuf,smb_err,ERRdiskfull);
}
@ -2227,11 +2251,11 @@ int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int dum_size,i
int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize)
{
files_struct *fsp = file_fsp(inbuf,smb_vwv2);
uint32 smb_offs = IVAL(inbuf,smb_vwv3);
int smb_dsize = SVAL(inbuf,smb_vwv10);
int smb_doff = SVAL(inbuf,smb_vwv11);
SMB_OFF_T startpos = IVAL(inbuf,smb_vwv3);
size_t numtowrite = SVAL(inbuf,smb_vwv10);
BOOL write_through = BITSETW(inbuf+smb_vwv7,0);
int nwritten = -1;
ssize_t nwritten = -1;
int smb_doff = SVAL(inbuf,smb_vwv11);
char *data;
CHECK_FSP(fsp,conn);
@ -2240,34 +2264,43 @@ int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int leng
data = smb_base(inbuf) + smb_doff;
if (is_locked(fsp,conn,smb_dsize,smb_offs, F_WRLCK))
#ifdef LLARGE_SMB_INO_T
if(SVAL(inbuf,smb_wct) == 14) {
/*
* This is a large offset (64 bit) write.
*/
startpos |= (((SMB_OFF_T)IVAL(inbuf,smb_vwv12)) << 32);
}
#endif /* LARGE_SMB_INO_T */
if (is_locked(fsp,conn,numtowrite,startpos, F_WRLCK))
return(ERROR(ERRDOS,ERRlock));
seek_file(fsp,smb_offs);
seek_file(fsp,startpos);
/* X/Open SMB protocol says that, unlike SMBwrite
if the length is zero then NO truncation is
done, just a write of zero. To truncate a file,
use SMBwrite. */
if(smb_dsize == 0)
if(numtowrite == 0)
nwritten = 0;
else
nwritten = write_file(fsp,data,smb_dsize);
nwritten = write_file(fsp,data,numtowrite);
if(((nwritten == 0) && (smb_dsize != 0))||(nwritten < 0))
if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0))
return(UNIXERROR(ERRDOS,ERRnoaccess));
set_message(outbuf,6,0,True);
SSVAL(outbuf,smb_vwv2,nwritten);
if (nwritten < smb_dsize) {
if (nwritten < (ssize_t)numtowrite) {
CVAL(outbuf,smb_rcls) = ERRHRD;
SSVAL(outbuf,smb_err,ERRdiskfull);
}
DEBUG(3,("writeX fnum=%d num=%d wrote=%d\n",
fsp->fnum, smb_dsize, nwritten));
fsp->fnum, numtowrite, nwritten));
if (lp_syncalways(SNUM(conn)) || write_through)
sync_file(conn,fsp);
@ -2281,7 +2314,7 @@ int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int leng
****************************************************************************/
int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
uint32 startpos;
SMB_OFF_T startpos;
SMB_OFF_T res= -1;
int mode,umode;
int outsize = 0;
@ -2302,19 +2335,18 @@ int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
umode = SEEK_SET; break;
}
res = sys_lseek(fsp->fd_ptr->fd,(SMB_OFF_T)startpos,umode);
res = sys_lseek(fsp->fd_ptr->fd,startpos,umode);
fsp->pos = res;
outsize = set_message(outbuf,2,0,True);
SIVALS(outbuf,smb_vwv0,(uint32)res);
SIVALS(outbuf,smb_vwv0,res);
DEBUG(3,("lseek fnum=%d ofs=%d mode=%d\n",
fsp->fnum, startpos, mode));
DEBUG(3,("lseek fnum=%d ofs=%.0f mode=%d\n",
fsp->fnum, (double)startpos, mode));
return(outsize);
}
/****************************************************************************
reply to a flush
****************************************************************************/
@ -2421,10 +2453,10 @@ int reply_close(connection_struct *conn,
int reply_writeclose(connection_struct *conn,
char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int numtowrite;
int nwritten = -1;
size_t numtowrite;
ssize_t nwritten = -1;
int outsize = 0;
int startpos;
SMB_OFF_T startpos;
char *data;
time_t mtime;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
@ -2470,7 +2502,7 @@ int reply_lock(connection_struct *conn,
char *inbuf,char *outbuf, int length, int dum_buffsize)
{
int outsize = set_message(outbuf,0,0,True);
uint32 count,offset;
SMB_OFF_T count,offset;
int eclass;
uint32 ecode;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
@ -2481,8 +2513,8 @@ int reply_lock(connection_struct *conn,
count = IVAL(inbuf,smb_vwv1);
offset = IVAL(inbuf,smb_vwv3);
DEBUG(3,("lock fd=%d fnum=%d ofs=%d cnt=%d\n",
fsp->fd_ptr->fd, fsp->fnum, offset, count));
DEBUG(3,("lock fd=%d fnum=%d offset=%.0f count=%.0f\n",
fsp->fd_ptr->fd, fsp->fnum, (double)offset, (double)count));
if (!do_lock(fsp, conn, count, offset, F_WRLCK, &eclass, &ecode)) {
if((ecode == ERRlock) && lp_blocking_locks(SNUM(conn))) {
@ -2507,7 +2539,7 @@ int reply_lock(connection_struct *conn,
int reply_unlock(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int outsize = set_message(outbuf,0,0,True);
uint32 count,offset;
SMB_OFF_T count,offset;
int eclass;
uint32 ecode;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
@ -2521,8 +2553,8 @@ int reply_unlock(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
if(!do_unlock(fsp, conn, count, offset, &eclass, &ecode))
return (ERROR(eclass,ecode));
DEBUG( 3, ( "unlock fd=%d fnum=%d ofs=%d cnt=%d\n",
fsp->fd_ptr->fd, fsp->fnum, offset, count ) );
DEBUG( 3, ( "unlock fd=%d fnum=%d offset=%.0f count=%.0f\n",
fsp->fd_ptr->fd, fsp->fnum, (double)offset, (double)count ) );
return(outsize);
}
@ -3476,8 +3508,6 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
return(outsize);
}
/****************************************************************************
reply to a setdir
****************************************************************************/
@ -3515,7 +3545,6 @@ int reply_setdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
return(outsize);
}
/****************************************************************************
reply to a lockingX request
****************************************************************************/
@ -3528,13 +3557,13 @@ int reply_lockingX(connection_struct *conn, char *inbuf,char *outbuf,int length,
#endif
uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
uint16 num_locks = SVAL(inbuf,smb_vwv7);
uint32 count, offset;
SMB_OFF_T count, offset;
int32 lock_timeout = IVAL(inbuf,smb_vwv4);
int i;
char *data;
uint32 ecode=0, dummy2;
int eclass=0, dummy1;
BOOL large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES);
CHECK_FSP(fsp,conn);
CHECK_ERROR(fsp);
@ -3565,13 +3594,8 @@ no oplock granted on this file.\n", fsp->fnum));
lock_share_entry(fsp->conn, dev, inode, &token);
if(remove_share_oplock(fsp, token)==False) {
#ifdef LARGE_SMB_INO_T
DEBUG(0,("reply_lockingX: failed to remove share oplock for fnum %d, \
dev = %x, inode = %.0f\n", fsp->fnum, (unsigned int)dev, (double)inode));
#else /* LARGE_SMB_INO_T */
DEBUG(0,("reply_lockingX: failed to remove share oplock for fnum %d, \
dev = %x, inode = %lx\n", fsp->fnum, (unsigned int)dev, (unsigned long)inode));
#endif /* LARGE_SMB_INO_T */
unlock_share_entry(fsp->conn, dev, inode, token);
} else {
@ -3596,10 +3620,22 @@ dev = %x, inode = %lx\n", fsp->fnum, (unsigned int)dev, (unsigned long)inode));
/* Data now points at the beginning of the list
of smb_unlkrng structs */
for(i = 0; i < (int)num_ulocks; i++) {
count = IVAL(data,SMB_LKLEN_OFFSET(i));
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
DEBUG(10,("reply_lockingX: unlock start=%d, len=%d for file %s\n",
(int)offset, (int)count, fsp->fsp_name ));
if(!large_file_format) {
count = IVAL(data,SMB_LKLEN_OFFSET(i));
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
}
#ifdef LARGE_SMB_OFF_T
else {
count = (((SMB_OFF_T) IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(i))) << 32) |
((SMB_OFF_T) IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(i)));
offset = (((SMB_OFF_T) IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(i))) << 32) |
((SMB_OFF_T) IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(i)));
}
#endif
DEBUG(10,("reply_lockingX: unlock start=%.0f, len=%.0f for file %s\n",
(double)offset, (double)count, fsp->fsp_name ));
if(!do_unlock(fsp,conn,count,offset,&eclass, &ecode))
return ERROR(eclass,ecode);
}
@ -3608,14 +3644,28 @@ dev = %x, inode = %lx\n", fsp->fnum, (unsigned int)dev, (unsigned long)inode));
lock_timeout = ((lock_timeout == -1) ? -1 : lock_timeout/1000);
/* Now do any requested locks */
data += 10*num_ulocks;
data += ((large_file_format ? 20 : 10)*num_ulocks);
/* Data now points at the beginning of the list
of smb_lkrng structs */
for(i = 0; i < (int)num_locks; i++) {
count = IVAL(data,SMB_LKLEN_OFFSET(i));
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
DEBUG(10,("reply_lockingX: lock start=%d, len=%d for file %s\n",
(int)offset, (int)count, fsp->fsp_name ));
if(!large_file_format) {
count = IVAL(data,SMB_LKLEN_OFFSET(i));
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
}
#ifdef LARGE_SMB_OFF_T
else {
count = (((SMB_OFF_T) IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(i))) << 32) |
((SMB_OFF_T) IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(i)));
offset = (((SMB_OFF_T) IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(i))) << 32) |
((SMB_OFF_T) IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(i)));
}
#endif
DEBUG(10,("reply_lockingX: lock start=%.0f, len=%.0f for file %s\n",
(double)offset, (double)count, fsp->fsp_name ));
if(!do_lock(fsp,conn,count,offset, ((locktype & 1) ? F_RDLCK : F_WRLCK),
&eclass, &ecode)) {
if((ecode == ERRlock) && (lock_timeout != 0) && lp_blocking_locks(SNUM(conn))) {
@ -3635,8 +3685,19 @@ dev = %x, inode = %lx\n", fsp->fnum, (unsigned int)dev, (unsigned long)inode));
all of the previous locks (X/Open spec). */
if(i != num_locks && num_locks != 0) {
for(; i >= 0; i--) {
count = IVAL(data,SMB_LKLEN_OFFSET(i));
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
if(!large_file_format) {
count = IVAL(data,SMB_LKLEN_OFFSET(i));
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
}
#ifdef LARGE_SMB_OFF_T
else {
count = (((SMB_OFF_T) IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(i))) << 32) |
((SMB_OFF_T) IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(i)));
offset = (((SMB_OFF_T) IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(i))) << 32) |
((SMB_OFF_T) IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(i)));
}
#endif
do_unlock(fsp,conn,count,offset,&dummy1,&dummy2);
}
return ERROR(eclass,ecode);
@ -3656,13 +3717,14 @@ dev = %x, inode = %lx\n", fsp->fnum, (unsigned int)dev, (unsigned long)inode));
****************************************************************************/
int reply_readbmpx(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize)
{
int nread = -1;
int total_read;
ssize_t nread = -1;
ssize_t total_read;
char *data;
uint32 startpos;
int outsize, mincount, maxcount;
SMB_OFF_T startpos;
int outsize;
size_t mincount, maxcount;
int max_per_packet;
int tcount;
size_t tcount;
int pad;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
@ -3694,14 +3756,14 @@ int reply_readbmpx(connection_struct *conn, char *inbuf,char *outbuf,int length,
do
{
int N = MIN(max_per_packet,tcount-total_read);
size_t N = MIN(max_per_packet,tcount-total_read);
nread = read_file(fsp,data,startpos,N);
if (nread <= 0) nread = 0;
if (nread < N)
tcount = total_read + nread;
if (nread < (ssize_t)N)
tcount = total_read + nread;
set_message(outbuf,8,nread,False);
SIVAL(outbuf,smb_vwv0,startpos);
@ -3714,22 +3776,23 @@ int reply_readbmpx(connection_struct *conn, char *inbuf,char *outbuf,int length,
total_read += nread;
startpos += nread;
}
while (total_read < tcount);
while (total_read < (ssize_t)tcount);
return(-1);
}
/****************************************************************************
reply to a SMBwritebmpx (write block multiplex primary) request
****************************************************************************/
int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int numtowrite;
int nwritten = -1;
size_t numtowrite;
ssize_t nwritten = -1;
int outsize = 0;
uint32 startpos;
int tcount, write_through, smb_doff;
SMB_OFF_T startpos;
size_t tcount;
BOOL write_through;
int smb_doff;
char *data;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
@ -3758,32 +3821,32 @@ int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int dum_s
if(lp_syncalways(SNUM(conn)) || write_through)
sync_file(conn,fsp);
if(nwritten < numtowrite)
if(nwritten < (ssize_t)numtowrite)
return(UNIXERROR(ERRHRD,ERRdiskfull));
/* If the maximum to be written to this file
is greater than what we just wrote then set
up a secondary struct to be attached to this
fd, we will use this to cache error messages etc. */
if(tcount > nwritten)
if((ssize_t)tcount > nwritten)
{
write_bmpx_struct *wbms;
if(fsp->wbmpx_ptr != NULL)
wbms = fsp->wbmpx_ptr; /* Use an existing struct */
else
wbms = (write_bmpx_struct *)malloc(sizeof(write_bmpx_struct));
if(!wbms)
{
write_bmpx_struct *wbms;
if(fsp->wbmpx_ptr != NULL)
wbms = fsp->wbmpx_ptr; /* Use an existing struct */
else
wbms = (write_bmpx_struct *)malloc(sizeof(write_bmpx_struct));
if(!wbms)
{
DEBUG(0,("Out of memory in reply_readmpx\n"));
return(ERROR(ERRSRV,ERRnoresource));
}
wbms->wr_mode = write_through;
wbms->wr_discard = False; /* No errors yet */
wbms->wr_total_written = nwritten;
wbms->wr_errclass = 0;
wbms->wr_error = 0;
fsp->wbmpx_ptr = wbms;
DEBUG(0,("Out of memory in reply_readmpx\n"));
return(ERROR(ERRSRV,ERRnoresource));
}
wbms->wr_mode = write_through;
wbms->wr_discard = False; /* No errors yet */
wbms->wr_total_written = nwritten;
wbms->wr_errclass = 0;
wbms->wr_error = 0;
fsp->wbmpx_ptr = wbms;
}
/* We are returning successfully, set the message type back to
SMBwritebmpx */
@ -3816,11 +3879,13 @@ int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int dum_s
****************************************************************************/
int reply_writebs(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int numtowrite;
int nwritten = -1;
size_t numtowrite;
ssize_t nwritten = -1;
int outsize = 0;
int32 startpos;
int tcount, write_through, smb_doff;
SMB_OFF_T startpos;
size_t tcount;
BOOL write_through;
int smb_doff;
char *data;
write_bmpx_struct *wbms;
BOOL send_response = False;
@ -3858,32 +3923,34 @@ int reply_writebs(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz
if(lp_syncalways(SNUM(conn)) || write_through)
sync_file(conn,fsp);
if (nwritten < numtowrite)
if (nwritten < (ssize_t)numtowrite)
{
if(write_through)
{
if(write_through) {
/* We are returning an error - we can delete the aux struct */
if (wbms) free((char *)wbms);
fsp->wbmpx_ptr = NULL;
return(ERROR(ERRHRD,ERRdiskfull));
}
return(CACHE_ERROR(wbms,ERRHRD,ERRdiskfull));
/* We are returning an error - we can delete the aux struct */
if (wbms) free((char *)wbms);
fsp->wbmpx_ptr = NULL;
return(ERROR(ERRHRD,ERRdiskfull));
}
return(CACHE_ERROR(wbms,ERRHRD,ERRdiskfull));
}
/* Increment the total written, if this matches tcount
we can discard the auxiliary struct (hurrah !) and return a writeC */
wbms->wr_total_written += nwritten;
if(wbms->wr_total_written >= tcount)
{
if (write_through)
{
if (write_through) {
outsize = set_message(outbuf,1,0,True);
SSVAL(outbuf,smb_vwv0,wbms->wr_total_written);
send_response = True;
}
free((char *)wbms);
fsp->wbmpx_ptr = NULL;
outsize = set_message(outbuf,1,0,True);
SSVAL(outbuf,smb_vwv0,wbms->wr_total_written);
send_response = True;
}
free((char *)wbms);
fsp->wbmpx_ptr = NULL;
}
if(send_response)
return(outsize);