Hi Cyril,
Thanks for helping to investigate this issue.
Will update the patch.

Thanks
Shuang
On 05/29/2014 07:56 PM, [email protected] wrote:
> Hi!
>>> It does not make sense to use stdout as the file description to test the
>>> system call fstatfs().We may get unexpected result(i.e.
>>> errno=38:Function not implemented) if redirect stdout when running ltp.
>>> Using ltp temporary file instead.
>>>
>>> Signed-off-by: Shuang Qiu <[email protected]>
>> The problem is that with the 2.6.39 series of kernels ENOSYS is returned
>> where EFAULT is expected.
>>
>> The reproducer:
>> #include <error.h>
>> #include <stdio.h>
>> #include <unistd.h>
>> #include <sys/vfs.h>
>>
>> int main(void)
>> {
>>     int fds[2];
>>
>>     if (pipe(fds) < 0) {
>>       perror("pipe() failed");
>>       return 1;
>>     }
>>
>>     if (fstatfs(fds[1], (void *)-1) < 0) {
>>       perror("fstatfs() failed");
>>       return 1;
>>     }
>>
>>     return 0;
>> }
>>
>> With 2.6.18, 2.6.32, 3.8.13 this reproducer returns EFAULT,
>> but with 2.6.39 - ENOSYS.
>>
>> If we change '(void *)-1' to a vaild pointer, fstatfs() + 2.6.39 will
>> succeed.
>>
>> So it's a bug in 2.6.39, which is fixed in modern kernels.
> I've looked at fstatfs() and pipe() code in recent kernel.
>
> The fstatfs() looks at dentry and if there is no statfs callback it
> returns ENOSYS, otherwise it uses the callback to fill the buffer.
>
> The pipe() mounts an "pipe:" kernel internal pseudo fs and uses
> simple_statfs() for the statfs() callback. So statfs() works fine on
> recent kernels. In 2.6.39 the pipefs_ops structure simply misses the
> fstatfs() callback, it has been introduced in:
>
> commit d70ef97baf048412c395bb5d65791d8fe133a52b
> Author: Pavel Emelyanov <[email protected]>
> Date:   Mon Oct 31 17:10:04 2011 -0700
>
>      fs/pipe.c: add ->statfs callback for pipefs
>
> I guess that we can add a test for fstatfs() on a pipe if kernel version
> is newer than 3.2.
>
>>   From one side, the above patch makes fstatfs02 pass by hiding an old
>> (and already fixed) kernel bug.
>>
>> But from the other side, it also enlarges the test scope by allowing to
>> test different file systems.
>>
>> So, personally, I would accept it.
>>
>> Are there any thoughts about it?
> I'm for fixing the testcase this way. If nothing else it makes it the
> test actually test what it's expected to test.
>
> Just cleanup the patch a bit before applying (use SAFE_OPEN(), etc).
>


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to