Hi,

The attached patch tries to cleanup the `mandatory locking' check in
the ftruncate04.c testcase.

The currently test is made with system(2) and involve calling some
external tools ... to determine if the underlying filesystem has
`mand' option set. The same result can be easily retrieved with a
simple statvfs(2) call and examining the mount flags value.

This has been successfully tested on a RHEL5 x86_64 machine.

Signed-off-by: Nicolas Joly <[email protected]>

Regards.

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.
diff --git a/testcases/kernel/syscalls/ftruncate/ftruncate04.c 
b/testcases/kernel/syscalls/ftruncate/ftruncate04.c
index 324a654..fa1daea 100644
--- a/testcases/kernel/syscalls/ftruncate/ftruncate04.c
+++ b/testcases/kernel/syscalls/ftruncate/ftruncate04.c
@@ -66,6 +66,8 @@
 #include <inttypes.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/mount.h>
+#include <sys/statvfs.h>
 #include "test.h"
 #include "usctest.h"
 #include "libtestsuite.h"
@@ -285,6 +287,7 @@ int main(int ac, char **av)
        struct sigaction act;
        int lc;                 /* loop counter */
        char *msg;              /* message returned from parse_opts */
+       struct statvfs fs;
 
        /*
         * parse standard options
@@ -300,9 +303,12 @@ int main(int ac, char **av)
 
        local_flag = PASSED;
        tst_tmpdir();
-       if (system
-           ("mount | grep `df . | grep ^/ | awk {'print $1'}` | grep mand 
>/dev/null")
-           != 0) {
+       if (statvfs(".", &fs) == -1) {
+               tst_resm(TFAIL|TERRNO, "statvfs failed");
+               tst_rmdir();
+               tst_exit();
+       }
+       if ((fs.f_flag & MS_MANDLOCK) == 0) {
                tst_resm(TCONF,
                         "The filesystem where /tmp is mounted does"
                         " not support mandatory locks. Cannot run this test.");
------------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to