fs/smb/server/vfs.c
Source file repositories/reference/linux-study-clean/fs/smb/server/vfs.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/server/vfs.c- Extension
.c- Size
- 48936 bytes
- Lines
- 2030
- 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
crypto/sha2.hlinux/kernel.hlinux/fs.hlinux/filelock.hlinux/uaccess.hlinux/backing-dev.hlinux/writeback.hlinux/xattr.hlinux/falloc.hlinux/fsnotify.hlinux/dcache.hlinux/slab.hlinux/vmalloc.hlinux/sched/xacct.hlinux/crc32c.hlinux/splice.hlinux/fileattr.hglob.hoplock.hconnection.hvfs.hvfs_cache.hsmbacl.hndr.hauth.hmisc.hstats.hsmb_common.hmgmt/share_config.hmgmt/tree_connect.hmgmt/user_session.hmgmt/user_config.h
Detected Declarations
function Copyrightfunction ksmbd_vfs_path_lookupfunction ksmbd_vfs_query_maximal_accessfunction ksmbd_vfs_createfunction ksmbd_vfs_mkdirfunction ksmbd_vfs_getcasexattrfunction ksmbd_vfs_stream_readfunction check_lock_rangefunction ksmbd_vfs_readfunction ksmbd_vfs_stream_writefunction ksmbd_vfs_writefunction ksmbd_vfs_getattrfunction ksmbd_vfs_fsyncfunction ksmbd_vfs_remove_filefunction ksmbd_vfs_linkfunction ksmbd_vfs_renamefunction ksmbd_vfs_truncatefunction ksmbd_vfs_listxattrfunction ksmbd_vfs_xattr_lenfunction ksmbd_vfs_getxattrfunction ksmbd_vfs_setxattrfunction ksmbd_vfs_set_fadvisefunction ksmbd_vfs_zero_datafunction ksmbd_vfs_fqar_lseekfunction ksmbd_vfs_remove_xattrfunction ksmbd_vfs_unlinkfunction __dir_emptyfunction ksmbd_vfs_empty_dirfunction __caseless_lookupfunction ksmbd_vfs_lookup_in_dirfunction __ksmbd_vfs_kern_pathfunction ksmbd_vfs_kern_pathfunction ksmbd_vfs_kern_path_start_removingfunction ksmbd_vfs_kern_path_end_removingfunction ksmbd_vfs_remove_acl_xattrsfunction ksmbd_vfs_remove_sd_xattrsfunction ksmbd_vfs_set_sd_xattrfunction ksmbd_vfs_get_sd_xattrfunction ksmbd_vfs_set_dos_attrib_xattrfunction ksmbd_vfs_get_dos_attrib_xattrfunction ksmbd_vfs_init_kstatfunction ksmbd_vfs_fill_dentry_attrsfunction ksmbd_vfs_casexattr_lenfunction ksmbd_vfs_xattr_stream_namefunction ksmbd_vfs_copy_file_rangesfunction ksmbd_vfs_posix_lock_waitfunction ksmbd_vfs_posix_lock_unblockfunction ksmbd_vfs_set_init_posix_acl
Annotated Snippet
if (err) {
path_put(path);
return -ENOENT;
}
d = start_removing_noperm(path->dentry, &last);
if (!IS_ERR(d)) {
dput(path->dentry);
path->dentry = d;
return 0;
}
mnt_drop_write(path->mnt);
path_put(path);
return -ENOENT;
}
d = lookup_noperm_unlocked(&last, path->dentry);
if (!IS_ERR(d) && d_is_negative(d)) {
dput(d);
d = ERR_PTR(-ENOENT);
}
if (IS_ERR(d)) {
path_put(path);
return -ENOENT;
}
dput(path->dentry);
path->dentry = d;
if (test_share_config_flag(share_conf, KSMBD_SHARE_FLAG_CROSSMNT)) {
err = follow_down(path, 0);
if (err < 0) {
path_put(path);
return -ENOENT;
}
}
return 0;
}
void ksmbd_vfs_query_maximal_access(struct mnt_idmap *idmap,
struct dentry *dentry, __le32 *daccess)
{
*daccess = cpu_to_le32(FILE_READ_ATTRIBUTES | READ_CONTROL);
if (!inode_permission(idmap, d_inode(dentry), MAY_OPEN | MAY_WRITE))
*daccess |= cpu_to_le32(WRITE_DAC | WRITE_OWNER | SYNCHRONIZE |
FILE_WRITE_DATA | FILE_APPEND_DATA |
FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES |
FILE_DELETE_CHILD);
if (!inode_permission(idmap, d_inode(dentry), MAY_OPEN | MAY_READ))
*daccess |= FILE_READ_DATA_LE | FILE_READ_EA_LE;
if (!inode_permission(idmap, d_inode(dentry), MAY_OPEN | MAY_EXEC))
*daccess |= FILE_EXECUTE_LE;
if (!inode_permission(idmap, d_inode(dentry->d_parent), MAY_EXEC | MAY_WRITE))
*daccess |= FILE_DELETE_LE;
}
/**
* ksmbd_vfs_create() - vfs helper for smb create file
* @work: work
* @name: file name that is relative to share
* @mode: file create mode
*
* Return: 0 on success, otherwise error
*/
int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode)
{
struct path path;
struct dentry *dentry;
int err;
dentry = ksmbd_vfs_kern_path_create(work, name,
LOOKUP_NO_SYMLINKS, &path);
if (IS_ERR(dentry)) {
err = PTR_ERR(dentry);
if (err != -ENOENT)
pr_err("path create failed for %s, err %d\n",
name, err);
return err;
}
mode |= S_IFREG;
err = vfs_create(mnt_idmap(path.mnt), dentry, mode, NULL);
if (!err) {
ksmbd_vfs_inherit_owner(work, d_inode(path.dentry),
d_inode(dentry));
} else {
Annotation
- Immediate include surface: `crypto/sha2.h`, `linux/kernel.h`, `linux/fs.h`, `linux/filelock.h`, `linux/uaccess.h`, `linux/backing-dev.h`, `linux/writeback.h`, `linux/xattr.h`.
- Detected declarations: `function Copyright`, `function ksmbd_vfs_path_lookup`, `function ksmbd_vfs_query_maximal_access`, `function ksmbd_vfs_create`, `function ksmbd_vfs_mkdir`, `function ksmbd_vfs_getcasexattr`, `function ksmbd_vfs_stream_read`, `function check_lock_range`, `function ksmbd_vfs_read`, `function ksmbd_vfs_stream_write`.
- 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.