From: DAN LI <li.dan@cn.fujitsu.com>
To: LTP list <ltp-list@lists.sourceforge.net>
Subject: [LTP] [PATCH 2/2 v2] mount/mount03.c: Test feature MS_NOATIME of mount(2)
Date: Mon, 08 Jul 2013 13:18:48 +0800 [thread overview]
Message-ID: <51DA4BB8.9070703@cn.fujitsu.com> (raw)
In-Reply-To: <51DA4B63.9010700@cn.fujitsu.com>
Additional test for feature MS_NOATIME.
---
testcases/kernel/syscalls/mount/mount03.c | 51 ++++++++++++++++++++++++++++---
1 file changed, 47 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
index a4c065a..d3f0733 100644
--- a/testcases/kernel/syscalls/mount/mount03.c
+++ b/testcases/kernel/syscalls/mount/mount03.c
@@ -27,6 +27,7 @@
* 4) MS_SYNCHRONOUS - writes are synced at once.
* 5) MS_REMOUNT - alter flags of a mounted FS.
* 6) MS_NOSUID - ignore suid and sgid bits.
+ * 7) MS_NOATIME - do not update access times.
*/
#ifndef _GNU_SOURCE
@@ -53,7 +54,7 @@ static void cleanup(void);
static int test_rwflag(int, int);
char *TCID = "mount03";
-int TST_TOTAL = 6;
+int TST_TOTAL = 7;
#define DEFAULT_FSTYPE "ext2"
#define TEMP_FILE "temp_file"
@@ -83,6 +84,7 @@ long rwflags[] = {
MS_SYNCHRONOUS,
MS_RDONLY,
MS_NOSUID,
+ MS_NOATIME,
};
static option_t options[] = {
@@ -161,8 +163,9 @@ int test_rwflag(int i, int cnt)
{
int ret, fd, pid, status;
char nobody_uid[] = "nobody";
+ time_t atime;
struct passwd *ltpuser;
- struct stat setuid_test_stat;
+ struct stat file_stat;
switch (i) {
case 0:
@@ -294,10 +297,10 @@ int test_rwflag(int i, int cnt)
snprintf(file, PATH_MAX, "%ssetuid_test", path_name);
SAFE_FILE_PRINTF(cleanup, file, "TEST FILE");
- if (stat(file, &setuid_test_stat) < 0)
+ if (stat(file, &file_stat) < 0)
tst_brkm(TBROK, cleanup, "stat for setuid_test failed");
- if (setuid_test_stat.st_mode != SUID_MODE &&
+ if (file_stat.st_mode != SUID_MODE &&
chmod(file, SUID_MODE) < 0)
tst_brkm(TBROK, cleanup,
"setuid for setuid_test failed");
@@ -326,6 +329,46 @@ int test_rwflag(int i, int cnt)
return 1;
}
}
+ case 6:
+ /* Validate MS_NOATIME flag of mount call */
+
+ snprintf(file, PATH_MAX, "%satime", path_name);
+ fd = open(file, O_CREAT | O_RDWR, S_IRWXU);
+ if (fd == -1) {
+ tst_resm(TWARN | TERRNO, "opening %s failed", file);
+ return 1;
+ }
+
+ if (write(fd, "TEST_MS_NOATIME", 15) != 15) {
+ tst_resm(TWARN | TERRNO, "write %s failed", file);
+ return 1;
+ }
+
+ if (fstat(fd, &file_stat) == -1) {
+ tst_resm(TWARN | TERRNO, "stat %s failed #1", file);
+ return 1;
+ }
+
+ atime = file_stat.st_atime;
+
+ sleep(1);
+
+ if (read(fd, NULL, 20) == -1) {
+ tst_resm(TWARN | TERRNO, "read %s failed", file);
+ return 1;
+ }
+
+ if (fstat(fd, &file_stat) == -1) {
+ tst_resm(TWARN | TERRNO, "stat %s failed #2", file);
+ return 1;
+ }
+ close(fd);
+
+ if (file_stat.st_atime != atime) {
+ tst_resm(TWARN, "access time is updated");
+ return 1;
+ }
+ return 0;
}
return 0;
}
--
1.8.1
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2013-07-08 5:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-08 5:17 [LTP] [PATCH 1/2 v2] mount/mount03.c: clean up DAN LI
2013-07-08 5:18 ` DAN LI [this message]
2013-07-10 2:10 ` Wanlong Gao
-- strict thread matches above, loose matches on Subject: below --
2013-07-02 6:21 [LTP] [PATCH 1/2] " DAN LI
2013-07-02 6:35 ` [LTP] [PATCH 2/2 v2] mount/mount03.c: Test feature MS_NOATIME of mount(2) DAN LI
2013-07-09 14:57 ` chrubis
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=51DA4BB8.9070703@cn.fujitsu.com \
--to=li.dan@cn.fujitsu.com \
--cc=ltp-list@lists.sourceforge.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.