Re: [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set

From: liubaolin

Date: Wed Sep 02 2026 - 02:49:55 EST




在 2026/9/2 09:22, Namjae Jeon 写道:
On Tue, Sep 1, 2026 at 6:15 PM Baolin Liu <liubaolin12138@xxxxxxx> wrote:

From: Baolin Liu <liubaolin@xxxxxxxxxx>

Wire up the fileattr inode operations so that lsattr(1) and chattr(1)
work on ntfs.

fileattr_get reports the compressed and encrypted state of the attribute
and the immutable and append-only flags, the same states ntfs_getattr()
already reports through STATX_ATTR_*.

fileattr_set accepts only FS_IMMUTABLE_FL and FS_APPEND_FL. Compression
and encryption are rejected because changing them would require
rewriting the attribute data. Both accepted flags go to inode->i_flags,
so the VFS enforces them.

Neither flag has an on-disk representation of its own, so a value set
through fileattr_set only lives for the lifetime of the mount. Note also
that S_IMMUTABLE is re-derived on every mount, from FILE_ATTR_SYSTEM when
mounted with sys_immutable and unconditionally for system files, so
clearing it on such a file does not survive a remount either.
NTFS forces S_IMMUTABLE on system metadata files such as $MFT, but
this patch allows userspace to clear that protection. The patch should
reject clearing immutable for these files and for files made immutable
by the sys_immutable mount option.

Hi Namjae,

You are right, that is a hole. The driver forces S_IMMUTABLE on those
files for a reason and userspace should not be able to clear it.

I will add the check and send a v2.

Thanks for the review.

Thanks,
Baolin