fs/smb/server/ndr.c
Source file repositories/reference/linux-study-clean/fs/smb/server/ndr.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/server/ndr.c- Extension
.c- Size
- 10011 bytes
- Lines
- 515
- 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.
- 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.hglob.hndr.h
Detected Declarations
function Copyrightfunction try_to_realloc_ndr_blobfunction ndr_write_int16function ndr_write_int32function ndr_write_int64function ndr_write_bytesfunction ndr_write_stringfunction ndr_read_stringfunction ndr_read_bytesfunction ndr_read_int16function ndr_read_int32function ndr_read_int64function ndr_encode_dos_attrfunction ndr_decode_dos_attrfunction ndr_encode_posix_acl_entryfunction ndr_encode_posix_aclfunction ndr_encode_v4_ntaclfunction ndr_decode_v4_ntacl
Annotated Snippet
if (acl->entries[i].type == SMB_ACL_USER) {
n->offset = ALIGN(n->offset, 8);
ret = ndr_write_int64(n, acl->entries[i].uid);
} else if (acl->entries[i].type == SMB_ACL_GROUP) {
n->offset = ALIGN(n->offset, 8);
ret = ndr_write_int64(n, acl->entries[i].gid);
}
if (ret)
return ret;
/* push permission */
ret = ndr_write_int32(n, acl->entries[i].perm);
}
return ret;
}
int ndr_encode_posix_acl(struct ndr *n,
struct mnt_idmap *idmap,
struct inode *inode,
struct xattr_smb_acl *acl,
struct xattr_smb_acl *def_acl)
{
unsigned int ref_id = 0x00020000;
int ret;
vfsuid_t vfsuid;
vfsgid_t vfsgid;
n->offset = 0;
n->length = 1024;
n->data = kzalloc(n->length, KSMBD_DEFAULT_GFP);
if (!n->data)
return -ENOMEM;
if (acl) {
/* ACL ACCESS */
ret = ndr_write_int32(n, ref_id);
ref_id += 4;
} else {
ret = ndr_write_int32(n, 0);
}
if (ret)
return ret;
if (def_acl) {
/* DEFAULT ACL ACCESS */
ret = ndr_write_int32(n, ref_id);
ref_id += 4;
} else {
ret = ndr_write_int32(n, 0);
}
if (ret)
return ret;
vfsuid = i_uid_into_vfsuid(idmap, inode);
ret = ndr_write_int64(n, from_kuid(&init_user_ns, vfsuid_into_kuid(vfsuid)));
if (ret)
return ret;
vfsgid = i_gid_into_vfsgid(idmap, inode);
ret = ndr_write_int64(n, from_kgid(&init_user_ns, vfsgid_into_kgid(vfsgid)));
if (ret)
return ret;
ret = ndr_write_int32(n, inode->i_mode);
if (ret)
return ret;
if (acl) {
ret = ndr_encode_posix_acl_entry(n, acl);
if (def_acl && !ret)
ret = ndr_encode_posix_acl_entry(n, def_acl);
}
return ret;
}
int ndr_encode_v4_ntacl(struct ndr *n, struct xattr_ntacl *acl)
{
unsigned int ref_id = 0x00020004;
int ret;
n->offset = 0;
n->length = 2048;
n->data = kzalloc(n->length, KSMBD_DEFAULT_GFP);
if (!n->data)
return -ENOMEM;
ret = ndr_write_int16(n, acl->version);
if (ret)
return ret;
ret = ndr_write_int32(n, acl->version);
Annotation
- Immediate include surface: `linux/fs.h`, `glob.h`, `ndr.h`.
- Detected declarations: `function Copyright`, `function try_to_realloc_ndr_blob`, `function ndr_write_int16`, `function ndr_write_int32`, `function ndr_write_int64`, `function ndr_write_bytes`, `function ndr_write_string`, `function ndr_read_string`, `function ndr_read_bytes`, `function ndr_read_int16`.
- 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.