Libsmbclient fails to handle filse sizes more than 4GB

Abhijeet Paturkar abhijeet.paturkar at xcelvision.com
Wed Apr 23 11:17:21 GMT 2003


Hi all,
We are using libsmbclient library in our product.
The lib. works absolutely fine with files sizes less than 4GB.
It fails for more than 4GB sizes.
Following is the program demonstrating this 
The readers are requested to modify the code to change hardcoded values.
Does any one uses libsmbclient fore dealing with files more than 4GB, if
yes please help us 
to use it in right way. 
 
*************************************************************PROGRAM****
************************************************************
#include <libsmbclient.h>
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
#define BUFSIZE (1024*1024)
 
//This function is required when we call the Samba library
//function smbc_init() that performs basic initializations.
 
extern "C" {
void auth_fn(const char *server, const char *share,
             char *workgroup, int wgmaxlen, char *username, int
unmaxlen,
             char *password, int pwmaxlen)
{
}
}
 
int main()
{
    //this url points to a 6GB(6,401,863,680 bytes) file on Windows
machine for which the samba library fails
    const char* url1 =
"smb://test:test1234@192.168.0.101/data/BIGFILE/6GBFile.zip";
 
    //this url points to a 220MB(220,753,920 bytes) file for which the
program runs successfully
    const char* url2 =
"smb://test:test1234@192.168.0.101/data/BIGFILE/bsk.tar";
 
    int fd;
    char buf[BUFSIZE];
    unsigned long nbytes=0;
    unsigned long long totbytes=0;
    int count = 0;
 
    if( smbc_init(auth_fn,0) == -1 )
    {
        cout << "smbc_init failed" << endl;
        exit(-1);
    }
 
    if( (fd = smbc_open(url1,O_RDONLY,0666)) == -1)
    {
        cout << "smbc_open failed" << endl;
        exit(-1);
    }
 
    // Reading 1MB at a time. For 6GB file the loop never breaks.
    while( (nbytes = smbc_read(fd,buf,BUFSIZE)) > 0)
    {
         totbytes += nbytes;
         //Printing the total bytes read after every smbc_read
         printf("Total bytes Read till NOW : %llu\n", totbytes);
    }
}

*************************************************************END OF
PROGRAM*****************************************************************
******
 
Outputs:
 
In case of url pointing to a 220MB file the last statement printed by
the program is --> Total bytes Read till NOW : 220753920
which means that the program was successfully able to read 220MB file
and exited normally.
 
In case of url pointing to a 6GB file after some time of execution the
program had to be killed and the last statement before killing was -->
Total bytes Read till NOW : 15398338560
( more than 15GB data read )
which means that the program has gone well beyond 6GB and was not able
to detect the end of the file.
 
 
Regards
Abhijeet
 
 
	
 	 
Abhijeet Paturkar
Project Leader
Software Solutions Group	
XcelVision Technologies Ltd. 
Tel : (91-22)  28399900 / 11 
Fax : (91-22) 28399898 
e-mail : <mailto:abhijeet.paturkar at xcelvision.com>
abhijeet.paturkar at xcelvision.com
<mailto:ashish.nadkarni at xcelvision.com> 
Web :  <http://www.xcelvision.com/> www.xcelvision.com	
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 11417 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba-technical/attachments/20030423/fe44e68a/attachment.jpg


More information about the samba-technical mailing list