chattr源码

chattr是一个用于修改Linux文件系统中文件属性的工具。文件属性包括追加写入(a)、压缩(c)、禁止备份(d)等,通过"+"、"-"或"="操作符来添加、移除或设置属性。本文详细介绍了各个属性的功能,如追加模式、压缩文件、不可变文件、同步更新等,并提供了源码分析,包括如何设置和检查文件属性。
摘要由CSDN通过智能技术生成

/*

Name


chattr - change file attributes on a Linux file system

Synopsis


chattr [ mode ] files…

Description


chattr changes the file attributes on a Linux file system. The format

of a symbolic mode is ±=[acdeijstuADST].

The operator ‘+’ causes the selected attributes to be added to the

existing attributes of the files; ‘-’ causes them to be removed; and

‘=’ causes them to be the only attributes that the files have.

The letters ‘acdeijstuADST’ select the new attributes for the files:

append only (a), compressed ©, no dump (d), extent format (e),

immutable (i), data journalling (j), secure deletion (s), no

tail-merging (t), undeletable (u), no atime updates (A), synchronous

directory updates (D), synchronous updates (S), and top of directory

hierarchy (T).

The following attributes are read-only, and may be listed by lsattr(1)

but not modified by chattr: huge file (h), compression error (E),

indexed directory (I), compression raw access (X), and compressed

dirty file (Z).

Attributes


When a file with the ‘A’ attribute set is accessed, its atime record

is not modified. This avoids a certain amount of disk I/O for laptop

systems. A file with the ‘a’ attribute set can only be open in append

mode for writing. Only the superuser or a process possessing the

CAP_LINUX_IMMUTABLE capability can set or clear this attribute.

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. Note: please make sure to read the bugs and limitations section

at the end of this document.

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.

A file with the ‘d’ attribute set is not candidate for backup when the

dump(8) program is run.

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 chattr(1), although it can be displayed by

lsattr(1).

The ‘e’ attribute indicates that the file is using extents for mapping

the blocks on disk. It may not be remove

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值