simple_xattr_set(9)
π simple_xattr_set(9) π
okay so welcome to the Kernel API Manual bestie, today we're doing simple_xattr_set β the function that sets an xattr object. it's giving "small but powerful" energy ngl π
β¨ NAME β¨
simple_xattr_set β set an xattr object π¦
πΈ SYNOPSIS πΈ
struct simple_xattr * simple_xattr_set (struct simple_xattr_cache *cache
, struct list_head *xattrs , const char *name , const void *value ,
size_t size , int flags );
like, six whole arguments. she's high maintenance but she's iconic π
π ARGUMENTS π
cacheβ anchor for the hash table ποΈxattrsβ the header of the xattr objectnameβ the name of the xattr to retrieve πvalueβ the value to store along the xattr πsizeβ the size ofvalueflagsβ the flags determining how to set the xattr π©
π DESCRIPTION π
So we're setting a new xattr object. periodt.
If value is passed, a new xattr object will be allocated. β¨
Now the flags lore, because this is the main character of the whole function:
- If
XATTR_REPLACEis specified inflags, a matching xattr object fornamemust already exist. If it does, it gets replaced with the new xattr object. If it doesn't β we fail. π no cap. - If
XATTR_CREATEis specified and a matching xattr does already exist, we fail. If it doesn't exist, we create a new xattr. π± - If
flagsis zero, we simply insert the new xattr, replacing any existing one. easy slay π«Ά
Also:
- If
valueis empty and a matching xattr object is found, we delete it ifXATTR_REPLACEis specified inflagsorflagsis zero. ποΈ - If
valueis empty and no matching xattr object fornameis found, we do nothing ifXATTR_CREATEis specified inflagsorflagsis zero. ForXATTR_REPLACEwe fail, as mentioned above. π
π₯ NOTE π₯
bestie listen. Callers must externally serialize writes. All current callers hold the inode lock for write operations. The lookup->replace/remove sequence is not atomic with respect to the rhashtable's per-bucket locking, but it is safe because writes are serialized by the caller. like it looks sketchy but it's fine, iykyk π
β RETURN β
On success, the removed or replaced xattr is returned, to be freed by the caller; or NULL if none. On failure a negative error code is returned. π
π SEE ALSO π
Kernel file ./fs/xattr.c π and honestly the whole friend group:
may_write_xattr(9)__vfs_setxattr_noperm(9)__vfs_setxattr_locked(9)vfs_listxattr(9)__vfs_removexattr_locked(9)generic_listxattr(9)xattr_full_name(9)simple_xattr_space(9)simple_xattr_free(9)simple_xattr_free_rcu(9)simple_xattr_alloc(9)simple_xattr_get(9)simple_xattr_set_limited(9)simple_xattr_list(9)simple_xattr_add(9)simple_xattr_add_limited(9)simple_xattrs_free(9)simple_xattr_cache_cleanup(9)
that's the whole page bestie, from ./fs with love, October 2026 edition, simple_xattr_set(9) out πβ¨π¦ go forth and set your xattrs π«Ά
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms