libsmbclient smbc_lseek works wrong?

Richard Sharpe rsharpe at richardsharpe.com
Wed Jan 12 16:12:02 GMT 2005


On Wed, 12 Jan 2005, Jelmer Vernooij wrote:

> On Wed, Jan 12, 2005 at 07:18:36PM +0600, RandoMan wrote about 'libsmbclient smbc_lseek works wrong?':
> > As far as I understand, the call of smbc_lseek() should set the
> > current position of file and return the resulting position in the
> > file. I trying to use following code:
>
> > int sfd=smbc_open(filename,O_RDONLY,0644);
> > off_t cur_pos=smbc_lseek(sfd,start,SEEK_SET);
>
> > and cur_pos sets to zero.
> > The file I tried to open exists, and has length 43 bytes, the
> > following smbc_read lists the content of this file, but smbc_lseek
> > doesn't  set the position to read.
> > What I do wrong? :-/
>
> Make sure you compile your application with the same flags as
> Samba was compiled. off_t is different in size when compiled with 64
> bit support enabled.

Hmmm, actually, I suspect the problem might be related to the protocol.
While the server keeps state about the client, one thing it does not keep
is the current offset into the file that the user is up to. That is
because all requests to read or write a file are accompanied with the
offset that you want to read from or write to.

When I wrote the code initially, I didn't think of this aspect.

I suspect that we will need to update all READ and WRITE requests
(smbc_read and smbc_write) to update curpos for the file handle after the
read/write completes.

Regards
-----
Richard Sharpe, rsharpe[at]richardsharpe.com, rsharpe[at]samba.org,
sharpe[at]ethereal.com, http://www.richardsharpe.com


More information about the samba-technical mailing list