fs/freevxfs/vxfs_lookup.c
Source file repositories/reference/linux-study-clean/fs/freevxfs/vxfs_lookup.c
File Facts
- System
- Linux kernel
- Corpus path
fs/freevxfs/vxfs_lookup.c- Extension
.c- Size
- 6061 bytes
- Lines
- 274
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/filelock.hlinux/time.hlinux/mm.hlinux/highmem.hlinux/kernel.hlinux/pagemap.hvxfs.hvxfs_dir.hvxfs_inode.hvxfs_extern.h
Detected Declarations
function vxfs_find_entryfunction vxfs_inode_by_namefunction vxfs_lookupfunction vxfs_readdir
Annotated Snippet
const struct file_operations vxfs_dir_operations = {
.llseek = generic_file_llseek,
.read = generic_read_dir,
.iterate_shared = vxfs_readdir,
.setlease = generic_setlease,
};
/**
* vxfs_find_entry - find a mathing directory entry for a dentry
* @ip: directory inode
* @dp: dentry for which we want to find a direct
* @ppp: gets filled with the page the return value sits in
*
* Description:
* vxfs_find_entry finds a &struct vxfs_direct for the VFS directory
* cache entry @dp. @ppp will be filled with the page the return
* value resides in.
*
* Returns:
* The wanted direct on success, else a NULL pointer.
*/
static struct vxfs_direct *
vxfs_find_entry(struct inode *ip, struct dentry *dp, struct page **ppp)
{
u_long bsize = ip->i_sb->s_blocksize;
const char *name = dp->d_name.name;
int namelen = dp->d_name.len;
loff_t limit = VXFS_DIRROUND(ip->i_size);
struct vxfs_direct *de_exit = NULL;
loff_t pos = 0;
struct vxfs_sb_info *sbi = VXFS_SBI(ip->i_sb);
while (pos < limit) {
struct page *pp;
char *kaddr;
int pg_ofs = pos & ~PAGE_MASK;
pp = vxfs_get_page(ip->i_mapping, pos >> PAGE_SHIFT);
if (IS_ERR(pp))
return NULL;
kaddr = (char *)page_address(pp);
while (pg_ofs < PAGE_SIZE && pos < limit) {
struct vxfs_direct *de;
if ((pos & (bsize - 1)) < 4) {
struct vxfs_dirblk *dbp =
(struct vxfs_dirblk *)
(kaddr + (pos & ~PAGE_MASK));
int overhead = VXFS_DIRBLKOV(sbi, dbp);
pos += overhead;
pg_ofs += overhead;
}
de = (struct vxfs_direct *)(kaddr + pg_ofs);
if (!de->d_reclen) {
pos += bsize - 1;
pos &= ~(bsize - 1);
break;
}
pg_ofs += fs16_to_cpu(sbi, de->d_reclen);
pos += fs16_to_cpu(sbi, de->d_reclen);
if (!de->d_ino)
continue;
if (namelen != fs16_to_cpu(sbi, de->d_namelen))
continue;
if (!memcmp(name, de->d_name, namelen)) {
*ppp = pp;
de_exit = de;
break;
}
}
if (!de_exit)
vxfs_put_page(pp);
else
break;
}
return de_exit;
}
/**
* vxfs_inode_by_name - find inode number for dentry
* @dip: directory to search in
* @dp: dentry we search for
*
Annotation
- Immediate include surface: `linux/fs.h`, `linux/filelock.h`, `linux/time.h`, `linux/mm.h`, `linux/highmem.h`, `linux/kernel.h`, `linux/pagemap.h`, `vxfs.h`.
- Detected declarations: `function vxfs_find_entry`, `function vxfs_inode_by_name`, `function vxfs_lookup`, `function vxfs_readdir`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern 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.