[FFmpeg-devel] [PATCH] lavf: add subfile protocol.

Lukasz M lukasz.m.luki at gmail.com
Thu Feb 27 20:15:40 CET 2014


On 27 February 2014 19:34, Lukasz M <lukasz.m.luki at gmail.com> wrote:

> On 27 February 2014 19:27, Nicolas George <george at nsup.org> wrote:
>
>> Le nonidi 9 ventôse, an CCXXII, Lukasz Marek a écrit :
>> > In file protocol lseek is used. If you pass SEEK_SET and n as new
>> > pos it always returns n and errno = 0. Even when seeking beyond end
>> > of the file or before beginning.  When you look at code file.c it
>> > will return 0 in case seeking to position before beginning.
>>
>> I think you read the code wrong. In the file protocol, as you say, lseek
>> is
>> used, and it returns whatever lseek returns.
>
>
> but when lseek returns negative, AVERROR(errno) is return and I get always
> 0.
>
>
>> After your first mail, I
>> checked in the specs, and I just re-checked by experiment: both confirm
>> that
>> seeking below 0 is not legal and just fails with EINVAL.
>
> Seeking past the end of the file is legal, although useless for reading.
>>
>> I therefore believe this part of the patch is fine.
>>
>
> I saw same specs says that explicitly it is an error, some not.
> I made experiment too and no error by errno was reported.
> It is ok with me, just noted that.
>

OK, I reproduced that lseek returns -1 and set errno to 22.
Strange thing about that anyway.

On debian it works as you say. On ubuntu (12.04, 13.10) following code

#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
//#include <unistd.h>

int main(void)
{
   int fh;
   off_t p;

   fh = open("sample.txt", O_RDONLY);

   errno = 0;
   p = lseek(fh, -2, SEEK_SET);

   printf("%ld %d\n", p, errno);

   close(fh);
   return 0;
}

depends on unistd.h being included / not included

OK, I think I will fix ftp and libssh the same way you did it here


More information about the ffmpeg-devel mailing list