<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 24, 2022 at 7:42 PM Avinesh Kumar <<a href="mailto:akumar@suse.de">akumar@suse.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Also I've removed the TINFO statements, I'm not sure if only<br>
printing the data in logs is helpful in anyway.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Removing the printing is OK, but I am just wondering that</div><div class="gmail_default" style="font-size:small">can we find a way to check if the returned value in 'buf' is</div><div class="gmail_default" style="font-size:small">indeed correct?</div><br></div><div><div class="gmail_default" style="font-size:small">As you can see the ‘struct statvfs‘ includes many fs key</div><div class="gmail_default" style="font-size:small">values that we need to trust when using them.</div></div><div><br></div><div><div class="gmail_default" style="font-size:small">struct statvfs {</div><span class="gmail_default" style="font-size:small">        </span>unsigned long  f_bsize;    /* Filesystem block size */<br><span class="gmail_default" style="font-size:small"></span>        unsigned long  f_frsize;   /* Fragment size */<br><span class="gmail_default" style="font-size:small"></span>        fsblkcnt_t     f_blocks;   /* Size of fs in f_frsize units */<br><span class="gmail_default" style="font-size:small"></span>        fsblkcnt_t     f_bfree;    /* Number of free blocks */<br><span class="gmail_default" style="font-size:small"></span>        fsblkcnt_t     f_bavail;   /* Number of free blocks for<br>                                             unprivileged users */<br><span class="gmail_default" style="font-size:small"></span>        fsfilcnt_t     f_files;    /* Number of inodes */<br><span class="gmail_default" style="font-size:small"></span>        fsfilcnt_t     f_ffree;    /* Number of free inodes */<br><span class="gmail_default" style="font-size:small"></span>        fsfilcnt_t     f_favail;   /* Number of free inodes for<br>                                             unprivileged users */<br><span class="gmail_default" style="font-size:small"></span>        unsigned long  f_fsid;     /* Filesystem ID */<br><span class="gmail_default" style="font-size:small"></span>        unsigned long  f_flag;     /* Mount flags */<br><span class="gmail_default" style="font-size:small"></span>        unsigned long  f_namemax;  /* Maximum filename length */<br> };<br><div class="gmail_default" style="font-size:small"></div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Signed-off-by: Avinesh Kumar <<a href="mailto:akumar@suse.de" target="_blank">akumar@suse.de</a>><br>
---<br>
 testcases/kernel/syscalls/statvfs/statvfs01.c | 96 +++++--------------<br>
 1 file changed, 22 insertions(+), 74 deletions(-)<br>
<br>
diff --git a/testcases/kernel/syscalls/statvfs/statvfs01.c b/testcases/kernel/syscalls/statvfs/statvfs01.c<br>
index e3b356c93..89ca4e960 100644<br>
--- a/testcases/kernel/syscalls/statvfs/statvfs01.c<br>
+++ b/testcases/kernel/syscalls/statvfs/statvfs01.c<br>
@@ -1,92 +1,40 @@<br>
+// SPDX-License-Identifier: GPL-2.0<br>
 /*<br>
  * Copyright (c) Wipro Technologies Ltd, 2005.  All Rights Reserved.<br>
  *    AUTHOR: Prashant P Yendigeri <<a href="mailto:prashant.yendigeri@wipro.com" target="_blank">prashant.yendigeri@wipro.com</a>><br>
- *<br>
- * This program is free software; you can redistribute it and/or modify it<br>
- * under the terms of version 2 of the GNU General Public License as<br>
- * published by the Free Software Foundation.<br>
- *<br>
- * This program is distributed in the hope that it would be useful, but<br>
- * WITHOUT ANY WARRANTY; without even the implied warranty of<br>
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br>
- *<br>
- * You should have received a copy of the GNU General Public License along<br>
- * with this program; if not, write the Free Software Foundation, Inc.,<br>
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.<br>
- *<br>
+ * Copyright (c) 2022 SUSE LLC Avinesh Kumar <<a href="mailto:avinesh.kumar@suse.com" target="_blank">avinesh.kumar@suse.com</a>><br>
  */<br>
-/*<br>
- *    DESCRIPTION<br>
- *      This is a Phase I test for the statvfs(2) system call.<br>
- *      It is intended to provide a limited exposure of the system call.<br>
- *     This call behaves similar to statfs.<br>
+<br>
+/*\<br>
+ * [Description]<br>
+ *<br>
+ * Verify that statvfs() executes successfully for all<br>
+ * available filesystems.<br>
  */<br>
<br>
-#include <stdio.h><br>
-#include <unistd.h><br>
-#include <errno.h><br>
 #include <sys/statvfs.h><br>
-#include <stdint.h><br>
-<br>
-#include "test.h"<br>
-<br>
-#define TEST_PATH "/"<br>
+#include "tst_test.h"<br>
<br>
-static void setup(void);<br>
-static void cleanup(void);<br>
+#define MNT_POINT "mntpoint"<br>
+#define TEST_PATH MNT_POINT"/testfile"<br>
<br>
-char *TCID = "statvfs01";<br>
-int TST_TOTAL = 1;<br>
-<br>
-int main(int ac, char **av)<br>
+static void run(void)<br>
 {<br>
        struct statvfs buf;<br>
-       int lc;<br>
-<br>
-       tst_parse_opts(ac, av, NULL, NULL);<br>
<br>
-       setup();<br>
-<br>
-       for (lc = 0; TEST_LOOPING(lc); lc++) {<br>
-<br>
-               tst_count = 0;<br>
-<br>
-               TEST(statvfs(TEST_PATH, &buf));<br>
-<br>
-               if (TEST_RETURN == -1) {<br>
-                       tst_resm(TFAIL | TTERRNO, "statvfs(%s, ...) failed",<br>
-                                TEST_PATH);<br>
-               } else {<br>
-                       tst_resm(TPASS, "statvfs(%s, ...) passed", TEST_PATH);<br>
-               }<br>
-<br>
-       }<br>
-<br>
-       tst_resm(TINFO, "This call is similar to statfs");<br>
-       tst_resm(TINFO, "Extracting info about the '%s' file system",<br>
-                TEST_PATH);<br>
-       tst_resm(TINFO, "file system block size = %lu bytes", buf.f_bsize);<br>
-       tst_resm(TINFO, "file system fragment size = %lu bytes", buf.f_frsize);<br>
-       tst_resm(TINFO, "file system free blocks = %ju",<br>
-                (uintmax_t) buf.f_bfree);<br>
-       tst_resm(TINFO, "file system total inodes = %ju",<br>
-                (uintmax_t) buf.f_files);<br>
-       tst_resm(TINFO, "file system free inodes = %ju",<br>
-                (uintmax_t) buf.f_ffree);<br>
-       tst_resm(TINFO, "file system id = %lu", buf.f_fsid);<br>
-       tst_resm(TINFO, "file system max filename length = %lu", buf.f_namemax);<br>
-<br>
-       cleanup();<br>
-       tst_exit();<br>
+       TST_EXP_PASS(statvfs(TEST_PATH, &buf));<br>
 }<br>
<br>
 static void setup(void)<br>
 {<br>
-       tst_sig(NOFORK, DEF_HANDLER, cleanup);<br>
-<br>
-       TEST_PAUSE;<br>
+       SAFE_TOUCH(TEST_PATH, 0666, NULL);<br>
 }<br>
<br>
-static void cleanup(void)<br>
-{<br>
-}<br>
+static struct tst_test test = {<br>
+       .test_all = run,<br>
+       .setup = setup,<br>
+       .needs_root = 1,<br>
+       .mount_device = 1,<br>
+       .mntpoint = MNT_POINT,<br>
+       .all_filesystems = 1<br>
+};<br>
-- <br>
2.38.1<br>
<br>
<br>
-- <br>
Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/listinfo/ltp</a><br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>