fs/ntfs/reparse.c
Source file repositories/reference/linux-study-clean/fs/ntfs/reparse.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ntfs/reparse.c- Extension
.c- Size
- 23965 bytes
- Lines
- 965
- 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
ntfs.hlayout.hattrib.hinode.hdir.hvolume.hmft.hindex.hlcnalloc.hreparse.h
Detected Declarations
struct wsl_link_reparse_datastruct reparse_indexfunction reparse_name_is_validfunction ntfs_reparse_target_to_nlsfunction valid_reparse_bufferfunction valid_reparse_datafunction ntfs_reparse_tag_modefunction ntfs_make_symlinkfunction valid_reparse_datafunction ntfs_reparse_tag_dt_typesfunction ntfs_is_drive_letterfunction ntfs_translate_symlink_pathfunction set_reparse_indexfunction remove_reparse_indexfunction update_reparse_datafunction ntfs_delete_reparse_indexfunction ntfs_set_ntfs_reparse_datafunction ntfs_reparse_set_wsl_symlinkfunction ntfs_reparse_set_native_symlinkfunction ntfs_reparse_set_wsl_not_symlink
Annotated Snippet
struct wsl_link_reparse_data {
__le32 type;
char link[];
};
static bool reparse_name_is_valid(size_t size, size_t name_off, u16 len)
{
if ((name_off | len) & 1)
return false;
return name_off + len <= size;
}
/*
* Windows-native reparse payloads store pathnames as UTF-16 strings with '\\'
* separators. Convert the on-disk UTF-16 target into the mount's NLS and
* normalize path separators.
*/
static int ntfs_reparse_target_to_nls(struct ntfs_volume *vol,
const __le16 *uname, u16 ulen,
char **target)
{
int err, i;
*target = NULL;
ulen >>= 1;
if (!ulen)
return -EINVAL;
if (!uname[ulen - 1])
ulen--;
err = ntfs_ucstonls(vol, uname, ulen, (unsigned char **)target, 0);
if (err < 0) {
ntfs_attr_name_free((unsigned char **)target);
return err;
}
for (i = 0; i < err; i++) {
if ((*target)[i] == '\\')
(*target)[i] = '/';
}
return 0;
}
/* Index entry in $Extend/$Reparse */
struct reparse_index {
struct index_entry_header header;
struct reparse_index_key key;
__le32 filling;
};
__le16 reparse_index_name[] = {cpu_to_le16('$'), cpu_to_le16('R'), 0};
/*
* Check if the reparse point attribute buffer is valid.
* Returns true if valid, false otherwise.
*/
static bool valid_reparse_buffer(struct ntfs_inode *ni,
const struct reparse_point *reparse_attr,
size_t size,
size_t payload_min_len)
{
size_t expected;
if (!ni || !reparse_attr)
return false;
/* Minimum size must cover reparse_point header */
if (size < sizeof(struct reparse_point))
return false;
/* The payload must contain the fixed fields for the current tag. */
if (payload_min_len &&
le16_to_cpu(reparse_attr->reparse_data_length) < payload_min_len)
return false;
/* Reserved zero tag is invalid */
if (reparse_attr->reparse_tag == IO_REPARSE_TAG_RESERVED_ZERO)
return false;
/* Calculate expected total size */
expected = sizeof(struct reparse_point) +
le16_to_cpu(reparse_attr->reparse_data_length);
/* Add GUID size for non-Microsoft tags */
if (!(reparse_attr->reparse_tag & IO_REPARSE_TAG_IS_MICROSOFT))
expected += sizeof(struct guid);
Annotation
- Immediate include surface: `ntfs.h`, `layout.h`, `attrib.h`, `inode.h`, `dir.h`, `volume.h`, `mft.h`, `index.h`.
- Detected declarations: `struct wsl_link_reparse_data`, `struct reparse_index`, `function reparse_name_is_valid`, `function ntfs_reparse_target_to_nls`, `function valid_reparse_buffer`, `function valid_reparse_data`, `function ntfs_reparse_tag_mode`, `function ntfs_make_symlink`, `function valid_reparse_data`, `function ntfs_reparse_tag_dt_types`.
- 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.