]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
chattr.1.in: Document the compression attribute flags E, X, and
authorTheodore Ts'o <tytso@mit.edu>
Sat, 17 Aug 2002 18:44:56 +0000 (14:44 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 17 Aug 2002 18:44:56 +0000 (14:44 -0400)
Z, and explain that chattr can't set or set these flags.
(Addresses Debian Bug #151990)

fsetflags.c (fsetflags), fgetflags.c (fgetflags.c), setflags.c
(setflags), getflags.c (getflags): Check to make sure the
file is a regular file or a directory before attempting to
use the ext2 ioctls.  Otherwise, return EOPNOTSUPP.
(Addresses Debian Bug #152029).

lib/e2p/ChangeLog
lib/e2p/fgetflags.c
lib/e2p/fsetflags.c
lib/e2p/getflags.c
lib/e2p/setflags.c
misc/ChangeLog
misc/chattr.1.in

index 5dfc86d14fc5e0fbc3f8744cad6bbab444351633..e2b1ebca7c811db40034004ae5999bc388d5a471 100644 (file)
@@ -1,3 +1,11 @@
+2002-08-17  Theodore Ts'o  <tytso@mit.edu>
+
+       * fsetflags.c (fsetflags), fgetflags.c (fgetflags.c), setflags.c
+               (setflags), getflags.c (getflags): Check to make sure the
+               file is a regular file or a directory before attempting to
+               use the ext2 ioctls.  Otherwise, return EOPNOTSUPP.
+               (Addresses Debian Bug #152029).
+
 2002-07-14  Theodore Ts'o  <tytso@mit.edu>
 
        * fsetflags.c (fsetflags), fgetflags.c (fgetflags,
index ed4ade9ddcd13b6ea9c8fc03c742e928446ecadb..f2d0399eae7e268773738fd14caf06cd7e12eccf 100644 (file)
@@ -23,9 +23,9 @@
 #if HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#if HAVE_STAT_FLAGS
+#include <sys/types.h>
 #include <sys/stat.h>
-#else
+#if HAVE_EXT2_IOCTLS
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #endif
@@ -40,8 +40,8 @@
 
 int fgetflags (const char * name, unsigned long * flags)
 {
-#if HAVE_STAT_FLAGS
        struct stat buf;
+#if HAVE_STAT_FLAGS
 
        if (stat (name, &buf) == -1)
                return -1;
@@ -65,6 +65,11 @@ int fgetflags (const char * name, unsigned long * flags)
 #if HAVE_EXT2_IOCTLS
        int fd, r, f, save_errno = 0;
 
+       if (!stat(name, &buf) &&
+           !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) {
+               close(fd);
+               goto notsupp;
+       }
        fd = open (name, OPEN_FLAGS);
        if (fd == -1)
                return -1;
@@ -76,10 +81,9 @@ int fgetflags (const char * name, unsigned long * flags)
        if (save_errno)
                errno = save_errno;
        return r;
-#else /* ! HAVE_EXT2_IOCTLS */
-       extern int errno;
+#endif /* HAVE_EXT2_IOCTLS */
+#endif
+notsupp:
        errno = EOPNOTSUPP;
        return -1;
-#endif /* ! HAVE_EXT2_IOCTLS */
-#endif
 }
index 6942c045adbd3e55b07663764c14ca56449bc3d3..f12af1c8650977388b414aacf0b72a61dea94dc2 100644 (file)
@@ -23,9 +23,9 @@
 #if HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#if HAVE_CHFLAGS
-#include <sys/stat.h>          /* For the flag values.  */
-#else
+#include <sys/types.h>
+#include <sys/stat.h>
+#if HAVE_EXT2_IOCTLS
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #endif
@@ -40,6 +40,7 @@
 
 int fsetflags (const char * name, unsigned long flags)
 {
+       struct stat buf;
 #if HAVE_CHFLAGS
        unsigned long bsd_flags = 0;
 
@@ -61,6 +62,11 @@ int fsetflags (const char * name, unsigned long flags)
 #if HAVE_EXT2_IOCTLS
        int fd, r, f, save_errno = 0;
 
+       if (!stat(name, &buf) &&
+           !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) {
+               close(fd);
+               goto notsupp;
+       }
        fd = open (name, OPEN_FLAGS);
        if (fd == -1)
                return -1;
@@ -72,10 +78,9 @@ int fsetflags (const char * name, unsigned long flags)
        if (save_errno)
                errno = save_errno;
        return r;
-#else /* ! HAVE_EXT2_IOCTLS */
-       extern int errno;
+#endif /* HAVE_EXT2_IOCTLS */
+#endif
+notsupp:
        errno = EOPNOTSUPP;
        return -1;
-#endif /* ! HAVE_EXT2_IOCTLS */
-#endif
 }
index 477cb9bd283f9a5fdcef429978c08e620ed51d03..acf7a122b4749d749007343f7a208589e8c73c44 100644 (file)
@@ -17,9 +17,9 @@
 #if HAVE_ERRNO_H
 #include <errno.h>
 #endif
-#if HAVE_STAT_FLAGS
+#include <sys/types.h>
 #include <sys/stat.h>
-#else
+#if HAVE_EXT2_IOCTLS
 #include <sys/ioctl.h>
 #endif
 
@@ -27,8 +27,8 @@
 
 int getflags (int fd, unsigned long * flags)
 {
-#if HAVE_STAT_FLAGS
        struct stat buf;
+#if HAVE_STAT_FLAGS
 
        if (fstat (fd, &buf) == -1)
                return -1;
@@ -52,13 +52,15 @@ int getflags (int fd, unsigned long * flags)
 #if HAVE_EXT2_IOCTLS
        int r, f;
        
+       if (!fstat(fd, &buf) &&
+           !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode))
+               goto notsupp;
        r = ioctl (fd, EXT2_IOC_GETFLAGS, &f);
        *flags = f;
        return r;
-#else /* ! HAVE_EXT2_IOCTLS */
-       extern int errno;
+#endif /* HAVE_EXT2_IOCTLS */
+#endif
+notsupp:
        errno = EOPNOTSUPP;
        return -1;
-#endif /* ! HAVE_EXT2_IOCTLS */
-#endif
 }
index 2bf47fa27025df5f60b158c5aa3b0380af1f18cc..1693035766496de4c126796e96f5e97478571eeb 100644 (file)
 #if HAVE_ERRNO_H
 #include <errno.h>
 #endif
-#if HAVE_CHFLAGS
 #include <sys/types.h>
-#include <sys/stat.h>          /* For the flag values.  */
-#else
+#include <sys/stat.h>
+#if HAVE_EXT2_IOCTLS
 #include <sys/ioctl.h>
 #endif
 
@@ -28,6 +27,7 @@
 
 int setflags (int fd, unsigned long flags)
 {
+       struct stat buf;
 #if HAVE_CHFLAGS
        unsigned long bsd_flags = 0;
 
@@ -49,12 +49,15 @@ int setflags (int fd, unsigned long flags)
 #if HAVE_EXT2_IOCTLS
        int     f;
 
+       if (!fstat(fd, &buf) &&
+           !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) {
+               errno = EOPNOTSUPP;
+               return -1;
+       }
        f = (int) flags;
        return ioctl (fd, EXT2_IOC_SETFLAGS, &f);
-#else /* ! HAVE_EXT2_IOCTLS */
-       extern int errno;
+#endif /* HAVE_EXT2_IOCTLS */
+#endif
        errno = EOPNOTSUPP;
        return -1;
-#endif /* ! HAVE_EXT2_IOCTLS */
-#endif
 }
index 59325b6faefe87977520747ff8ce532d5cedff39..ec3e1e9ec376ff9ccce97236fa51e4b549e9faea 100644 (file)
@@ -1,5 +1,9 @@
 2002-08-17  Theodore Ts'o  <tytso@mit.edu>
 
+       * chattr.1.in: Document the compression attribute flags E, X, and
+               Z, and explain that chattr can't set or set these flags.
+               (Addresses Debian Bug #151990)
+
        * fsck.8.in: Fix typo in man page, and clarified text regarding
                options specifiers for -t option.  (Addresses Debian bug 
                #145044)
index 590cca06cfede9029117f9ef98934d74adf4bd8e..218a291d06a0d366188d663d4ac65080a51cc646 100644 (file)
@@ -53,10 +53,21 @@ A file with the `c' attribute set is automatically compressed on the disk
 by the kernel. A read from this file returns uncompressed data. A write to
 this file compresses data before storing them on the disk.
 .PP
+When a directory with the `D' attribute set is modified,
+the changes are written synchronously on the disk; this is equivalent to
+the `dirsync' mount option applied to a subset of the files.
+.PP
 A file with the `d' attribute set is not candidate for backup when the
 .BR dump (8)
 program is run.
 .PP
+The 'E' attribute is used by the experimental compression patches to 
+indicate that a compressed file has a compression error.  It may not be
+set or reset using 
+.BR chattr (1),
+although it can be displayed by
+.BR lsattr (1).
+.PP
 A file with the `i' attribute cannot be modified: it cannot be deleted or
 renamed, no link can be created to this file and no data can be written
 to the file. Only the superuser can set or clear this attribute.
@@ -74,10 +85,6 @@ When a file with the `S' attribute set is modified,
 the changes are written synchronously on the disk; this is equivalent to
 the `sync' mount option applied to a subset of the files.
 .PP
-When a directory with the `D' attribute set is modified,
-the changes are written synchronously on the disk; this is equivalent to
-the `dirsync' mount option applied to a subset of the files.
-.PP
 A file with the 't' attribute will not have a partial block fragment at
 the of the file merged with other files (for those filesystems which
 support tail-merging).  This is necessary for applications such as LILO 
@@ -87,6 +94,19 @@ files.
 When a file with the `u' attribute set is deleted, its contents are saved.
 This allows the user to ask for its undeletion.
 .PP
+The 'X' attribute is used by the experimental compression patches to 
+indicate that a raw contents of a compressed file can be accessed
+directly.  It currently may not be set or reset using 
+.BR chattr (1),
+although it can be displayed by
+.BR lsattr (1).
+.PP
+The 'Z' attribute is used by the experimental compression patches to 
+indicate a compressed file is dirty.  It may not be set or reset using 
+.BR chattr (1),
+although it can be displayed by
+.BR lsattr (1).
+.PP
 .SH AUTHOR
 .B chattr
 was written by Remy Card <Remy.Card@linux.org>.