From 54dd51176fbab18af0b21bdee71b53f8f86573a8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 11 Sep 1998 21:42:18 +0000 Subject: Ok so with this bugfix 64 bit file access actually seems to work :-). Problems were just dumb bugs like (defining sys_lseek to return 'int' DOH !). Jeremy. --- source/client/client.c | 2 +- source/client/clitar.c | 2 +- source/include/proto.h | 2 +- source/lib/system.c | 2 +- source/smbd/fileio.c | 8 ++++++-- source/smbd/nttrans.c | 22 ++++++++++++++++++---- source/smbd/reply.c | 6 +++--- 7 files changed, 31 insertions(+), 13 deletions(-) diff --git a/source/client/client.c b/source/client/client.c index e08beeb6853..b48e520d96a 100644 --- a/source/client/client.c +++ b/source/client/client.c @@ -1123,7 +1123,7 @@ static void do_get(char *rname,char *lname,file_info *finfo1) SSVAL(outbuf,smb_vwv1,smb_offset(p,outbuf)); bzero(p,200); p -= smb_wct; - SSVAL(p,smb_wct,10); + SCVAL(p,smb_wct,10); SSVAL(p,smb_vwv0,0xFF); SSVAL(p,smb_vwv5,MIN(max_xmit-500,finfo.size)); SSVAL(p,smb_vwv9,MIN(BUFFER_SIZE,finfo.size)); diff --git a/source/client/clitar.c b/source/client/clitar.c index 376d3aeac69..1ca8c1a4dcc 100644 --- a/source/client/clitar.c +++ b/source/client/clitar.c @@ -1071,7 +1071,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1) SSVAL(outbuf,smb_vwv1,PTR_DIFF(p,outbuf) - 4); memset(p,0,200); p -= smb_wct; - SSVAL(p,smb_wct,10); + SCVAL(p,smb_wct,10); SSVAL(p,smb_vwv0,0xFF); SSVAL(p,smb_vwv5,MIN(max_xmit-500,finfo.size)); SSVAL(p,smb_vwv9,MIN(0xFFFF,finfo.size)); diff --git a/source/include/proto.h b/source/include/proto.h index 4c966b2faa0..a864cd7033d 100644 --- a/source/include/proto.h +++ b/source/include/proto.h @@ -159,7 +159,7 @@ int sys_stat(char *fname,SMB_STRUCT_STAT *sbuf); int sys_fstat(int fd,SMB_STRUCT_STAT *sbuf); int sys_lstat(char *fname,SMB_STRUCT_STAT *sbuf); int sys_ftruncate(int fd, SMB_OFF_T offset); -int sys_lseek(int fd, SMB_OFF_T offset, int whence); +SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence); int dos_unlink(char *fname); int dos_open(char *fname,int flags,int mode); DIR *dos_opendir(char *dname); diff --git a/source/lib/system.c b/source/lib/system.c index b6a59e86482..215bfd0c1df 100644 --- a/source/lib/system.c +++ b/source/lib/system.c @@ -195,7 +195,7 @@ int sys_ftruncate(int fd, SMB_OFF_T offset) An lseek() wrapper that will deal with 64 bit filesizes. ********************************************************************/ -int sys_lseek(int fd, SMB_OFF_T offset, int whence) +SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence) { #if defined(HAVE_OFF64_T) && defined(HAVE_LSEEK64) return lseek64(fd, offset, whence); diff --git a/source/smbd/fileio.c b/source/smbd/fileio.c index f0bb5e45ac4..d40c159798d 100644 --- a/source/smbd/fileio.c +++ b/source/smbd/fileio.c @@ -36,6 +36,10 @@ SMB_OFF_T seek_file(files_struct *fsp,SMB_OFF_T pos) offset = 3; fsp->pos = (sys_lseek(fsp->fd_ptr->fd,pos+offset,SEEK_SET) - offset); + + DEBUG(10,("seek_file: requested pos = %.0f, new pos = %.0f\n", + (double)(pos+offset), (double)fsp->pos )); + return(fsp->pos); } @@ -62,7 +66,7 @@ ssize_t read_file(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n) 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))) { + if ((num > 0) && (num < (1LL<<(sizeof(size_t)*8)))) { #else /* LARGE_SMB_OFF_T */ if (num > 0) { #endif /* LARGE_SMB_OFF_T */ @@ -76,7 +80,7 @@ ssize_t read_file(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n) #endif if (seek_file(fsp,pos) != pos) { - DEBUG(3,("Failed to seek to %.0f\n",(double)pos)); + DEBUG(3,("read_file: Failed to seek to %.0f\n",(double)pos)); return(ret); } diff --git a/source/smbd/nttrans.c b/source/smbd/nttrans.c index 81b3ff26d52..5052e6d52ac 100644 --- a/source/smbd/nttrans.c +++ b/source/smbd/nttrans.c @@ -661,9 +661,16 @@ int reply_ntcreate_and_X(connection_struct *conn, put_long_date(p,sbuf.st_mtime); /* change time */ p += 8; SIVAL(p,0,fmode); /* File Attributes. */ - p += 12; + p += 4; +#ifdef LARGE_SMB_OFF_T + SIVAL(p,0, file_len); + SIVAL(p,4, file_len >> 32); +#else /* LARGE_SMB_OFF_T */ + SIVAL(p,0,file_len); +#endif /* LARGE_SMB_OFF_T */ + p += 8; #ifdef LARGE_SMB_OFF_T - SIVAL(p,0, file_len & 0xFFFFFFFF); + SIVAL(p,0, file_len); SIVAL(p,4, file_len >> 32); #else /* LARGE_SMB_OFF_T */ SIVAL(p,0,file_len); @@ -889,9 +896,16 @@ static int call_nt_transact_create(connection_struct *conn, put_long_date(p,sbuf.st_mtime); /* change time */ p += 8; SIVAL(p,0,fmode); /* File Attributes. */ - p += 12; + p += 4; +#ifdef LARGE_SMB_OFF_T + SIVAL(p,0, file_len); + SIVAL(p,4, (file_len >> 32)); +#else /* LARGE_SMB_OFF_T */ + SIVAL(p,0,file_len); +#endif /* LARGE_SMB_OFF_T */ + p += 8; #ifdef LARGE_SMB_OFF_T - SIVAL(p,0, file_len & 0xFFFFFFFF); + SIVAL(p,0, file_len); SIVAL(p,4, (file_len >> 32)); #else /* LARGE_SMB_OFF_T */ SIVAL(p,0,file_len); diff --git a/source/smbd/reply.c b/source/smbd/reply.c index e956ab6cd93..38c39efad6b 100644 --- a/source/smbd/reply.c +++ b/source/smbd/reply.c @@ -1792,7 +1792,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s startpos = IVAL(inbuf,smb_vwv1); #ifdef LARGE_SMB_OFF_T - if(SVAL(inbuf,smb_wct) == 10) { + if(CVAL(inbuf,smb_wct) == 10) { /* * This is a large offset (64 bit) read. */ @@ -2007,7 +2007,7 @@ int reply_read_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt data = smb_buf(outbuf); #ifdef LARGE_SMB_OFF_T - if(SVAL(inbuf,smb_wct) == 12) { + if(CVAL(inbuf,smb_wct) == 12) { /* * This is a large offset (64 bit) read. */ @@ -2265,7 +2265,7 @@ int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int leng data = smb_base(inbuf) + smb_doff; #ifdef LLARGE_SMB_OFF_T - if(SVAL(inbuf,smb_wct) == 14) { + if(CVAL(inbuf,smb_wct) == 14) { /* * This is a large offset (64 bit) write. */ -- cgit v1.2.1