chattr

QNX SDP8.0Utilities ReferenceUtilities

Manipulate the attributes of a file (QNX OS)

Syntax:

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

Runs on:

QNX OS

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:
  • For DOS/FAT, it directly corresponds to the hidden bit.
  • For ISO-9660, it's the existence bit.

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-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.
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.
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
Page updated: