fs/nfsd/nfs3xdr.c
Source file repositories/reference/linux-study-clean/fs/nfsd/nfs3xdr.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfsd/nfs3xdr.c- Extension
.c- Size
- 31953 bytes
- Lines
- 1357
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/namei.hlinux/sunrpc/svc_xprt.hxdr3.hauth.hnetns.hvfs.h
Detected Declarations
function typesfunction svcxdr_decode_nfstime3function svcxdr_decode_nfs_fh3function svcxdr_encode_nfsstat3function svcxdr_encode_nfs_fh3function svcxdr_encode_post_op_fh3function svcxdr_encode_cookieverf3function svcxdr_encode_writeverf3function svcxdr_decode_filename3function svcxdr_decode_diropargs3function svcxdr_decode_sattr3function svcxdr_decode_sattrguard3function svcxdr_decode_specdata3function svcxdr_decode_devicedata3function svcxdr_encode_fattr3function svcxdr_encode_wcc_attrfunction svcxdr_encode_pre_op_attrfunction svcxdr_encode_post_op_attrfunction svcxdr_encode_wcc_datafunction nfs3svc_decode_fhandleargsfunction nfs3svc_decode_sattrargsfunction nfs3svc_decode_diropargsfunction nfs3svc_decode_accessargsfunction nfs3svc_decode_readargsfunction nfs3svc_decode_writeargsfunction nfs3svc_decode_createargsfunction nfs3svc_decode_mkdirargsfunction nfs3svc_decode_symlinkargsfunction nfs3svc_decode_mknodargsfunction nfs3svc_decode_renameargsfunction nfs3svc_decode_linkargsfunction nfs3svc_decode_readdirargsfunction nfs3svc_decode_readdirplusargsfunction nfs3svc_decode_commitargsfunction nfs3svc_encode_getattrresfunction nfs3svc_encode_wccstatfunction nfs3svc_encode_lookupresfunction nfs3svc_encode_accessresfunction nfs3svc_encode_readlinkresfunction nfs3svc_encode_readresfunction nfs3svc_encode_writeresfunction nfs3svc_encode_createresfunction nfs3svc_encode_renameresfunction nfs3svc_encode_linkresfunction nfs3svc_encode_readdirresfunction compose_entry_fhfunction svcxdr_encode_entry3_commonfunction svcxdr_encode_entry3_common
Annotated Snippet
if (namlen == 2) {
dchild = dget_parent(dparent);
/*
* Don't return filehandle for ".." if we're at
* the filesystem or export root:
*/
if (dchild == dparent)
goto out;
if (dparent == exp->ex_path.dentry)
goto out;
} else
dchild = dget(dparent);
} else
dchild = lookup_one_positive_unlocked(&nop_mnt_idmap,
&QSTR_LEN(name, namlen),
dparent);
if (IS_ERR(dchild))
return rv;
if (d_mountpoint(dchild))
goto out;
if (dchild->d_inode->i_ino != ino)
goto out;
rv = fh_compose(fhp, exp, dchild, &cd->fh);
out:
dput(dchild);
return rv;
}
/**
* nfs3svc_encode_cookie3 - Encode a directory offset cookie
* @resp: readdir result context
* @offset: offset cookie to encode
*
* The buffer space for the offset cookie has already been reserved
* by svcxdr_encode_entry3_common().
*/
void nfs3svc_encode_cookie3(struct nfsd3_readdirres *resp, u64 offset)
{
__be64 cookie = cpu_to_be64(offset);
if (!resp->cookie_offset)
return;
write_bytes_to_xdr_buf(&resp->dirlist, resp->cookie_offset, &cookie,
sizeof(cookie));
resp->cookie_offset = 0;
}
static bool
svcxdr_encode_entry3_common(struct nfsd3_readdirres *resp, const char *name,
int namlen, loff_t offset, u64 ino)
{
struct xdr_buf *dirlist = &resp->dirlist;
struct xdr_stream *xdr = &resp->xdr;
if (xdr_stream_encode_item_present(xdr) < 0)
return false;
/* fileid */
if (xdr_stream_encode_u64(xdr, ino) < 0)
return false;
/* name */
if (xdr_stream_encode_opaque(xdr, name, min(namlen, NFS3_MAXNAMLEN)) < 0)
return false;
/* cookie */
resp->cookie_offset = dirlist->len;
if (xdr_stream_encode_u64(xdr, OFFSET_MAX) < 0)
return false;
return true;
}
/**
* nfs3svc_encode_entry3 - encode one NFSv3 READDIR entry
* @data: directory context
* @name: name of the object to be encoded
* @namlen: length of that name, in bytes
* @offset: the offset of the previous entry
* @ino: the fileid of this entry
* @d_type: unused
*
* Return values:
* %0: Entry was successfully encoded.
* %-EINVAL: An encoding problem occurred, secondary status code in resp->common.err
*
* On exit, the following fields are updated:
* - resp->xdr
* - resp->common.err
* - resp->cookie_offset
*/
int nfs3svc_encode_entry3(void *data, const char *name, int namlen,
loff_t offset, u64 ino, unsigned int d_type)
Annotation
- Immediate include surface: `linux/namei.h`, `linux/sunrpc/svc_xprt.h`, `xdr3.h`, `auth.h`, `netns.h`, `vfs.h`.
- Detected declarations: `function types`, `function svcxdr_decode_nfstime3`, `function svcxdr_decode_nfs_fh3`, `function svcxdr_encode_nfsstat3`, `function svcxdr_encode_nfs_fh3`, `function svcxdr_encode_post_op_fh3`, `function svcxdr_encode_cookieverf3`, `function svcxdr_encode_writeverf3`, `function svcxdr_decode_filename3`, `function svcxdr_decode_diropargs3`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.