Skip to contentSkip to conversation

ftruncate04.c: cleanup mandatory locking check

LTP Nicolas Joly 2 participants 3 messages May 12, 2010 – May 17, 2010

lore
Share & tools
lore
#0 lore raw

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.

Regards.

Signature · 4 lines
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.
testcases/kernel/syscalls/ftruncate/ftruncate04.c +9 -3
index 324a654..fa1daea 100644
@@ -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

#1 lore raw
Quoted 5 lines · Nicolas Joly

Hi,

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

Quoted 8 lines

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.

Thanks. This does not introduce any regression. Will wait for others comments as well.

Regards--
Subrata

Quoted 9 lines

Regards.

------------------------------------------------------------------------------

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

------------------------------------------------------------------------------

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

#2 lore raw
In reply to Nicolas Joly
Quoted 5 lines · Nicolas Joly

Hi,

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

Quoted 8 lines

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.

Thanks.

Regards--
Subrata

Quoted 9 lines

Regards.

------------------------------------------------------------------------------

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

------------------------------------------------------------------------------

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