xfs
[Top] [All Lists]

Re: lsattr/chattr and XFS

To: Nathan Scott <nathans@xxxxxxx>
Subject: Re: lsattr/chattr and XFS
From: Utz Lehmann <ulehmann@xxxxxxxxxxxxxx>
Date: Tue, 27 Nov 2001 15:10:26 +0100
Cc: Justin Cormack <justin@xxxxxxxxxxxxxxxxxxxxxxxxx>, Theodore Tso <tytso@xxxxxxxxx>, linux-xfs@xxxxxxxxxxx
In-reply-to: <20011127104329.A16303@xxxxxxxxxxxxxxxxxxxxxxxx>; from nathans@xxxxxxx on Tue, Nov 27, 2001 at 10:43:30AM +1100
References: <200111261258.fAQCwgD11055@xxxxxxxxxxxxxxxxxxxxxxxxx> <20011127104329.A16303@xxxxxxxxxxxxxxxxxxxxxxxx>
Sender: owner-linux-xfs@xxxxxxxxxxx
User-agent: Mutt/1.3.12i
Hi Nathan

Checking for an ext2 filesystem in chattr/lsattr is imho a bad idea.
The reiserfs people have a patch for it.

http://marc.theaimsgroup.com/?l=reiserfs&m=100218431021888&w=2

chattr/lsattr should just print "filesystem unsupported" or such when the
ioctl faild for an fs which doesn't support it.


utz 

Nathan Scott [nathans@xxxxxxx] wrote:
[...]
> The "Invalid argument" (EINVAL) message is coming from the XFS
> kernel code, because it receives a request for an ioctl which it
> doesn't know anything about (an ext2 ioctl in this case).
> 
> This is arguably a buglet in e2fsprogs - in xfsprogs, wherever we
> issue an XFS-specific ioctl to an arbitary file descriptor we 1st
> check that it is indeed on an XFS filesystem (using fstatfs).
> 
> But its just a matter of style/taste on the e2fsprogs maintainers
> part, I guess - Ted, below is a little patch which is the sort of
> thing we do in the XFS utilites before we issue any XFS-specific
> ioctl call.  This checks the lsattr/chattr calls - there may well
> be several other ioctls I've missed in other parts of the code.
> 
> cheers.
> 
> -- 
> Nathan
> 
> 
> diff -Naur e2fsprogs-1.25/lib/e2p/fgetflags.c 
> e2fsprogs-1.25-ns/lib/e2p/fgetflags.c
> --- e2fsprogs-1.25/lib/e2p/fgetflags.c        Thu Sep 20 11:24:12 2001
> +++ e2fsprogs-1.25-ns/lib/e2p/fgetflags.c     Tue Nov 27 09:43:39 2001
> @@ -31,6 +31,7 @@
>  #endif
>  
>  #include "e2p.h"
> +#include <sys/statfs.h>
>  
>  #ifdef O_LARGEFILE
>  #define OPEN_FLAGS (O_RDONLY|O_NONBLOCK|O_LARGEFILE)
> @@ -64,10 +65,19 @@
>  #else
>  #if HAVE_EXT2_IOCTLS
>       int fd, r, f;
> +     struct statfs sf;
> +     extern int errno;
>  
>       fd = open (name, OPEN_FLAGS);
>       if (fd == -1)
>               return -1;
> +     r = fstatfs (fd, &sf);
> +     if (r == -1)
> +             return -1;
> +     if (sf.f_type != EXT2_SUPER_MAGIC) {
> +             errno = EOPNOTSUPP;
> +             return -1;
> +     }
>       r = ioctl (fd, EXT2_IOC_GETFLAGS, &f);
>       *flags = f;
>  
> diff -Naur e2fsprogs-1.25/lib/e2p/fsetflags.c 
> e2fsprogs-1.25-ns/lib/e2p/fsetflags.c
> --- e2fsprogs-1.25/lib/e2p/fsetflags.c        Thu Sep 20 11:24:12 2001
> +++ e2fsprogs-1.25-ns/lib/e2p/fsetflags.c     Tue Nov 27 09:43:47 2001
> @@ -31,6 +31,7 @@
>  #endif
>  
>  #include "e2p.h"
> +#include <sys/statfs.h>
>  
>  #ifdef O_LARGEFILE
>  #define OPEN_FLAGS (O_RDONLY|O_NONBLOCK|O_LARGEFILE)
> @@ -60,10 +61,19 @@
>  #else
>  #if HAVE_EXT2_IOCTLS
>       int fd, r, f;
> +     struct statfs sf;
> +     extern int errno;
>  
>       fd = open (name, OPEN_FLAGS);
>       if (fd == -1)
>               return -1;
> +     r = fstatfs (fd, &sf);
> +     if (r == -1)
> +             return -1;
> +     if (sf.f_type != EXT2_SUPER_MAGIC) {
> +             errno = EOPNOTSUPP;
> +             return -1;
> +     }
>       f = (int) flags;
>       r = ioctl (fd, EXT2_IOC_SETFLAGS, &f);
>       close (fd);


<Prev in Thread] Current Thread [Next in Thread>