1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2022 Paulo Alcantara <palcantara@suse.de>
4  */
5 
6 #ifndef _CIFS_DFS_H
7 #define _CIFS_DFS_H
8 
9 #include "cifsglob.h"
10 #include "fs_context.h"
11 #include "cifs_unicode.h"
12 
13 int dfs_parse_target_referral(const char *full_path, const struct dfs_info3_param *ref,
14 			      struct smb3_fs_context *ctx);
15 int dfs_mount_share(struct cifs_mount_ctx *mnt_ctx, bool *isdfs);
16 
dfs_get_path(struct cifs_sb_info * cifs_sb,const char * path)17 static inline char *dfs_get_path(struct cifs_sb_info *cifs_sb, const char *path)
18 {
19 	return dfs_cache_canonical_path(path, cifs_sb->local_nls, cifs_remap(cifs_sb));
20 }
21 
dfs_get_referral(struct cifs_mount_ctx * mnt_ctx,const char * path,struct dfs_info3_param * ref,struct dfs_cache_tgt_list * tl)22 static inline int dfs_get_referral(struct cifs_mount_ctx *mnt_ctx, const char *path,
23 				   struct dfs_info3_param *ref, struct dfs_cache_tgt_list *tl)
24 {
25 	struct cifs_sb_info *cifs_sb = mnt_ctx->cifs_sb;
26 
27 	return dfs_cache_find(mnt_ctx->xid, mnt_ctx->root_ses, cifs_sb->local_nls,
28 			      cifs_remap(cifs_sb), path, ref, tl);
29 }
30 
dfs_get_automount_devname(struct dentry * dentry,void * page)31 static inline char *dfs_get_automount_devname(struct dentry *dentry, void *page)
32 {
33 	struct cifs_sb_info *cifs_sb = CIFS_SB(dentry->d_sb);
34 	struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
35 	struct TCP_Server_Info *server = tcon->ses->server;
36 
37 	if (unlikely(!server->origin_fullpath))
38 		return ERR_PTR(-EREMOTE);
39 
40 	return __build_path_from_dentry_optional_prefix(dentry, page,
41 							server->origin_fullpath,
42 							strlen(server->origin_fullpath),
43 							true);
44 }
45 
46 #endif /* _CIFS_DFS_H */
47