fs/nfsd/vfs.c
Source file repositories/reference/linux-study-clean/fs/nfsd/vfs.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfsd/vfs.c- Extension
.c- Size
- 78977 bytes
- Lines
- 2988
- 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/fs.hlinux/file.hlinux/splice.hlinux/falloc.hlinux/fcntl.hlinux/namei.hlinux/delay.hlinux/fsnotify.hlinux/posix_acl_xattr.hlinux/xattr.hlinux/jhash.hlinux/pagemap.hlinux/slab.hlinux/uaccess.hlinux/exportfs.hlinux/writeback.hlinux/security.hlinux/sunrpc/xdr.hlinux/fileattr.hxdr3.hacl.hidmap.hxdr4.hnfsd.hvfs.hfilecache.htrace.h
Detected Declarations
struct accessmapstruct nfsd_write_dio_segstruct buffered_direntstruct readdir_datafunction appropriatefunction nfsd_cross_mntfunction nfsd_mountpointfunction follow_to_parentfunction nfsd_lookup_parentfunction nfsd_mountpointfunction nfsd_lookup_dentryfunction nfsd_lookupfunction commit_reset_write_verifierfunction commit_inode_metadatafunction commit_metadatafunction nfsd_sanitize_attrsfunction nfsd_get_write_accessfunction __nfsd_setattrfunction nfsd_setattrfunction utimesfunction nfsd4_is_junctionfunction nfsd4_clone_file_rangefunction nfsd_copy_file_rangefunction nfsd4_vfs_fallocatefunction nfsd_accessfunction nfsd_open_break_leasefunction openfunction nfsd_openfunction nfsd_open_verifiedfunction nfsd_splice_actorfunction nfsd_direct_splice_actorfunction nfsd_eof_on_readfunction nfsd_finish_readfunction nfsd_splice_readfunction nfsd_direct_readfunction nfsd_iter_readfunction toolfunction iov_iter_bvec_offsetfunction nfsd_write_dio_seg_initfunction nfsd_write_dio_iters_initfunction nfsd_direct_writefunction nfsd_vfs_writefunction nfsd_read_splice_okfunction nfsd_readfunction nfsd_writefunction nfsd_commitfunction nfsd_create_setattrfunction resizing
Annotated Snippet
struct accessmap {
u32 access;
int how;
};
static struct accessmap nfs3_regaccess[] = {
{ NFS3_ACCESS_READ, NFSD_MAY_READ },
{ NFS3_ACCESS_EXECUTE, NFSD_MAY_EXEC },
{ NFS3_ACCESS_MODIFY, NFSD_MAY_WRITE|NFSD_MAY_TRUNC },
{ NFS3_ACCESS_EXTEND, NFSD_MAY_WRITE },
#ifdef CONFIG_NFSD_V4
{ NFS4_ACCESS_XAREAD, NFSD_MAY_READ },
{ NFS4_ACCESS_XAWRITE, NFSD_MAY_WRITE },
{ NFS4_ACCESS_XALIST, NFSD_MAY_READ },
#endif
{ 0, 0 }
};
static struct accessmap nfs3_diraccess[] = {
{ NFS3_ACCESS_READ, NFSD_MAY_READ },
{ NFS3_ACCESS_LOOKUP, NFSD_MAY_EXEC },
{ NFS3_ACCESS_MODIFY, NFSD_MAY_EXEC|NFSD_MAY_WRITE|NFSD_MAY_TRUNC},
{ NFS3_ACCESS_EXTEND, NFSD_MAY_EXEC|NFSD_MAY_WRITE },
{ NFS3_ACCESS_DELETE, NFSD_MAY_REMOVE },
#ifdef CONFIG_NFSD_V4
{ NFS4_ACCESS_XAREAD, NFSD_MAY_READ },
{ NFS4_ACCESS_XAWRITE, NFSD_MAY_WRITE },
{ NFS4_ACCESS_XALIST, NFSD_MAY_READ },
#endif
{ 0, 0 }
};
static struct accessmap nfs3_anyaccess[] = {
/* Some clients - Solaris 2.6 at least, make an access call
* to the server to check for access for things like /dev/null
* (which really, the server doesn't care about). So
* We provide simple access checking for them, looking
* mainly at mode bits, and we make sure to ignore read-only
* filesystem checks
*/
{ NFS3_ACCESS_READ, NFSD_MAY_READ },
{ NFS3_ACCESS_EXECUTE, NFSD_MAY_EXEC },
{ NFS3_ACCESS_MODIFY, NFSD_MAY_WRITE|NFSD_MAY_LOCAL_ACCESS },
{ NFS3_ACCESS_EXTEND, NFSD_MAY_WRITE|NFSD_MAY_LOCAL_ACCESS },
{ 0, 0 }
};
__be32
nfsd_access(struct svc_rqst *rqstp, struct svc_fh *fhp, u32 *access, u32 *supported)
{
struct accessmap *map;
struct svc_export *export;
struct dentry *dentry;
u32 query, result = 0, sresult = 0;
__be32 error;
error = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP);
if (error)
goto out;
export = fhp->fh_export;
dentry = fhp->fh_dentry;
if (d_is_reg(dentry))
map = nfs3_regaccess;
else if (d_is_dir(dentry))
map = nfs3_diraccess;
else
map = nfs3_anyaccess;
query = *access;
for (; map->access; map++) {
if (map->access & query) {
__be32 err2;
sresult |= map->access;
err2 = nfsd_permission(&rqstp->rq_cred, export,
dentry, map->how);
switch (err2) {
case nfs_ok:
result |= map->access;
break;
/* the following error codes just mean the access was not allowed,
Annotation
- Immediate include surface: `linux/fs.h`, `linux/file.h`, `linux/splice.h`, `linux/falloc.h`, `linux/fcntl.h`, `linux/namei.h`, `linux/delay.h`, `linux/fsnotify.h`.
- Detected declarations: `struct accessmap`, `struct nfsd_write_dio_seg`, `struct buffered_dirent`, `struct readdir_data`, `function appropriate`, `function nfsd_cross_mnt`, `function nfsd_mountpoint`, `function follow_to_parent`, `function nfsd_lookup_parent`, `function nfsd_mountpoint`.
- 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.