fs/vboxsf/utils.c
Source file repositories/reference/linux-study-clean/fs/vboxsf/utils.c
File Facts
- System
- Linux kernel
- Corpus path
fs/vboxsf/utils.c- Extension
.c- Size
- 13645 bytes
- Lines
- 600
- 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/namei.hlinux/nls.hlinux/sizes.hlinux/pagemap.hlinux/vfs.hlinux/fileattr.hvfsmod.h
Detected Declarations
function Copyrightfunction vboxsf_init_inodefunction vboxsf_create_at_dentryfunction vboxsf_statfunction vboxsf_stat_dentryfunction vboxsf_inode_revalidatefunction vboxsf_getattrfunction vboxsf_setattrfunction __getnamefunction vboxsf_nlscpyfunction vboxsf_dir_buf_freefunction vboxsf_dir_info_freefunction vboxsf_dir_read_allfunction vboxsf_query_case_sensitivefunction vboxsf_fileattr_get
Annotated Snippet
if (!reinit) {
inode->i_op = &vboxsf_dir_iops;
inode->i_fop = &vboxsf_dir_fops;
/*
* XXX: this probably should be set to the number of entries
* in the directory plus two (. ..)
*/
set_nlink(inode, 1);
} else if (!S_ISDIR(inode->i_mode))
return -ESTALE;
inode->i_mode = mode;
} else if (SHFL_IS_SYMLINK(attr->mode)) {
if (sbi->o.fmode_set)
mode = sbi->o.fmode;
mode &= ~sbi->o.fmask;
mode |= S_IFLNK;
if (!reinit) {
inode->i_op = &vboxsf_lnk_iops;
set_nlink(inode, 1);
} else if (!S_ISLNK(inode->i_mode))
return -ESTALE;
inode->i_mode = mode;
} else {
if (sbi->o.fmode_set)
mode = sbi->o.fmode;
mode &= ~sbi->o.fmask;
mode |= S_IFREG;
if (!reinit) {
inode->i_op = &vboxsf_reg_iops;
inode->i_fop = &vboxsf_reg_fops;
set_nlink(inode, 1);
} else if (!S_ISREG(inode->i_mode))
return -ESTALE;
inode->i_mode = mode;
}
inode->i_uid = sbi->o.uid;
inode->i_gid = sbi->o.gid;
inode->i_size = info->size;
inode->i_blkbits = 12;
/* i_blocks always in units of 512 bytes! */
allocated = info->allocated + 511;
do_div(allocated, 512);
inode->i_blocks = allocated;
inode_set_atime_to_ts(inode,
ns_to_timespec64(info->access_time.ns_relative_to_unix_epoch));
inode_set_ctime_to_ts(inode,
ns_to_timespec64(info->change_time.ns_relative_to_unix_epoch));
inode_set_mtime_to_ts(inode,
ns_to_timespec64(info->modification_time.ns_relative_to_unix_epoch));
return 0;
}
int vboxsf_create_at_dentry(struct dentry *dentry,
struct shfl_createparms *params)
{
struct vboxsf_sbi *sbi = VBOXSF_SBI(dentry->d_sb);
struct shfl_string *path;
int err;
path = vboxsf_path_from_dentry(sbi, dentry);
if (IS_ERR(path))
return PTR_ERR(path);
err = vboxsf_create(sbi->root, path, params);
__putname(path);
return err;
}
int vboxsf_stat(struct vboxsf_sbi *sbi, struct shfl_string *path,
struct shfl_fsobjinfo *info)
{
struct shfl_createparms params = {};
int err;
params.handle = SHFL_HANDLE_NIL;
params.create_flags = SHFL_CF_LOOKUP | SHFL_CF_ACT_FAIL_IF_NEW;
err = vboxsf_create(sbi->root, path, ¶ms);
if (err)
return err;
if (params.result != SHFL_FILE_EXISTS)
return -ENOENT;
if (info)
*info = params.info;
Annotation
- Immediate include surface: `linux/namei.h`, `linux/nls.h`, `linux/sizes.h`, `linux/pagemap.h`, `linux/vfs.h`, `linux/fileattr.h`, `vfsmod.h`.
- Detected declarations: `function Copyright`, `function vboxsf_init_inode`, `function vboxsf_create_at_dentry`, `function vboxsf_stat`, `function vboxsf_stat_dentry`, `function vboxsf_inode_revalidate`, `function vboxsf_getattr`, `function vboxsf_setattr`, `function __getname`, `function vboxsf_nlscpy`.
- 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.