Some qns on Ext2 Extended File Attributes

From: Michael Kerrisk (m.kerrisk@gmx.net)
Date: Mon Aug 28 2000 - 02:23:00 EST


A while back there was a note in LK about ext2 extended file attributes
(and the rather out of date man page). I've been doing a little
experimentation and source scanning and have summarised what I understand
about these attributes, along with a few questions, as listed below. Can
anyone help me with some answers / correct any of my incorrect assumptions?

Thanks

Michael

EXT2_APPEND_FL (chattr +a file) File can only be opened for writing with
O_APPEND (thus forcing all file updates to append toend of file)
(requires su priv)

This is implemented. Looking at the kernel source (do_link in
fs/namei.c), and testing also shows that setting this attributes prevents
creation of hard links to a file. This flag also prevents related
operations such as truncate() and unlink() on a file.

EXT2_NOATIME_FL (chattr +A file) Do not update file access time

The man page says this is still in testing, and is not yet supported. One
posting in the earlier LK thrread implied that this attribute *is* now
effective, and looking at fs/inode.c, I see the line

    if ( IS_NOATIME (inode) ) return;

in update_atime(), and briefly looking at other parts of the source seems
to imply that this feature *is* present. However, a simple test (touch(1)
on a file with this attribute set) seems to indicate that this feature is
**not** implemented (since touch did change the file atime...). The
original poster of the earlier LK thread also found this attribute did not
seem to work. Have I missed something?

EXT2_COMPR_FL (chattr +c file) Store file in compressed form

The manual page says this isn't implemented, and a quick test seems to
indicate that this is so. The previous LK note indicates that e2compr
adds this support, but I haven't tried this.

EXT2_NODUMP_FL (chattr +d file) Do not backup file with dump(8)

I ran a quick test with dump(8), and it seems to ignore this attribute
(i.e. files with this attribute got backed up anyway). Does this
attribute have any effect anywhere?

EXT2_IMMUTABLE_FL (chattr +i file) Make file immutable (no updates allowed)
(requires su priv)

This is implemented. File data cannot be updated (write()) and metadata
changes are prevented (chmod(), unlink(), link())

EXT2_SECRM_FL (chattr +s file) Secure deletion

Although the manual page doesn't say so, it seems this feature is not
implemented. (The earlier LK thread also says this) A simple test -
creating a very large file with this flag set, and then deleting it showed
no delay on the deletion, suggesting that no explicit zeroing of file
bytes occurred. Looking at the sources seems to confirm this.

EXT2_SYNC_FL (chattr +S file) Make file updates synchronous

Either I'm misunderstanding how this attribute works or it doesn't seem to
be implemented. I had expected that setting this flag would force later
opens for writing on a file to behave as if O_SYNC had been specified.
Briefly looking at the kernel sources seems to indicate that this
attribute should have an effect.

I tried setting this attribute on a file and then running some timing
tests with a program which wrote a 10000 * 1 bytes to a file. The timings
seem to inicate that the attribute had **no** affect, since if I modified
my program to explicity open(O_SYNC), then the times slowed down
considerably.

Is this attribute effective, and if so, how?

EXT2_UNRM_FL (chattr +u file) Undelete file

The man page says this is not yet implemented, and looking at the kernel
sources seems to confirm this.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Aug 31 2000 - 21:00:20 EST