fs/jfs/xattr.c
Source file repositories/reference/linux-study-clean/fs/jfs/xattr.c
File Facts
- System
- Linux kernel
- Corpus path
fs/jfs/xattr.c- Extension
.c- Size
- 26324 bytes
- Lines
- 1056
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/capability.hlinux/fs.hlinux/xattr.hlinux/posix_acl_xattr.hlinux/slab.hlinux/quotaops.hlinux/security.hjfs_incore.hjfs_superblock.hjfs_dmap.hjfs_debug.hjfs_dinode.hjfs_extent.hjfs_metapage.hjfs_xattr.hjfs_acl.h
Detected Declarations
struct ea_bufferfunction prefixfunction name_sizefunction copy_namefunction ea_write_inlinefunction ea_writefunction ea_read_inlinefunction ea_readfunction ea_getfunction ea_releasefunction ea_putfunction __jfs_setxattrfunction XATTR_SIZE_MAXfunction __jfs_getxattrfunction can_listfunction jfs_listxattrfunction __jfs_xattr_setfunction jfs_xattr_getfunction jfs_xattr_setfunction jfs_xattr_get_os2function jfs_xattr_set_os2function jfs_initxattrsfunction jfs_init_security
Annotated Snippet
struct ea_buffer {
int flag; /* Indicates what storage xattr points to */
int max_size; /* largest xattr that fits in current buffer */
dxd_t new_ea; /* dxd to replace ea when modifying xattr */
struct metapage *mp; /* metapage containing ea list */
struct jfs_ea_list *xattr; /* buffer containing ea list */
};
/*
* ea_buffer.flag values
*/
#define EA_INLINE 0x0001
#define EA_EXTENT 0x0002
#define EA_NEW 0x0004
#define EA_MALLOC 0x0008
/*
* Mapping of on-disk attribute names: for on-disk attribute names with an
* unknown prefix (not "system.", "user.", "security.", or "trusted."), the
* prefix "os2." is prepended. On the way back to disk, "os2." prefixes are
* stripped and we make sure that the remaining name does not start with one
* of the know prefixes.
*/
static int is_known_namespace(const char *name)
{
if (strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN) &&
strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) &&
strncmp(name, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) &&
strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
return false;
return true;
}
static inline int name_size(struct jfs_ea *ea)
{
if (is_known_namespace(ea->name))
return ea->namelen;
else
return ea->namelen + XATTR_OS2_PREFIX_LEN;
}
static inline int copy_name(char *buffer, struct jfs_ea *ea)
{
int len = ea->namelen;
if (!is_known_namespace(ea->name)) {
memcpy(buffer, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN);
buffer += XATTR_OS2_PREFIX_LEN;
len += XATTR_OS2_PREFIX_LEN;
}
memcpy(buffer, ea->name, ea->namelen);
buffer[ea->namelen] = 0;
return len;
}
/* Forward references */
static void ea_release(struct inode *inode, struct ea_buffer *ea_buf);
/*
* NAME: ea_write_inline
*
* FUNCTION: Attempt to write an EA inline if area is available
*
* PRE CONDITIONS:
* Already verified that the specified EA is small enough to fit inline
*
* PARAMETERS:
* ip - Inode pointer
* ealist - EA list pointer
* size - size of ealist in bytes
* ea - dxd_t structure to be filled in with necessary EA information
* if we successfully copy the EA inline
*
* NOTES:
* Checks if the inode's inline area is available. If so, copies EA inline
* and sets <ea> fields appropriately. Otherwise, returns failure, EA will
* have to be put into an extent.
*
* RETURNS: 0 for successful copy to inline area; -1 if area not available
*/
static int ea_write_inline(struct inode *ip, struct jfs_ea_list *ealist,
int size, dxd_t * ea)
{
struct jfs_inode_info *ji = JFS_IP(ip);
/*
Annotation
- Immediate include surface: `linux/capability.h`, `linux/fs.h`, `linux/xattr.h`, `linux/posix_acl_xattr.h`, `linux/slab.h`, `linux/quotaops.h`, `linux/security.h`, `jfs_incore.h`.
- Detected declarations: `struct ea_buffer`, `function prefix`, `function name_size`, `function copy_name`, `function ea_write_inline`, `function ea_write`, `function ea_read_inline`, `function ea_read`, `function ea_get`, `function ea_release`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.