The chattr command is used to set some attributes for a file (for example: append only (a), immutable (i), etc.).

Are these attributes implemented as extended attributes, or are they their own category of attributes?

1 Answer 1


No, those flags are set using the FS_IOC_SETFLAGS ioctl() (also known as EXT2_IOC_SETFLAGS for ext* file systems, and corresponding one for other filesystems).

In most file systems that support it, that translates to one bit map of the inode structure.

For instance, in ext4 and several other file systems, that's the i_flags inode structure member (a 32 bit integer).

Some foreign (non-Linux) filesystems like Apple's HFS+ have a similar concept with equivalent flags and the FS_IOC_SETFLAGS ioctl does the translation there.

When using the stat command (which dumps the inode structure) in debugfs on ext* file systems, that's the Flags: number in the output:

 $ sudo debugfs /dev/vda
 debugfs: stat /tmp/file
 Inode: 1835209   Type: regular    Mode:  0644   Flags: 0x80010

0x80000 is FS_EXTENT_FL (e in lsattr output), 0x10 is FS_IMMUTABLE_FL (i).

The new statx() system call can also return (part of) that information (not all systems at this time (early 2019) will have a recent enough version of the GNU libc (2.28 or newer) to be able to call it easily though).

On a recent system, you can use xfs_io's statx command as an interface to the statx() system call:

$ xfs_io -rc 'statx -r' /tmp/a
stat.attributes = 0x10

(here 0x10 is STATX_ATTR_IMMUTABLE, the FS_EXTENT_FL one doesn't have a corresponding statx() flag).

  • Note that the ioctl request code is named FS_IOC_SETFLAGS, not FC_IOC_SETFLAGS (I tried to just edit the answer to correct that but it appears Stack Exchange doesn't allow small corrections. Since it's only a two character change to fix both places, it's not allowed here). Mar 5 at 23:44
  • Thanks Dan, fixed now. Mar 6 at 6:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .