chattr

Manipulate the attributes of a file (QNX Neutrino)

Syntax:

chattr [+|- attribute]... [filename]...

Runs on:

QNX Neutrino

Options:

attribute
The attribute you want to remove (-) or set (+).
filename
The name of a file whose attributes you want to display or manipulate.

Description:

The chattr utility is a front end to the DCMD_FSYS_FILE_FLAGS devctl() command—defined in <sys/dcmd_blk.h>, and described in the Devctl and Ioctl Commands reference—which gets and sets file attributes (that are outside the scope of the POSIX standard). For example, the DOS/FAT filesystem has the concept of "hidden" or "system" files. Such attributes are typically stored as flags in the on-disk inode of each file.

When you invoke chattr with no attributes and a filename (or a list of filenames), it displays the currently set attributes of each file. When you invoke chattr with an attribute (or list of attributes), it applies those modifications to each file.

These attributes are divided into the following classes:

Generic
An attribute that corresponds to a concept that may be shared across multiple filesystem formats (even if implemented in a different manner for each one).
Filesystem-specific
An attribute that has meaning only within a specific filesystem.

It's the responsibility of each io-blk.so filesystem module to map generic attributes to and from their private representation.

For example, a hidden file is a generic concept of a filename that may be hidden from normal user browsing (not displayed by ls) but remains available (to open() by an application) if its name is already known. The representation of this concept varies between filesystems:

This mapping functionality allows for application abstraction away from a particular on-disk structure (a program can work unchanged against any file on any filesystem). Many filesystem-specific attributes have no corresponding generic concept, and must be manipulated with knowledge of the underlying filesystem structure; the various <sys/fs_*.h> header files contain relevant bit definitions.

Filesystem Attribute Bit Description
Generic backup FS_FLAGS_BACKUP The file has been modified and should be backed up.
  contiguous FS_FLAGS_CONTIGUOUS The file is contiguous.
  dirty FS_FLAGS_DIRTY The filesystem might be in an inconsistent state.
  hidden FS_FLAGS_HIDDEN The file is hidden from normal user browsing (not displayed by ls) but remains available (to open() by an application) if its name is already known.
Power-Safe (fs-qnx6.so) defrag QNX6FS_BG_DEFRAG Background defragmentation is enabled.
  hold QNX6FS_SNAPSHOT_HOLD Snapshots are on hold for the file.
  modified QNX6FS_INO_MODIFIED The inode has been modified.
  snapshot FS_FLAGS_COMMITTING Snapshots are turned on.
  used QNX6FS_INO_USED The inode is in use.
fs-qnx4.so busy QNX4FS_FILE_BUSY The file was being written when a crash occurred.
  clean QNX4FS_FSYS_CLEAN The filesystem is intact.
  grown QNX4FS_FILE_GROWN The file is a growing data file and space has been overallocated for it.
  inode QNX4FS_FILE_INODE The file is an inode.
  link QNX4FS_FILE_LINK The file is a link.
  modified QNX4FS_FILE_MODIFIED The inode has been modified.
  used QNX4FS_FILE_USED The inode is in use.
fs-cd.so, fs-udf.so associate CDFS_DIRENT_ASSOCIATE The file is an associated file (i.e., it has a relationship to another file sith the same identifier).
  cdda CDFS_CDXA_CDDA The file is a Compact Disk Digital Audio file.
  dir CDFS_DIRENT_DIR The file is a directory.
  existence CDFS_DIRENT_EXIST Don't make the file's existence known (i.e., it's hidden).
  extent CDFS_DIRENT_EXTENT The file has more than one extent; this isn't the final directory record for the file.
  interleave CDFS_CDXA_INTERLEAVED The file extents are interleaved.
  mode2form1 CDFS_CDXA_MODE2FORM1 The file is a Mode 2 Form 1 file.
  mode2form2 CDFS_CDXA_MODE2FORM2 The file is a Mode 2 Form 2 file.
  protect CDFS_DIRENT_PROTECT Only the owner may read or execute the file.
  record CDFS_DIRENT_RECORD The information in the file has a specified record format.
fs-udf.so archive   The file has been modified and should be backed up.
  nonreloc   The file can't be relocated.
  setgid   The file has the setgid bit set.
  setuid   The file has the setuid bit set.
  sorted   Directories are sorted.
  sticky   The sticky bit is set.
  stream   The file is a named stream.
  system   The file is used exclusively by the OS and shouldn't be changed or deleted.
  transform   The file has been transformed (e.g., by being compressed).
fs-dos.so archive DOSFS_ARCHIVE The file has been modified and should be backed up.
  dir DOSFS_DIR The file is a directory.
  hidden DOSFS_HIDDEN The file is normally hidden from view.
  label DOSFS_VOLLABEL The file represents the volume label.
  lcasebase DOSFS_LCASE_BASE The base filename includes lowercase characters.
  lcaseext DOSFS_LCASE_EXT The filename's extension includes lowercase characters.
  rdonly DOSFS_RDONLY The file is read-only.
  system DOSFS_SYSTEM The file is used exclusively by the OS and shouldn't be changed or deleted.
fs-nt.so archive   The file has been modified and should be backed up.
  compress   The file is compressed.
  device   The file represents a device.
  encrypt   The file is encrypted.
  hidden   The file is normally hidden from view.
  normal   The file is normal.
  offline   The actual file is stored remotely.
  rdonly   The file is read-only.
  sparse   The file is sparse; nonzero data is allocated on disk, but long strings of zeros aren't.
  system   The file is used exclusively by the OS and shouldn't be changed or deleted.
  temp   The file is temporary.
fs-mac.so alias   The file is an alias file, a dynamic link to another file.
  bundle   The file is a bundle, a directory with a standardized hierarchy that holds executable code and any associated resources.
  desktop   The file is located on the desktop.
  hasicon   The file has its own customized icon.
  hiddenext   The file's extension is hidden.
  invisible   The file doesn't appear in dialog box listings or windows.
  namelock   You can't rename the file or assign another icon to it.
  stationery   The file is a stationery pad; you can use it as a template to create new files, but you can't modify the file itself.

Examples:

List the attributes for a file:

# chattr chattr.c
chattr.c: +backup +contiguous +used +modified

Add to and remove from the attributes for a file:

# chattr -archive +system /fs/dos/autoexec.bat
/fs/dos/autoexec.bat: -archive +system

Turn off snapshots for a Power-Safe (fs-qnx6.so) filesystem:

# chattr -snapshot /fs/qnx6
/fs/qnx6: -snapshot