fs/ntfs/attrlist.c
Source file repositories/reference/linux-study-clean/fs/ntfs/attrlist.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ntfs/attrlist.c- Extension
.c- Size
- 8264 bytes
- Lines
- 294
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
mft.hattrib.hattrlist.h
Detected Declarations
function Copyrightfunction ntfs_attrlist_updatefunction ntfs_attrlist_entry_addfunction ntfs_attrlist_entry_rm
Annotated Snippet
if (err || ntfs_attr_truncate_i(attr_ni, base_ni->attr_list_size, HOLES_NO) != 0) {
iput(attr_vi);
ntfs_error(base_ni->vol->sb,
"Failed to truncate attribute list of inode %#llx",
(long long)base_ni->mft_no);
return -EIO;
}
} else if (err) {
iput(attr_vi);
ntfs_error(base_ni->vol->sb,
"Failed to truncate attribute list of inode %#llx",
(long long)base_ni->mft_no);
return -EIO;
}
i_size_write(attr_vi, base_ni->attr_list_size);
if (NInoNonResident(attr_ni) && !NInoAttrListNonResident(base_ni))
NInoSetAttrListNonResident(base_ni);
if (ntfs_inode_attr_pwrite(attr_vi, 0, base_ni->attr_list_size,
base_ni->attr_list, false) !=
base_ni->attr_list_size) {
iput(attr_vi);
ntfs_error(base_ni->vol->sb,
"Failed to write attribute list of inode %#llx",
(long long)base_ni->mft_no);
return -EIO;
}
NInoSetAttrListDirty(base_ni);
iput(attr_vi);
return 0;
}
/*
* ntfs_attrlist_entry_add - add an attribute list attribute entry
* @ni: opened ntfs inode, which contains that attribute
* @attr: attribute record to add to attribute list
*
* Return 0 on success and -errno on error.
*/
int ntfs_attrlist_entry_add(struct ntfs_inode *ni, struct attr_record *attr)
{
struct attr_list_entry *ale;
__le64 mref;
struct ntfs_attr_search_ctx *ctx;
u8 *new_al;
int entry_len, entry_offset, err;
struct mft_record *ni_mrec;
u8 *old_al;
__le64 lowest_vcn;
if (!ni || !attr) {
ntfs_debug("Invalid arguments.\n");
return -EINVAL;
}
ntfs_debug("Entering for inode 0x%llx, attr 0x%x.\n",
ni->mft_no, (unsigned int) le32_to_cpu(attr->type));
ni_mrec = map_mft_record(ni);
if (IS_ERR(ni_mrec)) {
ntfs_debug("Invalid arguments.\n");
return -EIO;
}
mref = MK_LE_MREF(ni->mft_no, le16_to_cpu(ni_mrec->sequence_number));
unmap_mft_record(ni);
if (ni->nr_extents == -1)
ni = ni->ext.base_ntfs_ino;
if (!NInoAttrList(ni)) {
ntfs_debug("Attribute list isn't present.\n");
return -ENOENT;
}
/* Determine size and allocate memory for new attribute list. */
entry_len = (sizeof(struct attr_list_entry) + sizeof(__le16) *
attr->name_length + 7) & ~7;
new_al = kvzalloc(ni->attr_list_size + entry_len, GFP_NOFS);
if (!new_al)
return -ENOMEM;
/* Find place for the new entry. */
ctx = ntfs_attr_get_search_ctx(ni, NULL);
if (!ctx) {
err = -ENOMEM;
ntfs_error(ni->vol->sb, "Failed to get search context");
Annotation
- Immediate include surface: `mft.h`, `attrib.h`, `attrlist.h`.
- Detected declarations: `function Copyright`, `function ntfs_attrlist_update`, `function ntfs_attrlist_entry_add`, `function ntfs_attrlist_entry_rm`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
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.