Ok so with this bugfix 64 bit file access actually seems to work :-).
authorJeremy Allison <jra@samba.org>
Fri, 11 Sep 1998 21:42:18 +0000 (21:42 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 11 Sep 1998 21:42:18 +0000 (21:42 +0000)
Problems were just dumb bugs like (defining sys_lseek to return 'int' DOH !).

Jeremy.
(This used to be commit 54dd51176fbab18af0b21bdee71b53f8f86573a8)

source3/client/client.c
source3/client/clitar.c
source3/include/proto.h
source3/lib/system.c
source3/smbd/fileio.c
source3/smbd/nttrans.c
source3/smbd/reply.c

index e08beeb68531e012d05c89344e3132c8222c9c61..b48e520d96a614dfc553a5919e51598e490d165e 100644 (file)
@@ -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));
index 376d3aeac6991eaf1e06cfc66c4c856858f26f1e..1ca8c1a4dcc230389a92785cea5f74b8be576e85 100644 (file)
@@ -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));
index 4c966b2faa0d69ab2bdf43c8278c9d26404385f4..a864cd7033dc085a5508eb0bf620b9d9a8b1a1a0 100644 (file)
@@ -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);
index b6a59e864824631b77d497a3c63614331a99b26c..215bfd0c1df7d8e5b4f3ab5c8f137541e5455d22 100644 (file)
@@ -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);
index f0bb5e45ac441659d80f1502301773809b88f910..d40c159798df42c6bbee102afe4a85befed714ff 100644 (file)
@@ -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);
   }
   
index 81b3ff26d525d0172af2eb9f663fe5fad8965dcd..5052e6d52ac1e682913c2280ef1316fd67c14a68 100644 (file)
@@ -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);
index e956ab6cd9393586cef55824c80f0a149ed43a22..38c39efad6b7b5fd82edaec6e8ecaad60a65eefb 100644 (file)
@@ -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.
      */