public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Nicolas Joly <njoly@pasteur.fr>
To: LTP list <ltp-list@lists.sf.net>
Subject: [LTP] ftruncate04.c: cleanup mandatory locking check
Date: Wed, 12 May 2010 15:14:26 +0200	[thread overview]
Message-ID: <20100512131426.GA190127@medusa.sis.pasteur.fr> (raw)

[-- Attachment #1: Type: text/plain, Size: 561 bytes --]


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 <njoly@pasteur.fr>

Regards.

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.

[-- Attachment #2: ltp-ftruncate04.diff --]
[-- Type: text/plain, Size: 1156 bytes --]

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.");

[-- Attachment #3: Type: text/plain, Size: 80 bytes --]

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


[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

             reply	other threads:[~2010-05-12 13:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-12 13:14 Nicolas Joly [this message]
2010-05-12 17:23 ` [LTP] ftruncate04.c: cleanup mandatory locking check Subrata Modak
2010-05-17 20:06 ` Subrata Modak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100512131426.GA190127@medusa.sis.pasteur.fr \
    --to=njoly@pasteur.fr \
    --cc=ltp-list@lists.sf.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox