Libsmbclient fails to handle filse sizes more than 4GB

Abhijeet Paturkar abhijeet.paturkar at
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. 
#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
             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 =
    //this url points to a 220MB(220,753,920 bytes) file for which the
program runs successfully
    const char* url2 =
    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;
    if( (fd = smbc_open(url1,O_RDONLY,0666)) == -1)
        cout << "smbc_open failed" << endl;
    // 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
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.
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>
abhijeet.paturkar at
<mailto:ashish.nadkarni at> 
Web :  <>	
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 11417 bytes
Desc: not available
Url :

More information about the samba-technical mailing list