smbc_lseek libsmbclient ?
Richard Sharpe
rsharpe at richardsharpe.com
Sat May 14 23:33:06 GMT 2005
On Sat, 14 May 2005, Richard Sharpe wrote:
> On Sat, 14 May 2005, Matthieu Tourne wrote:
>
> > Hello,
> >
> > I'm using smbc_lseek(fd,0,SEEK_END), to get the length of a file. But
> > it fails with files bigger than 4gb even when compiling with :
> > HAVE_EXPLICIT_LARGEFILE_SUPPORT, HAVE_OFF64_T, HAVE_LSEEK64.
> > (I don't know if it's useful because the library is a .so)
> >
> > The offset returned by the function is 64bit long but the value is
> > incoherent (not -1).
> > (actually it's 801613448, although the file is 5096580744)
>
> It's possible that we are assigning this to an intermediate uint32_t
> before returning it. I will check in a little while.
OK, that's not the case, as the two variables used with SEEK_END are both
of type SMB_OFF_T which is defined as int64_t on those platforms that
support it.
The code that handles SEEK_END does this:
case SEEK_END:
if (!cli_qfileinfo(&file->srv->cli, file->cli_fd, NULL,
&size, NULL, NULL,
NULL, NULL, NULL))
{
SMB_BIG_UINT b_size = size;
if (!cli_getattrE(&file->srv->cli, file->cli_fd, NULL,
&b_size, NULL, NULL,
NULL))
{
errno = EINVAL;
return -1;
} else
size = b_size;
}
file->offset = size + offset;
break;
If either of cli_qfileinfo or cli_getattrE does something wrong with
sizes larger than 4GB, we could have a problem. I haven't looked as yet.
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