Re: [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set
From: Namjae Jeon
Date: Tue Sep 01 2026 - 21:23:04 EST
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.