fs/smb/client/dns_resolve.c
Source file repositories/reference/linux-study-clean/fs/smb/client/dns_resolve.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/client/dns_resolve.c- Extension
.c- Size
- 2570 bytes
- Lines
- 97
- 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/inet.hlinux/slab.hlinux/dns_resolver.hdns_resolve.hcifsglob.hcifsproto.hcifs_debug.h
Detected Declarations
function Copyrightfunction dns_resolve_name
Annotated Snippet
if (!rc) {
cifs_dbg(FYI, "%s: unable to determine ip address\n",
__func__);
rc = -EHOSTUNREACH;
} else {
rc = 0;
}
}
return rc;
}
/**
* dns_resolve_name - Perform an upcall to resolve hostname to an ip address.
* @dom: DNS domain name (or NULL)
* @name: Name to look up
* @namelen: Length of name
* @ip_addr: Where to return the IP address
*
* Returns zero on success, -ve code otherwise.
*/
int dns_resolve_name(const char *dom, const char *name,
size_t namelen, struct sockaddr *ip_addr)
{
size_t len;
char *s;
int rc;
cifs_dbg(FYI, "%s: dom=%s name=%.*s\n", __func__, dom, (int)namelen, name);
if (!ip_addr || !name || !*name || !namelen)
return -EINVAL;
cifs_dbg(FYI, "%s: hostname=%.*s\n", __func__, (int)namelen, name);
/* Try to interpret hostname as an IPv4 or IPv6 address */
rc = cifs_convert_address(ip_addr, name, namelen);
if (rc > 0) {
cifs_dbg(FYI, "%s: unc is IP, skipping dns upcall: %*.*s\n",
__func__, (int)namelen, (int)namelen, name);
return 0;
}
/*
* If @name contains a NetBIOS name and @dom has been specified, then
* convert @name to an FQDN and try resolving it first.
*/
if (dom && *dom && cifs_netbios_name(name, namelen)) {
len = strnlen(dom, CIFS_MAX_DOMAINNAME_LEN) + namelen + 2;
s = kmalloc(len, GFP_KERNEL);
if (!s)
return -ENOMEM;
scnprintf(s, len, "%.*s.%s", (int)namelen, name, dom);
rc = resolve_name(s, len - 1, ip_addr);
kfree(s);
if (!rc)
return 0;
}
return resolve_name(name, namelen, ip_addr);
}
Annotation
- Immediate include surface: `linux/inet.h`, `linux/slab.h`, `linux/dns_resolver.h`, `dns_resolve.h`, `cifsglob.h`, `cifsproto.h`, `cifs_debug.h`.
- Detected declarations: `function Copyright`, `function dns_resolve_name`.
- 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.