public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Eryu Guan <eguan@redhat.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>, Xiong Zhou <xzhou@redhat.com>,
	linux-unionfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH v4 4/4] t_immutable: add ftruncate to append only tests
Date: Fri,  7 Apr 2017 12:15:39 +0300	[thread overview]
Message-ID: <1491556539-17147-1-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1491457434-7359-3-git-send-email-amir73il@gmail.com>

The truncate and ftruncate syscalls check the IS_APPEND() flag
in 2 different vfs code paths and I had to fix both in order to
fix overlayfs IS_APPEND() violations.

Add the ftruncate test to t_immutable, so overlay/030 can verify
the fix.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 src/t_immutable.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Eryu,

Added another patch to the series.
It stands by itself regardless of test overlay/030, but
together with overlay/030 they provide full coverage of the
kernel fixes I posted.

Amir.

diff --git a/src/t_immutable.c b/src/t_immutable.c
index 8a12d2c..7a7195e 100644
--- a/src/t_immutable.c
+++ b/src/t_immutable.c
@@ -892,6 +892,21 @@ static int test_append(const char *dir)
      }
 
      errno = 0;
+     if ((fd = open(path, O_RDWR|O_APPEND)) == -1) {
+	  fprintf(stderr, "open(%s, O_RDWR|O_APPEND) failed: %s\n", path, strerror(errno));
+	  fail++;
+     } else {
+	     if (ftruncate(fd, 0) != -1) {
+		     fprintf(stderr, "ftruncate(%s, 0) did not fail\n", path);
+		     fail++;
+	     } else if (errno != EPERM) {
+		     fprintf(stderr, "ftruncate(%s, 0) did not set errno == EPERM\n", path);
+		     fail++;
+	     }
+	     close(fd);
+     }
+
+     errno = 0;
      if (truncate(path, 0) != -1) {
 	  fprintf(stderr, "truncate(%s, 0) did not fail\n", path);
 	  fail++;
-- 
2.7.4


      reply	other threads:[~2017-04-07  9:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-06  5:43 [PATCH v3 1/3] fstests: _require_chattr() must get an input arg Amir Goldstein
2017-04-06  5:43 ` [PATCH v3 2/3] generic/079: use _require_test_program Amir Goldstein
2017-04-06  5:43 ` [PATCH v3 3/3] overlay/030: test immutable and append-only upper files Amir Goldstein
2017-04-07  9:15   ` Amir Goldstein [this message]

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=1491556539-17147-1-git-send-email-amir73il@gmail.com \
    --to=amir73il@gmail.com \
    --cc=eguan@redhat.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=xzhou@redhat.com \
    /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