fs/vboxsf/dir.c
Source file repositories/reference/linux-study-clean/fs/vboxsf/dir.c
File Facts
- System
- Linux kernel
- Corpus path
fs/vboxsf/dir.c- Extension
.c- Size
- 11913 bytes
- Lines
- 482
- 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.
- 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/namei.hlinux/vbox_utils.hvfsmod.h
Detected Declarations
function Copyrightfunction vboxsf_dir_releasefunction vboxsf_get_d_typefunction vboxsf_dir_emitfunction list_for_each_entryfunction vboxsf_dir_iteratefunction vboxsf_dentry_revalidatefunction vboxsf_dir_instantiatefunction vboxsf_dir_createfunction vboxsf_dir_mkfilefunction vboxsf_dir_atomic_openfunction vboxsf_dir_unlinkfunction vboxsf_dir_renamefunction vboxsf_dir_symlink
Annotated Snippet
const struct file_operations vboxsf_dir_fops = {
.open = vboxsf_dir_open,
.iterate_shared = shared_vboxsf_dir_iterate,
.release = vboxsf_dir_release,
.read = generic_read_dir,
.llseek = generic_file_llseek,
};
/*
* This is called during name resolution/lookup to check if the @dentry in
* the cache is still valid. the job is handled by vboxsf_inode_revalidate.
*/
static int vboxsf_dentry_revalidate(struct inode *dir, const struct qstr *name,
struct dentry *dentry, unsigned int flags)
{
if (flags & LOOKUP_RCU)
return -ECHILD;
if (d_really_is_positive(dentry))
return vboxsf_inode_revalidate(dentry) == 0;
else
return vboxsf_stat_dentry(dentry, NULL) == -ENOENT;
}
const struct dentry_operations vboxsf_dentry_ops = {
.d_revalidate = vboxsf_dentry_revalidate
};
/* iops */
static struct dentry *vboxsf_dir_lookup(struct inode *parent,
struct dentry *dentry,
unsigned int flags)
{
struct vboxsf_sbi *sbi = VBOXSF_SBI(parent->i_sb);
struct shfl_fsobjinfo fsinfo;
struct inode *inode;
int err;
dentry->d_time = jiffies;
err = vboxsf_stat_dentry(dentry, &fsinfo);
if (err) {
inode = (err == -ENOENT) ? NULL : ERR_PTR(err);
} else {
inode = vboxsf_new_inode(parent->i_sb);
if (!IS_ERR(inode))
vboxsf_init_inode(sbi, inode, &fsinfo, false);
}
return d_splice_alias(inode, dentry);
}
static int vboxsf_dir_instantiate(struct inode *parent, struct dentry *dentry,
struct shfl_fsobjinfo *info)
{
struct vboxsf_sbi *sbi = VBOXSF_SBI(parent->i_sb);
struct vboxsf_inode *sf_i;
struct inode *inode;
inode = vboxsf_new_inode(parent->i_sb);
if (IS_ERR(inode))
return PTR_ERR(inode);
sf_i = VBOXSF_I(inode);
/* The host may have given us different attr then requested */
sf_i->force_restat = 1;
vboxsf_init_inode(sbi, inode, info, false);
d_instantiate(dentry, inode);
return 0;
}
static int vboxsf_dir_create(struct inode *parent, struct dentry *dentry,
umode_t mode, bool is_dir, bool excl, u64 *handle_ret)
{
struct vboxsf_inode *sf_parent_i = VBOXSF_I(parent);
struct vboxsf_sbi *sbi = VBOXSF_SBI(parent->i_sb);
struct shfl_createparms params = {};
int err;
params.handle = SHFL_HANDLE_NIL;
params.create_flags = SHFL_CF_ACT_CREATE_IF_NEW | SHFL_CF_ACCESS_READWRITE;
if (is_dir)
params.create_flags |= SHFL_CF_DIRECTORY;
if (excl)
params.create_flags |= SHFL_CF_ACT_FAIL_IF_EXISTS;
params.info.attr.mode = (mode & 0777) |
Annotation
- Immediate include surface: `linux/namei.h`, `linux/vbox_utils.h`, `vfsmod.h`.
- Detected declarations: `function Copyright`, `function vboxsf_dir_release`, `function vboxsf_get_d_type`, `function vboxsf_dir_emit`, `function list_for_each_entry`, `function vboxsf_dir_iterate`, `function vboxsf_dentry_revalidate`, `function vboxsf_dir_instantiate`, `function vboxsf_dir_create`, `function vboxsf_dir_mkfile`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern 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.