All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Behrens <sbehrens@giantdisaster.de>
To: linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org,
	xfs@oss.sgi.com
Subject: [PATCH v2 4/4] xfstests: Changed test 079 to be generic for all filesystems
Date: Fri, 29 Jul 2011 18:07:01 +0200	[thread overview]
Message-ID: <d63d92aa14e5fa81b4a40d0903001e70f7da9249.1311953979.git.sbehrens@giantdisaster.de> (raw)
In-Reply-To: <cover.1311953979.git.sbehrens@giantdisaster.de>
In-Reply-To: <cover.1311953979.git.sbehrens@giantdisaster.de>

Changed the test 079 to be generic for all filesystems and to be
executed for all filesystems.
In src/t_immutable.c which is compiled for Linux only, replaced the
old style XFS and ext2 specific code for setting the append-only and
immutable flags by generic code that makes use of the
ioctl(FS_IOC_SETFLAGS) and ioctl(FS_IOC_GETFLAGS).
Therefore the check for the specific filesystem type was removed.
FS_IOC_GETFLAGS/FS_IOC_SETFLAGS is always used. This code is inside an
'#ifdef FS_IOC_SETFLAGS' block in order to never fail compilation.
Without support for FS_IOC_SETFLAGS, the test completes with _notrun.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
---
 079               |   13 ++++++++--
 src/t_immutable.c |   66 +++++++++++++++++-----------------------------------
 2 files changed, 32 insertions(+), 47 deletions(-)

diff --git a/079 b/079
index 6c43fe7..0c70811 100755
--- a/079
+++ b/079
@@ -46,7 +46,7 @@ _cleanup()
 . ./common.filter
 . ./common.attr
 
-_supported_fs xfs
+_supported_fs generic
 _supported_os Linux
 
 _require_attrs
@@ -55,10 +55,17 @@ _require_scratch
 [ -x $timmutable ] || _notrun "t_immutable was not built for this platform"
 
 # real QA test starts here
-_scratch_mkfs_xfs 2>&1 >/dev/null || _fail "mkfs failed"
+_scratch_mkfs >/dev/null 2>&1 || _fail "mkfs failed"
 _scratch_mount || _fail "mount failed"
 
 echo "*** starting up"
-$timmutable -c $SCRATCH_MNT/$seq
+$timmutable -c $SCRATCH_MNT/$seq >$tmp.out 2>&1
+if grep -q 'Operation not supported' $tmp.out
+then
+    rm -f $tmp.out
+    _notrun "Setting immutable/append flag not supported"
+fi
+cat $tmp.out
+rm -f $tmp.out
 status=$?
 exit
diff --git a/src/t_immutable.c b/src/t_immutable.c
index 7bb3154..87ffc75 100644
--- a/src/t_immutable.c
+++ b/src/t_immutable.c
@@ -41,11 +41,8 @@
 #include <xfs/xfs.h>
 #include <xfs/handle.h>
 #include <xfs/jdm.h>
-
-#define EXT2_SUPER_MAGIC	0xEF53
-#define EXT2_IMMUTABLE_FL       0x00000010
-#define EXT2_APPEND_FL          0x00000020
-#define EXT2_IOC_SETFLAGS	_IOW('f', 2, long)
+#include <linux/fs.h>
+#include <linux/magic.h>
 
 #ifndef XFS_SUPER_MAGIC
 #define XFS_SUPER_MAGIC 0x58465342
@@ -55,52 +52,33 @@ extern const char *__progname;
 
 static int fsetflag(const char *path, int fd, int on, int immutable)
 {
-     int e2flags = 0;
-     struct fsxattr attr;
-     struct statfs stfs;
-     int xfsfl;
-     int e2fl;
-
-     if (immutable) {
-	  xfsfl = XFS_XFLAG_IMMUTABLE;
-	  e2fl = EXT2_IMMUTABLE_FL;
-     } else {
-	  xfsfl = XFS_XFLAG_APPEND;
-	  e2fl = EXT2_APPEND_FL;
-     }
+#ifdef FS_IOC_SETFLAGS
+     int fsflags = 0;
+     int fsfl;
 
-     if (fstatfs(fd, &stfs) != 0)
+     if (ioctl(fd, FS_IOC_GETFLAGS, &fsflags) < 0) {
+	  close(fd);
 	  return 1;
-
-     if (stfs.f_type == XFS_SUPER_MAGIC) {
-	  if (xfsctl(path, fd, XFS_IOC_FSGETXATTR, &attr) < 0) {
-	       close(fd);
-	       return 1;
-	  }
-	  if (on)
-	       attr.fsx_xflags |= xfsfl;
-	  else
-	       attr.fsx_xflags &= ~xfsfl;
-	  if (xfsctl(path, fd, XFS_IOC_FSSETXATTR, &attr) < 0) {
-	       close(fd);
-	       return 1;
-	  }
-     } else if (stfs.f_type == EXT2_SUPER_MAGIC) {
-	  if (on)
-	       e2flags |= e2fl;
-	  else
-	       e2flags &= ~e2fl;
-	  if (ioctl(fd, EXT2_IOC_SETFLAGS, &e2flags) < 0) {
-	       close(fd);
-	       return 1;
-	  }
-     } else {
-	  errno = EOPNOTSUPP;
+     }
+     if (immutable)
+	  fsfl = FS_IMMUTABLE_FL;
+     else
+	  fsfl = FS_APPEND_FL;
+     if (on)
+	  fsflags |= fsfl;
+     else
+	  fsflags &= ~fsfl;
+     if (ioctl(fd, FS_IOC_SETFLAGS, &fsflags) < 0) {
 	  close(fd);
 	  return 1;
      }
      close(fd);
      return 0;
+#else
+     errno = EOPNOTSUPP;
+     close(fd);
+     return 1;
+#endif
 }
 
 static int add_acl(const char *path, const char *acl_text)
-- 
1.7.3.4


WARNING: multiple messages have this Message-ID (diff)
From: Stefan Behrens <sbehrens@giantdisaster.de>
To: linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org,
	xfs@oss.sgi.com
Subject: [PATCH v2 4/4] xfstests: Changed test 079 to be generic for all filesystems
Date: Fri, 29 Jul 2011 18:07:01 +0200	[thread overview]
Message-ID: <d63d92aa14e5fa81b4a40d0903001e70f7da9249.1311953979.git.sbehrens@giantdisaster.de> (raw)
In-Reply-To: <cover.1311953979.git.sbehrens@giantdisaster.de>
In-Reply-To: <cover.1311953979.git.sbehrens@giantdisaster.de>

Changed the test 079 to be generic for all filesystems and to be
executed for all filesystems.
In src/t_immutable.c which is compiled for Linux only, replaced the
old style XFS and ext2 specific code for setting the append-only and
immutable flags by generic code that makes use of the
ioctl(FS_IOC_SETFLAGS) and ioctl(FS_IOC_GETFLAGS).
Therefore the check for the specific filesystem type was removed.
FS_IOC_GETFLAGS/FS_IOC_SETFLAGS is always used. This code is inside an
'#ifdef FS_IOC_SETFLAGS' block in order to never fail compilation.
Without support for FS_IOC_SETFLAGS, the test completes with _notrun.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
---
 079               |   13 ++++++++--
 src/t_immutable.c |   66 +++++++++++++++++-----------------------------------
 2 files changed, 32 insertions(+), 47 deletions(-)

diff --git a/079 b/079
index 6c43fe7..0c70811 100755
--- a/079
+++ b/079
@@ -46,7 +46,7 @@ _cleanup()
 . ./common.filter
 . ./common.attr
 
-_supported_fs xfs
+_supported_fs generic
 _supported_os Linux
 
 _require_attrs
@@ -55,10 +55,17 @@ _require_scratch
 [ -x $timmutable ] || _notrun "t_immutable was not built for this platform"
 
 # real QA test starts here
-_scratch_mkfs_xfs 2>&1 >/dev/null || _fail "mkfs failed"
+_scratch_mkfs >/dev/null 2>&1 || _fail "mkfs failed"
 _scratch_mount || _fail "mount failed"
 
 echo "*** starting up"
-$timmutable -c $SCRATCH_MNT/$seq
+$timmutable -c $SCRATCH_MNT/$seq >$tmp.out 2>&1
+if grep -q 'Operation not supported' $tmp.out
+then
+    rm -f $tmp.out
+    _notrun "Setting immutable/append flag not supported"
+fi
+cat $tmp.out
+rm -f $tmp.out
 status=$?
 exit
diff --git a/src/t_immutable.c b/src/t_immutable.c
index 7bb3154..87ffc75 100644
--- a/src/t_immutable.c
+++ b/src/t_immutable.c
@@ -41,11 +41,8 @@
 #include <xfs/xfs.h>
 #include <xfs/handle.h>
 #include <xfs/jdm.h>
-
-#define EXT2_SUPER_MAGIC	0xEF53
-#define EXT2_IMMUTABLE_FL       0x00000010
-#define EXT2_APPEND_FL          0x00000020
-#define EXT2_IOC_SETFLAGS	_IOW('f', 2, long)
+#include <linux/fs.h>
+#include <linux/magic.h>
 
 #ifndef XFS_SUPER_MAGIC
 #define XFS_SUPER_MAGIC 0x58465342
@@ -55,52 +52,33 @@ extern const char *__progname;
 
 static int fsetflag(const char *path, int fd, int on, int immutable)
 {
-     int e2flags = 0;
-     struct fsxattr attr;
-     struct statfs stfs;
-     int xfsfl;
-     int e2fl;
-
-     if (immutable) {
-	  xfsfl = XFS_XFLAG_IMMUTABLE;
-	  e2fl = EXT2_IMMUTABLE_FL;
-     } else {
-	  xfsfl = XFS_XFLAG_APPEND;
-	  e2fl = EXT2_APPEND_FL;
-     }
+#ifdef FS_IOC_SETFLAGS
+     int fsflags = 0;
+     int fsfl;
 
-     if (fstatfs(fd, &stfs) != 0)
+     if (ioctl(fd, FS_IOC_GETFLAGS, &fsflags) < 0) {
+	  close(fd);
 	  return 1;
-
-     if (stfs.f_type == XFS_SUPER_MAGIC) {
-	  if (xfsctl(path, fd, XFS_IOC_FSGETXATTR, &attr) < 0) {
-	       close(fd);
-	       return 1;
-	  }
-	  if (on)
-	       attr.fsx_xflags |= xfsfl;
-	  else
-	       attr.fsx_xflags &= ~xfsfl;
-	  if (xfsctl(path, fd, XFS_IOC_FSSETXATTR, &attr) < 0) {
-	       close(fd);
-	       return 1;
-	  }
-     } else if (stfs.f_type == EXT2_SUPER_MAGIC) {
-	  if (on)
-	       e2flags |= e2fl;
-	  else
-	       e2flags &= ~e2fl;
-	  if (ioctl(fd, EXT2_IOC_SETFLAGS, &e2flags) < 0) {
-	       close(fd);
-	       return 1;
-	  }
-     } else {
-	  errno = EOPNOTSUPP;
+     }
+     if (immutable)
+	  fsfl = FS_IMMUTABLE_FL;
+     else
+	  fsfl = FS_APPEND_FL;
+     if (on)
+	  fsflags |= fsfl;
+     else
+	  fsflags &= ~fsfl;
+     if (ioctl(fd, FS_IOC_SETFLAGS, &fsflags) < 0) {
 	  close(fd);
 	  return 1;
      }
      close(fd);
      return 0;
+#else
+     errno = EOPNOTSUPP;
+     close(fd);
+     return 1;
+#endif
 }
 
 static int add_acl(const char *path, const char *acl_text)
-- 
1.7.3.4

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2011-07-29 16:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-29 16:06 [PATCH v2 0/4] xfstests: Changed a couple of tests to be generic Stefan Behrens
2011-07-29 16:06 ` Stefan Behrens
2011-07-29 16:06 ` [PATCH v2 1/4] xfstests: Changed test 062 to be generic for all filesystems Stefan Behrens
2011-07-29 16:06   ` Stefan Behrens
2011-07-30 14:25   ` Christoph Hellwig
2011-07-30 14:25     ` Christoph Hellwig
2011-07-29 16:06 ` [PATCH v2 2/4] xfstests: Changed tests 083, 117, 120 and 192 " Stefan Behrens
2011-07-29 16:06   ` Stefan Behrens
2011-07-29 16:07 ` [PATCH v2 3/4] xfstests: Changed test 015 " Stefan Behrens
2011-07-29 16:07   ` Stefan Behrens
2011-07-29 16:07 ` Stefan Behrens [this message]
2011-07-29 16:07   ` [PATCH v2 4/4] xfstests: Changed test 079 " Stefan Behrens
2011-07-30 14:28   ` Christoph Hellwig
2011-07-30 14:28     ` Christoph Hellwig

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=d63d92aa14e5fa81b4a40d0903001e70f7da9249.1311953979.git.sbehrens@giantdisaster.de \
    --to=sbehrens@giantdisaster.de \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=xfs@oss.sgi.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 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.