fs/smb/client/dfs.c
Source file repositories/reference/linux-study-clean/fs/smb/client/dfs.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/client/dfs.c- Extension
.c- Size
- 11560 bytes
- Lines
- 468
- 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
cifsproto.hcifs_debug.hdns_resolve.hfs_context.hdfs.h
Detected Declarations
function Copyrightfunction get_sessionfunction set_root_smb_sessionfunction parse_dfs_targetfunction setup_dfs_reffunction __dfs_referral_walkfunction dfs_referral_walkfunction __dfs_mount_sharefunction mountfunction dfs_mount_sharefunction referralfunction target_share_matches_serverfunction strncasecmpfunction tree_connect_dfs_targetfunction cifs_tree_connectfunction dfs_cache_noreq_find
Annotated Snippet
while (ref_walk_next_tgt(rw)) {
rc = parse_dfs_target(ctx, rw, &tgt);
if (rc)
continue;
cifs_mount_put_conns(mnt_ctx);
rc = get_session(mnt_ctx, ref_walk_path(rw));
if (rc)
continue;
rc = cifs_mount_get_tcon(mnt_ctx);
if (rc) {
if (tgt.server_type == DFS_TYPE_LINK &&
DFS_INTERLINK(tgt.flags))
rc = -EREMOTE;
} else {
rc = cifs_is_path_remote(mnt_ctx);
if (!rc) {
ref_walk_set_tgt_hint(rw);
break;
}
}
if (rc == -EREMOTE) {
rc = ref_walk_advance(rw);
if (!rc) {
rc = setup_dfs_ref(&tgt, rw);
if (rc)
break;
ref_walk_mark_end(rw);
goto again;
}
}
}
} while (rc && ref_walk_descend(rw));
free_dfs_info_param(&tgt);
return rc;
}
static int dfs_referral_walk(struct cifs_mount_ctx *mnt_ctx,
struct dfs_ref_walk **rw)
{
int rc;
*rw = ref_walk_alloc();
if (IS_ERR(*rw)) {
rc = PTR_ERR(*rw);
*rw = NULL;
return rc;
}
ref_walk_init(*rw, mnt_ctx);
rc = setup_dfs_ref(NULL, *rw);
if (!rc)
rc = __dfs_referral_walk(*rw);
return rc;
}
static int __dfs_mount_share(struct cifs_mount_ctx *mnt_ctx)
{
struct cifs_sb_info *cifs_sb = mnt_ctx->cifs_sb;
struct smb3_fs_context *ctx = mnt_ctx->fs_ctx;
struct dfs_ref_walk *rw = NULL;
struct cifs_tcon *tcon;
char *origin_fullpath;
int rc;
origin_fullpath = dfs_get_path(cifs_sb, ctx->source);
if (IS_ERR(origin_fullpath))
return PTR_ERR(origin_fullpath);
rc = dfs_referral_walk(mnt_ctx, &rw);
if (!rc) {
/*
* Prevent superblock from being created with any missing
* connections.
*/
if (WARN_ON(!mnt_ctx->server))
rc = -EHOSTDOWN;
else if (WARN_ON(!mnt_ctx->ses))
rc = -EACCES;
else if (WARN_ON(!mnt_ctx->tcon))
rc = -ENOENT;
}
if (rc)
goto out;
tcon = mnt_ctx->tcon;
spin_lock(&tcon->tc_lock);
tcon->origin_fullpath = origin_fullpath;
Annotation
- Immediate include surface: `cifsproto.h`, `cifs_debug.h`, `dns_resolve.h`, `fs_context.h`, `dfs.h`.
- Detected declarations: `function Copyright`, `function get_session`, `function set_root_smb_session`, `function parse_dfs_target`, `function setup_dfs_ref`, `function __dfs_referral_walk`, `function dfs_referral_walk`, `function __dfs_mount_share`, `function mount`, `function dfs_mount_share`.
- 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.