From: Michal Simek <[email protected]>

"Fields that are undefined for a particular file system are set to 0".
Note that if it's ramfs or tmpfs with -o nr_blocks=0,
there is no such thing as "amount of free space", reserved for root
or not. - Al Viro

Signed-off-by: Michal Simek <[email protected]>
---
 testcases/kernel/syscalls/fsync/fsync02.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/fsync/fsync02.c 
b/testcases/kernel/syscalls/fsync/fsync02.c
index 7ba2c50..913f7db 100644
--- a/testcases/kernel/syscalls/fsync/fsync02.c
+++ b/testcases/kernel/syscalls/fsync/fsync02.c
@@ -166,6 +166,9 @@ int main(int ac, char **av)
  */
 void setup()
 {
+       /* free blocks avail to non-superuser */
+       unsigned long f_bavail;
+
        /* capture signals */
        tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
@@ -187,9 +190,10 @@ void setup()
                         "file system");
        }
 
-       if ((stat_buf.f_bavail / (BLOCKSIZE / stat_buf.f_frsize)) < MAXBLKS) {
-               max_blks = stat_buf.f_bavail / (BLOCKSIZE / stat_buf.f_frsize);
-       }
+       f_bavail = stat_buf.f_bavail / (BLOCKSIZE / stat_buf.f_frsize);
+       if (f_bavail && (f_bavail < MAXBLKS))
+               max_blks = f_bavail;
+
 #ifdef LARGEFILE
        if ((fcntl(fd, F_SETFL, O_LARGEFILE)) == -1) {
                tst_brkm(TBROK, cleanup, "fcntl failed to O_LARGEFILE");
-- 
1.5.5.1


------------------------------------------------------------------------------
Crystal Reports &#45; New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty&#45;free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to