sgx-lkl
sgx-lkl copied to clipboard
[Tests] statfs() syscall return zero for total blocks, available blocks & free blocks fields
In sgx-lkl, the file system information returned from statfs() syscall contains zero for the parameters total number of blocks(f_blocks), free blocks (f_bfree) and free blocks available to unprivileged user(f_bavail).
background of the issue: Original LTP test case “kernel-syscalls-sendfile-sendfile09” check 5GB available free space in current directory path by invoking test framework function “tst_fs_has_free”. This test framework function reads the statefs details of file system and checks available memory (f_bavail * f_bsize) with 5GB.
Based on GDB logs it looks the statfs data returned from kernel has 0 value for total number of blocks(f_blocks), free blocks (f_bfree) and free blocks available to unprivileged user(f_bavail).
What is the bug here? Are these incorrect values? With a minimal disk image, these are the values that I would expect. Does the LTP test runner need an image with 5GB free for this to pass?
Original Test Case Description: This test case is to test "sendfile09" system call on large files. Below specified sub test case. 1. call sendfile(2) with offset at 0. 2. call sendfile(2) with offset at 3GB. In both the cases 1GB data is send. Link: https://github.com/linux-test-project/ltp/blob/c5311d26fb80988de010301c0855a5f65442c6c0/testcases/kernel/syscalls/sendfile/sendfile09.c#L139
Modifications: This test case is modified to use maximum of 4MB.
Problem/Issue: This test case checks for available free space in the file system. It performs below algorithm.
- Read the file system statistics by invoking "statfs" system call and calculate (f_bavail * f_bsize) the available free size.
- Problem here is statfs always returning below values as 0 and test case failed. (this failure is observed even after reducing the size to 4MB) a. total number of blocks(f_blocks) b. free blocks (f_bfree) c. free blocks available to unprivileged user(f_bavail). Link: https://github.com/linux-test-project/ltp/blob/c5311d26fb80988de010301c0855a5f65442c6c0/lib/tst_fs_has_free.c#L34
GDB Logs:
(gdb) bt
0 tst_fs_has_free_ (cleanup=cleanup@entry=0x0, path=path@entry=0x7fff3dad06c6 ".", size=size@entry=5, mult=mult@entry=1073741824) at tst_fs_has_free.c:31
1 0x00007fff3dabf69e in tst_fs_has_free (mult=1073741824, size=5, path=0x7fff3dad06c6 ".", cleanup=0x0) at ../../../../include/tst_fs.h:223
2 setup () at sendfile09.c:139
3 main (ac=1, av=0x7fff40b5ee98) at sendfile09.c:186
4 0x00007fff00538402 in libc_start_main_stage2 (main=0x7fff3dabf610