public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] src/t_immutable: allow EPERM on immutable inode
@ 2016-08-09 11:16 Eryu Guan
  2016-08-11 17:45 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Eryu Guan @ 2016-08-09 11:16 UTC (permalink / raw)
  To: fstests; +Cc: Eryu Guan

Starting from kernel commit 337684a1746f ("fs: return EPERM on
immutable inode"), EPERM is returned instead of EACCES. Update
src/t_immutable.c to accept EPERM as a PASS.

Signed-off-by: Eryu Guan <eguan@redhat.com>
---
 src/t_immutable.c | 108 +++++++++++++++++++++++++++---------------------------
 1 file changed, 54 insertions(+), 54 deletions(-)

diff --git a/src/t_immutable.c b/src/t_immutable.c
index 7fd9e5d..8a12d2c 100644
--- a/src/t_immutable.c
+++ b/src/t_immutable.c
@@ -165,8 +165,8 @@ static int test_immutable(const char *dir)
 	  fprintf(stderr, "open(%s, O_RDWR) did not fail\n", path);
 	  fail++;
 	  close(fd);
-     } else if (errno != EACCES) {
-	  fprintf(stderr, "open(%s, O_RDWR) did not set errno == EACCES\n", path);
+     } else if (errno != EACCES && errno != EPERM) {
+	  fprintf(stderr, "open(%s, O_RDWR) did not set errno == EACCES or EPERM\n", path);
 	  fail++;
      }
 
@@ -175,8 +175,8 @@ static int test_immutable(const char *dir)
 	  fprintf(stderr, "open(%s, O_WRONLY) did not fail\n", path);
 	  fail++;
 	  close(fd);
-     } else if (errno != EACCES) {
-          fprintf(stderr, "open(%s, O_WRONLY) did not set errno == EACCES\n", path);
+     } else if (errno != EACCES && errno != EPERM) {
+          fprintf(stderr, "open(%s, O_WRONLY) did not set errno == EACCES or EPERM\n", path);
           fail++;
      }
 
@@ -185,8 +185,8 @@ static int test_immutable(const char *dir)
           fprintf(stderr, "open(%s, O_RDWR|O_TRUNC) did not fail\n", path);
           fail++;
           close(fd);
-     } else if (errno != EACCES) {
-          fprintf(stderr, "open(%s, O_RDWR|O_TRUNC) did not set errno == EACCES\n", path);
+     } else if (errno != EACCES && errno != EPERM) {
+          fprintf(stderr, "open(%s, O_RDWR|O_TRUNC) did not set errno == EACCES or EPERM\n", path);
           fail++;
      }
 
@@ -195,8 +195,8 @@ static int test_immutable(const char *dir)
           fprintf(stderr, "open(%s, O_WRONLY|O_TRUNC) did not fail\n", path);
           fail++;
           close(fd);
-     } else if (errno != EACCES) {
-          fprintf(stderr, "open(%s, O_WRONLY|O_TRUNC did not set errno == EACCES\n", path);
+     } else if (errno != EACCES && errno != EPERM) {
+          fprintf(stderr, "open(%s, O_WRONLY|O_TRUNC did not set errno == EACCES or EPERM\n", path);
           fail++;
      }
 
@@ -205,8 +205,8 @@ static int test_immutable(const char *dir)
           fprintf(stderr, "open(%s, O_RDWR|O_APPEND) did not fail\n", path);
           fail++;
           close(fd);
-     } else if (errno != EACCES) {
-          fprintf(stderr, "open(%s, O_RDWR|O_APPEND) did not set errno == EACCES\n", path);
+     } else if (errno != EACCES && errno != EPERM) {
+          fprintf(stderr, "open(%s, O_RDWR|O_APPEND) did not set errno == EACCES or EPERM\n", path);
           fail++;
      }
 
@@ -215,8 +215,8 @@ static int test_immutable(const char *dir)
           fprintf(stderr, "open(%s, O_WRONLY|O_APPEND) did not fail\n", path);
           fail++;
           close(fd);
-     } else if (errno != EACCES) {
-          fprintf(stderr, "open(%s, O_WRONLY|O_APPEND) did not set errno == EACCES\n", path);
+     } else if (errno != EACCES && errno != EPERM) {
+          fprintf(stderr, "open(%s, O_WRONLY|O_APPEND) did not set errno == EACCES or EPERM\n", path);
           fail++;
      }
 
@@ -225,8 +225,8 @@ static int test_immutable(const char *dir)
           fprintf(stderr, "open(%s, O_RDWR|O_APPEND|O_TRUNC) did not fail\n", path);
           fail++;
           close(fd);
-     } else if (errno != EACCES) {
-          fprintf(stderr, "open(%s, O_RDWR|O_APPEND|O_TRUNC) did not set errno == EACCES\n", path);
+     } else if (errno != EACCES && errno != EPERM) {
+          fprintf(stderr, "open(%s, O_RDWR|O_APPEND|O_TRUNC) did not set errno == EACCES or EPERM\n", path);
           fail++;
      }
 
@@ -235,8 +235,8 @@ static int test_immutable(const char *dir)
           fprintf(stderr, "open(%s, O_WRONLY|O_APPEND|O_TRUNC) did not fail\n", path);
           fail++;
           close(fd);
-     } else if (errno != EACCES) {
-          fprintf(stderr, "open(%s, O_WRONLY|O_APPEND|O_TRUNC) did not set errno == EACCES\n", path);
+     } else if (errno != EACCES && errno != EPERM) {
+          fprintf(stderr, "open(%s, O_WRONLY|O_APPEND|O_TRUNC) did not set errno == EACCES or EPERM\n", path);
           fail++;
      }
 
@@ -283,9 +283,9 @@ static int test_immutable(const char *dir)
 	       fprintf(stderr, "jdm_open(%s, O_RDWR) did not fail\n", path);
 	       fail++;
 	       close(fd);
-	  } else if (errno != EACCES) {
+	  } else if (errno != EACCES && errno != EPERM) {
 	       perror("jdm_open");
-	       fprintf(stderr, "jdm_open(%s, O_RDWR) did not set errno == EACCES\n", path);
+	       fprintf(stderr, "jdm_open(%s, O_RDWR) did not set errno == EACCES or EPERM\n", path);
 	       fail++;
 	  }
 
@@ -294,8 +294,8 @@ static int test_immutable(const char *dir)
 	       fprintf(stderr, "jdm_open(%s, O_WRONLY) did not fail\n", path);
 	       fail++;
 	       close(fd);
-	  } else if (errno != EACCES) {
-	       fprintf(stderr, "jdm_open(%s, O_WRONLY) did not set errno == EACCES\n", path);
+	  } else if (errno != EACCES && errno != EPERM) {
+	       fprintf(stderr, "jdm_open(%s, O_WRONLY) did not set errno == EACCES or EPERM\n", path);
 	       fail++;
 	  }
 
@@ -304,8 +304,8 @@ static int test_immutable(const char *dir)
 	       fprintf(stderr, "jdm_open(%s, O_RDWR|O_TRUNC) did not fail\n", path);
 	       fail++;
 	       close(fd);
-	  } else if (errno != EACCES) {
-	       fprintf(stderr, "jdm_open(%s, O_RDWR|O_TRUNC) did not set errno == EACCES\n", path);
+	  } else if (errno != EACCES && errno != EPERM) {
+	       fprintf(stderr, "jdm_open(%s, O_RDWR|O_TRUNC) did not set errno == EACCES or EPERM\n", path);
 	       fail++;
 	  }
 
@@ -314,8 +314,8 @@ static int test_immutable(const char *dir)
 	       fprintf(stderr, "jdm_open(%s, O_WRONLY|O_TRUNC) did not fail\n", path);
 	       fail++;
 	       close(fd);
-	  } else if (errno != EACCES) {
-	       fprintf(stderr, "jdm_open(%s, O_WRONLY|O_TRUNC did not set errno == EACCES\n", path);
+	  } else if (errno != EACCES && errno != EPERM) {
+	       fprintf(stderr, "jdm_open(%s, O_WRONLY|O_TRUNC did not set errno == EACCES or EPERM\n", path);
 	       fail++;
 	  }
 
@@ -324,8 +324,8 @@ static int test_immutable(const char *dir)
 	       fprintf(stderr, "jdm_open(%s, O_RDWR|O_APPEND) did not fail\n", path);
 	       fail++;
 	       close(fd);
-	  } else if (errno != EACCES) {
-	       fprintf(stderr, "jdm_open(%s, O_RDWR|O_APPEND) did not set errno == EACCES\n", path);
+	  } else if (errno != EACCES && errno != EPERM) {
+	       fprintf(stderr, "jdm_open(%s, O_RDWR|O_APPEND) did not set errno == EACCES or EPERM\n", path);
 	       fail++;
 	  }
 
@@ -334,8 +334,8 @@ static int test_immutable(const char *dir)
 	       fprintf(stderr, "jdm_open(%s, O_WRONLY|O_APPEND) did not fail\n", path);
 	       fail++;
 	       close(fd);
-	  } else if (errno != EACCES) {
-	       fprintf(stderr, "jdm_open(%s, O_WRONLY|O_APPEND) did not set errno == EACCES\n", path);
+	  } else if (errno != EACCES && errno != EPERM) {
+	       fprintf(stderr, "jdm_open(%s, O_WRONLY|O_APPEND) did not set errno == EACCES or EPERM\n", path);
 	       fail++;
 	  }
 
@@ -344,8 +344,8 @@ static int test_immutable(const char *dir)
 	       fprintf(stderr, "jdm_open(%s, O_RDWR|O_APPEND|O_TRUNC) did not fail\n", path);
 	       fail++;
 	       close(fd);
-	  } else if (errno != EACCES) {
-	       fprintf(stderr, "jdm_open(%s, O_RDWR|O_APPEND|O_TRUNC) did not set errno == EACCES\n", path);
+	  } else if (errno != EACCES && errno != EPERM) {
+	       fprintf(stderr, "jdm_open(%s, O_RDWR|O_APPEND|O_TRUNC) did not set errno == EACCES or EPERM\n", path);
 	       fail++;
 	  }
 
@@ -354,8 +354,8 @@ static int test_immutable(const char *dir)
 	       fprintf(stderr, "jdm_open(%s, O_WRONLY|O_APPEND|O_TRUNC) did not fail\n", path);
 	       fail++;
 	       close(fd);
-	  } else if (errno != EACCES) {
-	       fprintf(stderr, "jdm_open(%s, O_WRONLY|O_APPEND|O_TRUNC) did not set errno == EACCES\n", path);
+	  } else if (errno != EACCES && errno != EPERM) {
+	       fprintf(stderr, "jdm_open(%s, O_WRONLY|O_APPEND|O_TRUNC) did not set errno == EACCES or EPERM\n", path);
 	       fail++;
 	  }
      }
@@ -364,8 +364,8 @@ static int test_immutable(const char *dir)
      if (truncate(path, 0) != -1) {
 	  fprintf(stderr, "truncate(%s, 0) did not fail\n", path);
 	  fail++;
-     } else if (errno != EACCES) {
-	  fprintf(stderr, "truncate(%s, 0) did not set errno == EACCES\n", path);
+     } else if (errno != EACCES && errno != EPERM) {
+	  fprintf(stderr, "truncate(%s, 0) did not set errno == EACCES or EPERM\n", path);
 	  fail++;
      }
 
@@ -383,8 +383,8 @@ static int test_immutable(const char *dir)
      if (utime(path, NULL) != -1) {
           fprintf(stderr, "utime(%s, NULL) did not fail\n", path);
           fail++;
-     } else if (errno != EACCES) {
-          fprintf(stderr, "utime(%s, NULL) did not set errno == EACCES\n", path);
+     } else if (errno != EACCES && errno != EPERM) {
+          fprintf(stderr, "utime(%s, NULL) did not set errno == EACCES or EPERM\n", path);
           fail++;
      }
 #endif /* TEST_UTIME */
@@ -570,16 +570,16 @@ static int test_immutable(const char *dir)
 	  fprintf(stderr, "link(%s, %s) did not fail\n", path, linkpath);
 	  fail++;
 	  unlink(linkpath);
-     } else if (errno != EACCES) {
-	  fprintf(stderr, "link(%s, %s) did not set errno == EACCES\n", path, linkpath);
+     } else if (errno != EACCES && errno != EPERM) {
+	  fprintf(stderr, "link(%s, %s) did not set errno == EACCES or EPERM\n", path, linkpath);
 	  fail++;
      }
      if (symlink(path, linkpath) != -1) {
 	  fprintf(stderr, "symlink(%s, %s) did not fail\n", path, linkpath);
 	  fail++;
 	  unlink(linkpath);
-     } else if (errno != EACCES) {
-	  fprintf(stderr, "symlink(%s, %s) did not set errno == EACCES\n", path, linkpath);
+     } else if (errno != EACCES && errno != EPERM) {
+	  fprintf(stderr, "symlink(%s, %s) did not set errno == EACCES or EPERM\n", path, linkpath);
           fail++;
      }
      free(linkpath);
@@ -588,8 +588,8 @@ static int test_immutable(const char *dir)
 	  fprintf(stderr, "rename(%s, %s) did not fail\n", path, linkpath);
 	  fail++;
 	  rename(linkpath, path);
-     } else if (errno != EACCES) {
-	  fprintf(stderr, "rename(%s, %s) did not set errno == EACCES\n", path, linkpath);
+     } else if (errno != EACCES && errno != EPERM) {
+	  fprintf(stderr, "rename(%s, %s) did not set errno == EACCES or EPERM\n", path, linkpath);
           fail++;
      }
      free(linkpath);
@@ -597,8 +597,8 @@ static int test_immutable(const char *dir)
      if (unlink(path) != -1) {
 	  fprintf(stderr, "unlink(%s) did not fail\n", path);
 	  fail++;
-     } else if (errno != EACCES) {
-	  fprintf(stderr, "unlink(%s) did not set errno == EACCES\n", path);
+     } else if (errno != EACCES && errno != EPERM) {
+	  fprintf(stderr, "unlink(%s) did not set errno == EACCES or EPERM\n", path);
           fail++;
      }
 
@@ -609,8 +609,8 @@ static int test_immutable(const char *dir)
 	  fprintf(stderr, "open(%s, O_RDWR|O_CREAT, 0666) did not fail\n", path);
 	  fail++;
 	  unlink(path);
-     } else if (errno != EACCES) {
-	  fprintf(stderr, "open(%s, O_RDWR|O_CREAT, 0666) did not set errno == EACCES\n", path);
+     } else if (errno != EACCES && errno != EPERM) {
+	  fprintf(stderr, "open(%s, O_RDWR|O_CREAT, 0666) did not set errno == EACCES or EPERM\n", path);
 	  fail++;
      }
      if (!getuid()) {
@@ -619,8 +619,8 @@ static int test_immutable(const char *dir)
 		    fprintf(stderr, "mknod(%s, S_IFCHR|0666, %lld) did not fail\n", path, (long long int)st.st_rdev);
 		    fail++;
 		    unlink(path);
-	       } else if (errno != EACCES) {
-		    fprintf(stderr, "mknod(%s, S_IFCHR|0666, %lld) did not set errno == EACCESS\n", path, (long long int)st.st_rdev);
+	       } else if (errno != EACCES && errno != EPERM) {
+		    fprintf(stderr, "mknod(%s, S_IFCHR|0666, %lld) did not set errno == EACCES or EPERM\n", path, (long long int)st.st_rdev);
 		    fail++;
 	       }
 	  }
@@ -633,8 +633,8 @@ static int test_immutable(const char *dir)
 	  fprintf(stderr, "mkdir(%s, 0777) did not fail\n", path);
 	  fail++;
 	  rmdir(path);
-     } else if (errno != EACCES) {
-	  fprintf(stderr, "mkdir(%s, 0777) did not set errno == EACCES\n", path);
+     } else if (errno != EACCES && errno != EPERM) {
+	  fprintf(stderr, "mkdir(%s, 0777) did not set errno == EACCES or EPERM\n", path);
           fail++;
      }
 
@@ -670,8 +670,8 @@ static int test_immutable(const char *dir)
      if (rmdir(path) != -1) {
 	  fprintf(stderr, "rmdir(%s) did not fail\n", path);
 	  fail++;
-     } else if (errno != EACCES) {
-	  fprintf(stderr, "rmdir(%s) did not set errno == EACCES\n", path);
+     } else if (errno != EACCES && errno != EPERM) {
+	  fprintf(stderr, "rmdir(%s) did not set errno == EACCES or EPERM\n", path);
 	  fail++;
      }
 
@@ -692,8 +692,8 @@ static int test_immutable(const char *dir)
      if (utime(path, NULL) != -1) {
           fprintf(stderr, "utime(%s, NULL) did not fail\n", path);
           fail++;
-     } else if (errno != EACCES) {
-          fprintf(stderr, "utime(%s, NULL) did not set errno == EACCES\n", path);
+     } else if (errno != EACCES && errno != EPERM) {
+          fprintf(stderr, "utime(%s, NULL) did not set errno == EACCES or EPERM\n", path);
           fail++;
      }
 #endif /* TEST_UTIME */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] src/t_immutable: allow EPERM on immutable inode
  2016-08-09 11:16 [PATCH] src/t_immutable: allow EPERM on immutable inode Eryu Guan
@ 2016-08-11 17:45 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2016-08-11 17:45 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests

On Tue, Aug 09, 2016 at 07:16:48PM +0800, Eryu Guan wrote:
> Starting from kernel commit 337684a1746f ("fs: return EPERM on
> immutable inode"), EPERM is returned instead of EACCES. Update
> src/t_immutable.c to accept EPERM as a PASS.
> 
> Signed-off-by: Eryu Guan <eguan@redhat.com>

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-11 17:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-09 11:16 [PATCH] src/t_immutable: allow EPERM on immutable inode Eryu Guan
2016-08-11 17:45 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox