file_attr(2type)
β¨ file_attr(2type) β¨
okay so bestie, this one is a type page (a 2type page, if we're being precise π
) from section 2 of the Linux man-pages, and it's literally just the β¨glow-upβ¨ of a struct. no functions, no syscall, just a little bundle of fields that the kernel hands back and forth. it's giving "supporting cast member with main character energy" π
πΈ NAME πΈ
file_attr β filesystem file attributes π¦
π SYNOPSIS π
okay so first you gotta pull in the header:
#include <linux/fs.h>
and then here's the whole struct, character for character, no edits, we do not touch the struct, the struct is sacred π
struct file_attr {
u64 fa_xflags; // Extended flags
u32 fa_extsize; // Extent size hint
u32 fa_nextents; // Number of extents (read-only)
u32 fa_projid; // Project identifier
u32 fa_cowextsize; // CoW extent size hint
};
π DESCRIPTION π
so like, this whole thing describes filesystem file attributes, and its literal job in life is to be the payload for two syscalls: file_getattr(2) and file_setattr(2). one reads it, one writes it. iconic teamwork fr fr π«Ά
here's the field-by-field breakdown, no skips, no shortcuts:
.fa_xflagsβ this is where the file attribute flags live. it's a bit mask, meaning it's zero or more of theFS_XFLAG_*flags OR'd together. the full menu is down in Flags below, iykyk β¨.fa_extsizeβ the extent size allocator hint, measured in bytes. basically it's a lil suggestion like "hey, for new allocations for this file, maybe prefer extents around this big?" a vibe check for the allocator, if you will π.fa_nextentsβ the number of data extents in the file, and bestie this one is read-only.file_getattr(2)fills it in for you;file_setattr(2)straight up ignores it. you don't write to this one, periodt π«.fa_projidβ the project identifier. quota systems use it (quotactl(2)) to group files that belong together, like a lil friend group for accounting purposes πΈ.fa_cowextsizeβ the Copy-on-Write (CoW) extent size hint, in bytes. same deal asfa_extsizebut specifically suggesting a preferred extent size for CoW operations π¦
π Flags π
here come the FS_XFLAG_* flags ok, deep breath, there's a bunch and we love them all:
FS_XFLAG_REALTIMEβ data is stored in a realtime volume.FS_XFLAG_IMMUTABLEβ file cannot be modified. (not "shouldn't", cannot. it's locked in π)FS_XFLAG_APPENDβ all writes must append to the end of the file.FS_XFLAG_SYNCβ all writes are synchronous.FS_XFLAG_NOATIMEβ do not update file access time on reads.FS_XFLAG_NODUMPβ do not include file in backups.FS_XFLAG_DAXβ use Direct Access (DAX) for I/O operations.FS_XFLAG_NODEFRAGβ exclude this file from defragmentation operations.FS_XFLAG_FILESTREAMβ use filestream allocator for this file.FS_XFLAG_EXTSIZEβ use the extent size hint from thefa_extsizefield.FS_XFLAG_COWEXTSIZEβ use the CoW extent size hint from thefa_cowextsizefield.
π Directory-only flags:
these only make sense on directories, so don't come for them on files bestie:
FS_XFLAG_RTINHERITβ new files created in this directory inherit the realtime flag.FS_XFLAG_NOSYMLINKSβ disallow creation of symbolic links in this directory.FS_XFLAG_EXTSZINHERITβ new files created in this directory inherit the extent size hint.FS_XFLAG_PROJINHERITβ new files created in this directory inherit the project identifier.
π Read-only flags:
FS_XFLAG_PREALLOCβ file has preallocated extents.FS_XFLAG_HASATTRβ file has extended attributes.FS_XFLAG_VERITYβ file has fs-verity enabled.FS_XFLAG_CASEFOLDβ the filesystem performs case-insensitive lookups (file and directory name comparisons ignore case).FS_XFLAG_CASENONPRESERVINGβ the filesystem does not preserve the case of file and directory names.
β οΈ and this part matters, so listen up: not all filesystems support all flags. setting unsupported flags may result in an error. so like, check before you go setting things, ok? don't just assume π
π°οΈ HISTORY π°οΈ
Linux v6.17
this structure is introduced. hello world, welcome to the kernel π
Linux v7.2
the FS_XFLAG_CASEFOLD and FS_XFLAG_CASENONPRESERVING are introduced, and the whole reason is so that upper layers β like NFSD β can retrieve case sensitivity information. slay β¨
π SEE ALSO π
file_getattr(2)file_setattr(2)
and that's the whole page bestie, no cap π this was Linux man-pages 6.20, dated 2026-10-11, and it's giving thorough. go read file_getattr(2) and file_setattr(2) next, they're the ones actually doing stuff. mwah π«Άπ
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms