1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-or-later
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * Contains the CIFS DFS referral mounting routines used for handling
4*4882a593Smuzhiyun * traversal via DFS junction point
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun * Copyright (c) 2007 Igor Mammedov
7*4882a593Smuzhiyun * Copyright (C) International Business Machines Corp., 2008
8*4882a593Smuzhiyun * Author(s): Igor Mammedov (niallain@gmail.com)
9*4882a593Smuzhiyun * Steve French (sfrench@us.ibm.com)
10*4882a593Smuzhiyun */
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun #include <linux/dcache.h>
13*4882a593Smuzhiyun #include <linux/mount.h>
14*4882a593Smuzhiyun #include <linux/namei.h>
15*4882a593Smuzhiyun #include <linux/slab.h>
16*4882a593Smuzhiyun #include <linux/vfs.h>
17*4882a593Smuzhiyun #include <linux/fs.h>
18*4882a593Smuzhiyun #include <linux/inet.h>
19*4882a593Smuzhiyun #include "cifsglob.h"
20*4882a593Smuzhiyun #include "cifsproto.h"
21*4882a593Smuzhiyun #include "cifsfs.h"
22*4882a593Smuzhiyun #include "dns_resolve.h"
23*4882a593Smuzhiyun #include "cifs_debug.h"
24*4882a593Smuzhiyun #include "cifs_unicode.h"
25*4882a593Smuzhiyun #include "dfs_cache.h"
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun static LIST_HEAD(cifs_dfs_automount_list);
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun static void cifs_dfs_expire_automounts(struct work_struct *work);
30*4882a593Smuzhiyun static DECLARE_DELAYED_WORK(cifs_dfs_automount_task,
31*4882a593Smuzhiyun cifs_dfs_expire_automounts);
32*4882a593Smuzhiyun static int cifs_dfs_mountpoint_expiry_timeout = 500 * HZ;
33*4882a593Smuzhiyun
cifs_dfs_expire_automounts(struct work_struct * work)34*4882a593Smuzhiyun static void cifs_dfs_expire_automounts(struct work_struct *work)
35*4882a593Smuzhiyun {
36*4882a593Smuzhiyun struct list_head *list = &cifs_dfs_automount_list;
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun mark_mounts_for_expiry(list);
39*4882a593Smuzhiyun if (!list_empty(list))
40*4882a593Smuzhiyun schedule_delayed_work(&cifs_dfs_automount_task,
41*4882a593Smuzhiyun cifs_dfs_mountpoint_expiry_timeout);
42*4882a593Smuzhiyun }
43*4882a593Smuzhiyun
cifs_dfs_release_automount_timer(void)44*4882a593Smuzhiyun void cifs_dfs_release_automount_timer(void)
45*4882a593Smuzhiyun {
46*4882a593Smuzhiyun BUG_ON(!list_empty(&cifs_dfs_automount_list));
47*4882a593Smuzhiyun cancel_delayed_work_sync(&cifs_dfs_automount_task);
48*4882a593Smuzhiyun }
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun /**
51*4882a593Smuzhiyun * cifs_build_devname - build a devicename from a UNC and optional prepath
52*4882a593Smuzhiyun * @nodename: pointer to UNC string
53*4882a593Smuzhiyun * @prepath: pointer to prefixpath (or NULL if there isn't one)
54*4882a593Smuzhiyun *
55*4882a593Smuzhiyun * Build a new cifs devicename after chasing a DFS referral. Allocate a buffer
56*4882a593Smuzhiyun * big enough to hold the final thing. Copy the UNC from the nodename, and
57*4882a593Smuzhiyun * concatenate the prepath onto the end of it if there is one.
58*4882a593Smuzhiyun *
59*4882a593Smuzhiyun * Returns pointer to the built string, or a ERR_PTR. Caller is responsible
60*4882a593Smuzhiyun * for freeing the returned string.
61*4882a593Smuzhiyun */
62*4882a593Smuzhiyun static char *
cifs_build_devname(char * nodename,const char * prepath)63*4882a593Smuzhiyun cifs_build_devname(char *nodename, const char *prepath)
64*4882a593Smuzhiyun {
65*4882a593Smuzhiyun size_t pplen;
66*4882a593Smuzhiyun size_t unclen;
67*4882a593Smuzhiyun char *dev;
68*4882a593Smuzhiyun char *pos;
69*4882a593Smuzhiyun
70*4882a593Smuzhiyun /* skip over any preceding delimiters */
71*4882a593Smuzhiyun nodename += strspn(nodename, "\\");
72*4882a593Smuzhiyun if (!*nodename)
73*4882a593Smuzhiyun return ERR_PTR(-EINVAL);
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun /* get length of UNC and set pos to last char */
76*4882a593Smuzhiyun unclen = strlen(nodename);
77*4882a593Smuzhiyun pos = nodename + unclen - 1;
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun /* trim off any trailing delimiters */
80*4882a593Smuzhiyun while (*pos == '\\') {
81*4882a593Smuzhiyun --pos;
82*4882a593Smuzhiyun --unclen;
83*4882a593Smuzhiyun }
84*4882a593Smuzhiyun
85*4882a593Smuzhiyun /* allocate a buffer:
86*4882a593Smuzhiyun * +2 for preceding "//"
87*4882a593Smuzhiyun * +1 for delimiter between UNC and prepath
88*4882a593Smuzhiyun * +1 for trailing NULL
89*4882a593Smuzhiyun */
90*4882a593Smuzhiyun pplen = prepath ? strlen(prepath) : 0;
91*4882a593Smuzhiyun dev = kmalloc(2 + unclen + 1 + pplen + 1, GFP_KERNEL);
92*4882a593Smuzhiyun if (!dev)
93*4882a593Smuzhiyun return ERR_PTR(-ENOMEM);
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun pos = dev;
96*4882a593Smuzhiyun /* add the initial "//" */
97*4882a593Smuzhiyun *pos = '/';
98*4882a593Smuzhiyun ++pos;
99*4882a593Smuzhiyun *pos = '/';
100*4882a593Smuzhiyun ++pos;
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun /* copy in the UNC portion from referral */
103*4882a593Smuzhiyun memcpy(pos, nodename, unclen);
104*4882a593Smuzhiyun pos += unclen;
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun /* copy the prefixpath remainder (if there is one) */
107*4882a593Smuzhiyun if (pplen) {
108*4882a593Smuzhiyun *pos = '/';
109*4882a593Smuzhiyun ++pos;
110*4882a593Smuzhiyun memcpy(pos, prepath, pplen);
111*4882a593Smuzhiyun pos += pplen;
112*4882a593Smuzhiyun }
113*4882a593Smuzhiyun
114*4882a593Smuzhiyun /* NULL terminator */
115*4882a593Smuzhiyun *pos = '\0';
116*4882a593Smuzhiyun
117*4882a593Smuzhiyun convert_delimiter(dev, '/');
118*4882a593Smuzhiyun return dev;
119*4882a593Smuzhiyun }
120*4882a593Smuzhiyun
121*4882a593Smuzhiyun
122*4882a593Smuzhiyun /**
123*4882a593Smuzhiyun * cifs_compose_mount_options - creates mount options for referral
124*4882a593Smuzhiyun * @sb_mountdata: parent/root DFS mount options (template)
125*4882a593Smuzhiyun * @fullpath: full path in UNC format
126*4882a593Smuzhiyun * @ref: optional server's referral
127*4882a593Smuzhiyun * @devname: optional pointer for saving device name
128*4882a593Smuzhiyun *
129*4882a593Smuzhiyun * creates mount options for submount based on template options sb_mountdata
130*4882a593Smuzhiyun * and replacing unc,ip,prefixpath options with ones we've got form ref_unc.
131*4882a593Smuzhiyun *
132*4882a593Smuzhiyun * Returns: pointer to new mount options or ERR_PTR.
133*4882a593Smuzhiyun * Caller is responsible for freeing returned value if it is not error.
134*4882a593Smuzhiyun */
cifs_compose_mount_options(const char * sb_mountdata,const char * fullpath,const struct dfs_info3_param * ref,char ** devname)135*4882a593Smuzhiyun char *cifs_compose_mount_options(const char *sb_mountdata,
136*4882a593Smuzhiyun const char *fullpath,
137*4882a593Smuzhiyun const struct dfs_info3_param *ref,
138*4882a593Smuzhiyun char **devname)
139*4882a593Smuzhiyun {
140*4882a593Smuzhiyun int rc;
141*4882a593Smuzhiyun char *name;
142*4882a593Smuzhiyun char *mountdata = NULL;
143*4882a593Smuzhiyun const char *prepath = NULL;
144*4882a593Smuzhiyun int md_len;
145*4882a593Smuzhiyun char *tkn_e;
146*4882a593Smuzhiyun char *srvIP = NULL;
147*4882a593Smuzhiyun char sep = ',';
148*4882a593Smuzhiyun int off, noff;
149*4882a593Smuzhiyun
150*4882a593Smuzhiyun if (sb_mountdata == NULL)
151*4882a593Smuzhiyun return ERR_PTR(-EINVAL);
152*4882a593Smuzhiyun
153*4882a593Smuzhiyun if (ref) {
154*4882a593Smuzhiyun if (WARN_ON_ONCE(!ref->node_name || ref->path_consumed < 0))
155*4882a593Smuzhiyun return ERR_PTR(-EINVAL);
156*4882a593Smuzhiyun
157*4882a593Smuzhiyun if (strlen(fullpath) - ref->path_consumed) {
158*4882a593Smuzhiyun prepath = fullpath + ref->path_consumed;
159*4882a593Smuzhiyun /* skip initial delimiter */
160*4882a593Smuzhiyun if (*prepath == '/' || *prepath == '\\')
161*4882a593Smuzhiyun prepath++;
162*4882a593Smuzhiyun }
163*4882a593Smuzhiyun
164*4882a593Smuzhiyun name = cifs_build_devname(ref->node_name, prepath);
165*4882a593Smuzhiyun if (IS_ERR(name)) {
166*4882a593Smuzhiyun rc = PTR_ERR(name);
167*4882a593Smuzhiyun name = NULL;
168*4882a593Smuzhiyun goto compose_mount_options_err;
169*4882a593Smuzhiyun }
170*4882a593Smuzhiyun } else {
171*4882a593Smuzhiyun name = cifs_build_devname((char *)fullpath, NULL);
172*4882a593Smuzhiyun if (IS_ERR(name)) {
173*4882a593Smuzhiyun rc = PTR_ERR(name);
174*4882a593Smuzhiyun name = NULL;
175*4882a593Smuzhiyun goto compose_mount_options_err;
176*4882a593Smuzhiyun }
177*4882a593Smuzhiyun }
178*4882a593Smuzhiyun
179*4882a593Smuzhiyun rc = dns_resolve_server_name_to_ip(name, &srvIP);
180*4882a593Smuzhiyun if (rc < 0) {
181*4882a593Smuzhiyun cifs_dbg(FYI, "%s: Failed to resolve server part of %s to IP: %d\n",
182*4882a593Smuzhiyun __func__, name, rc);
183*4882a593Smuzhiyun goto compose_mount_options_err;
184*4882a593Smuzhiyun }
185*4882a593Smuzhiyun
186*4882a593Smuzhiyun /*
187*4882a593Smuzhiyun * In most cases, we'll be building a shorter string than the original,
188*4882a593Smuzhiyun * but we do have to assume that the address in the ip= option may be
189*4882a593Smuzhiyun * much longer than the original. Add the max length of an address
190*4882a593Smuzhiyun * string to the length of the original string to allow for worst case.
191*4882a593Smuzhiyun */
192*4882a593Smuzhiyun md_len = strlen(sb_mountdata) + INET6_ADDRSTRLEN;
193*4882a593Smuzhiyun mountdata = kzalloc(md_len + sizeof("ip=") + 1, GFP_KERNEL);
194*4882a593Smuzhiyun if (mountdata == NULL) {
195*4882a593Smuzhiyun rc = -ENOMEM;
196*4882a593Smuzhiyun goto compose_mount_options_err;
197*4882a593Smuzhiyun }
198*4882a593Smuzhiyun
199*4882a593Smuzhiyun /* copy all options except of unc,ip,prefixpath */
200*4882a593Smuzhiyun off = 0;
201*4882a593Smuzhiyun if (strncmp(sb_mountdata, "sep=", 4) == 0) {
202*4882a593Smuzhiyun sep = sb_mountdata[4];
203*4882a593Smuzhiyun strncpy(mountdata, sb_mountdata, 5);
204*4882a593Smuzhiyun off += 5;
205*4882a593Smuzhiyun }
206*4882a593Smuzhiyun
207*4882a593Smuzhiyun do {
208*4882a593Smuzhiyun tkn_e = strchr(sb_mountdata + off, sep);
209*4882a593Smuzhiyun if (tkn_e == NULL)
210*4882a593Smuzhiyun noff = strlen(sb_mountdata + off);
211*4882a593Smuzhiyun else
212*4882a593Smuzhiyun noff = tkn_e - (sb_mountdata + off) + 1;
213*4882a593Smuzhiyun
214*4882a593Smuzhiyun if (strncasecmp(sb_mountdata + off, "unc=", 4) == 0) {
215*4882a593Smuzhiyun off += noff;
216*4882a593Smuzhiyun continue;
217*4882a593Smuzhiyun }
218*4882a593Smuzhiyun if (strncasecmp(sb_mountdata + off, "ip=", 3) == 0) {
219*4882a593Smuzhiyun off += noff;
220*4882a593Smuzhiyun continue;
221*4882a593Smuzhiyun }
222*4882a593Smuzhiyun if (strncasecmp(sb_mountdata + off, "prefixpath=", 11) == 0) {
223*4882a593Smuzhiyun off += noff;
224*4882a593Smuzhiyun continue;
225*4882a593Smuzhiyun }
226*4882a593Smuzhiyun strncat(mountdata, sb_mountdata + off, noff);
227*4882a593Smuzhiyun off += noff;
228*4882a593Smuzhiyun } while (tkn_e);
229*4882a593Smuzhiyun strcat(mountdata, sb_mountdata + off);
230*4882a593Smuzhiyun mountdata[md_len] = '\0';
231*4882a593Smuzhiyun
232*4882a593Smuzhiyun /* copy new IP and ref share name */
233*4882a593Smuzhiyun if (mountdata[strlen(mountdata) - 1] != sep)
234*4882a593Smuzhiyun strncat(mountdata, &sep, 1);
235*4882a593Smuzhiyun strcat(mountdata, "ip=");
236*4882a593Smuzhiyun strcat(mountdata, srvIP);
237*4882a593Smuzhiyun
238*4882a593Smuzhiyun if (devname)
239*4882a593Smuzhiyun *devname = name;
240*4882a593Smuzhiyun else
241*4882a593Smuzhiyun kfree(name);
242*4882a593Smuzhiyun
243*4882a593Smuzhiyun /*cifs_dbg(FYI, "%s: parent mountdata: %s\n", __func__, sb_mountdata);*/
244*4882a593Smuzhiyun /*cifs_dbg(FYI, "%s: submount mountdata: %s\n", __func__, mountdata );*/
245*4882a593Smuzhiyun
246*4882a593Smuzhiyun compose_mount_options_out:
247*4882a593Smuzhiyun kfree(srvIP);
248*4882a593Smuzhiyun return mountdata;
249*4882a593Smuzhiyun
250*4882a593Smuzhiyun compose_mount_options_err:
251*4882a593Smuzhiyun kfree(mountdata);
252*4882a593Smuzhiyun mountdata = ERR_PTR(rc);
253*4882a593Smuzhiyun kfree(name);
254*4882a593Smuzhiyun goto compose_mount_options_out;
255*4882a593Smuzhiyun }
256*4882a593Smuzhiyun
257*4882a593Smuzhiyun /**
258*4882a593Smuzhiyun * cifs_dfs_do_mount - mounts specified path using DFS full path
259*4882a593Smuzhiyun *
260*4882a593Smuzhiyun * Always pass down @fullpath to smb3_do_mount() so we can use the root server
261*4882a593Smuzhiyun * to perform failover in case we failed to connect to the first target in the
262*4882a593Smuzhiyun * referral.
263*4882a593Smuzhiyun *
264*4882a593Smuzhiyun * @cifs_sb: parent/root superblock
265*4882a593Smuzhiyun * @fullpath: full path in UNC format
266*4882a593Smuzhiyun */
cifs_dfs_do_mount(struct dentry * mntpt,struct cifs_sb_info * cifs_sb,const char * fullpath)267*4882a593Smuzhiyun static struct vfsmount *cifs_dfs_do_mount(struct dentry *mntpt,
268*4882a593Smuzhiyun struct cifs_sb_info *cifs_sb,
269*4882a593Smuzhiyun const char *fullpath)
270*4882a593Smuzhiyun {
271*4882a593Smuzhiyun struct vfsmount *mnt;
272*4882a593Smuzhiyun char *mountdata;
273*4882a593Smuzhiyun char *devname;
274*4882a593Smuzhiyun
275*4882a593Smuzhiyun devname = kstrndup(fullpath, strlen(fullpath), GFP_KERNEL);
276*4882a593Smuzhiyun if (!devname)
277*4882a593Smuzhiyun return ERR_PTR(-ENOMEM);
278*4882a593Smuzhiyun
279*4882a593Smuzhiyun convert_delimiter(devname, '/');
280*4882a593Smuzhiyun
281*4882a593Smuzhiyun /* strip first '\' from fullpath */
282*4882a593Smuzhiyun mountdata = cifs_compose_mount_options(cifs_sb->mountdata,
283*4882a593Smuzhiyun fullpath + 1, NULL, NULL);
284*4882a593Smuzhiyun if (IS_ERR(mountdata)) {
285*4882a593Smuzhiyun kfree(devname);
286*4882a593Smuzhiyun return (struct vfsmount *)mountdata;
287*4882a593Smuzhiyun }
288*4882a593Smuzhiyun
289*4882a593Smuzhiyun mnt = vfs_submount(mntpt, &cifs_fs_type, devname, mountdata);
290*4882a593Smuzhiyun kfree(mountdata);
291*4882a593Smuzhiyun kfree(devname);
292*4882a593Smuzhiyun return mnt;
293*4882a593Smuzhiyun }
294*4882a593Smuzhiyun
295*4882a593Smuzhiyun /*
296*4882a593Smuzhiyun * Create a vfsmount that we can automount
297*4882a593Smuzhiyun */
cifs_dfs_do_automount(struct dentry * mntpt)298*4882a593Smuzhiyun static struct vfsmount *cifs_dfs_do_automount(struct dentry *mntpt)
299*4882a593Smuzhiyun {
300*4882a593Smuzhiyun struct cifs_sb_info *cifs_sb;
301*4882a593Smuzhiyun struct cifs_ses *ses;
302*4882a593Smuzhiyun struct cifs_tcon *tcon;
303*4882a593Smuzhiyun char *full_path, *root_path;
304*4882a593Smuzhiyun unsigned int xid;
305*4882a593Smuzhiyun int rc;
306*4882a593Smuzhiyun struct vfsmount *mnt;
307*4882a593Smuzhiyun
308*4882a593Smuzhiyun cifs_dbg(FYI, "in %s\n", __func__);
309*4882a593Smuzhiyun BUG_ON(IS_ROOT(mntpt));
310*4882a593Smuzhiyun
311*4882a593Smuzhiyun /*
312*4882a593Smuzhiyun * The MSDFS spec states that paths in DFS referral requests and
313*4882a593Smuzhiyun * responses must be prefixed by a single '\' character instead of
314*4882a593Smuzhiyun * the double backslashes usually used in the UNC. This function
315*4882a593Smuzhiyun * gives us the latter, so we must adjust the result.
316*4882a593Smuzhiyun */
317*4882a593Smuzhiyun mnt = ERR_PTR(-ENOMEM);
318*4882a593Smuzhiyun
319*4882a593Smuzhiyun cifs_sb = CIFS_SB(mntpt->d_sb);
320*4882a593Smuzhiyun if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS) {
321*4882a593Smuzhiyun mnt = ERR_PTR(-EREMOTE);
322*4882a593Smuzhiyun goto cdda_exit;
323*4882a593Smuzhiyun }
324*4882a593Smuzhiyun
325*4882a593Smuzhiyun /* always use tree name prefix */
326*4882a593Smuzhiyun full_path = build_path_from_dentry_optional_prefix(mntpt, true);
327*4882a593Smuzhiyun if (full_path == NULL)
328*4882a593Smuzhiyun goto cdda_exit;
329*4882a593Smuzhiyun
330*4882a593Smuzhiyun convert_delimiter(full_path, '\\');
331*4882a593Smuzhiyun
332*4882a593Smuzhiyun cifs_dbg(FYI, "%s: full_path: %s\n", __func__, full_path);
333*4882a593Smuzhiyun
334*4882a593Smuzhiyun if (!cifs_sb_master_tlink(cifs_sb)) {
335*4882a593Smuzhiyun cifs_dbg(FYI, "%s: master tlink is NULL\n", __func__);
336*4882a593Smuzhiyun goto free_full_path;
337*4882a593Smuzhiyun }
338*4882a593Smuzhiyun
339*4882a593Smuzhiyun tcon = cifs_sb_master_tcon(cifs_sb);
340*4882a593Smuzhiyun if (!tcon) {
341*4882a593Smuzhiyun cifs_dbg(FYI, "%s: master tcon is NULL\n", __func__);
342*4882a593Smuzhiyun goto free_full_path;
343*4882a593Smuzhiyun }
344*4882a593Smuzhiyun
345*4882a593Smuzhiyun root_path = kstrdup(tcon->treeName, GFP_KERNEL);
346*4882a593Smuzhiyun if (!root_path) {
347*4882a593Smuzhiyun mnt = ERR_PTR(-ENOMEM);
348*4882a593Smuzhiyun goto free_full_path;
349*4882a593Smuzhiyun }
350*4882a593Smuzhiyun cifs_dbg(FYI, "%s: root path: %s\n", __func__, root_path);
351*4882a593Smuzhiyun
352*4882a593Smuzhiyun ses = tcon->ses;
353*4882a593Smuzhiyun xid = get_xid();
354*4882a593Smuzhiyun
355*4882a593Smuzhiyun /*
356*4882a593Smuzhiyun * If DFS root has been expired, then unconditionally fetch it again to
357*4882a593Smuzhiyun * refresh DFS referral cache.
358*4882a593Smuzhiyun */
359*4882a593Smuzhiyun rc = dfs_cache_find(xid, ses, cifs_sb->local_nls, cifs_remap(cifs_sb),
360*4882a593Smuzhiyun root_path + 1, NULL, NULL);
361*4882a593Smuzhiyun if (!rc) {
362*4882a593Smuzhiyun rc = dfs_cache_find(xid, ses, cifs_sb->local_nls,
363*4882a593Smuzhiyun cifs_remap(cifs_sb), full_path + 1,
364*4882a593Smuzhiyun NULL, NULL);
365*4882a593Smuzhiyun }
366*4882a593Smuzhiyun
367*4882a593Smuzhiyun free_xid(xid);
368*4882a593Smuzhiyun
369*4882a593Smuzhiyun if (rc) {
370*4882a593Smuzhiyun mnt = ERR_PTR(rc);
371*4882a593Smuzhiyun goto free_root_path;
372*4882a593Smuzhiyun }
373*4882a593Smuzhiyun /*
374*4882a593Smuzhiyun * OK - we were able to get and cache a referral for @full_path.
375*4882a593Smuzhiyun *
376*4882a593Smuzhiyun * Now, pass it down to cifs_mount() and it will retry every available
377*4882a593Smuzhiyun * node server in case of failures - no need to do it here.
378*4882a593Smuzhiyun */
379*4882a593Smuzhiyun mnt = cifs_dfs_do_mount(mntpt, cifs_sb, full_path);
380*4882a593Smuzhiyun cifs_dbg(FYI, "%s: cifs_dfs_do_mount:%s , mnt:%p\n", __func__,
381*4882a593Smuzhiyun full_path + 1, mnt);
382*4882a593Smuzhiyun
383*4882a593Smuzhiyun free_root_path:
384*4882a593Smuzhiyun kfree(root_path);
385*4882a593Smuzhiyun free_full_path:
386*4882a593Smuzhiyun kfree(full_path);
387*4882a593Smuzhiyun cdda_exit:
388*4882a593Smuzhiyun cifs_dbg(FYI, "leaving %s\n" , __func__);
389*4882a593Smuzhiyun return mnt;
390*4882a593Smuzhiyun }
391*4882a593Smuzhiyun
392*4882a593Smuzhiyun /*
393*4882a593Smuzhiyun * Attempt to automount the referral
394*4882a593Smuzhiyun */
cifs_dfs_d_automount(struct path * path)395*4882a593Smuzhiyun struct vfsmount *cifs_dfs_d_automount(struct path *path)
396*4882a593Smuzhiyun {
397*4882a593Smuzhiyun struct vfsmount *newmnt;
398*4882a593Smuzhiyun
399*4882a593Smuzhiyun cifs_dbg(FYI, "in %s\n", __func__);
400*4882a593Smuzhiyun
401*4882a593Smuzhiyun newmnt = cifs_dfs_do_automount(path->dentry);
402*4882a593Smuzhiyun if (IS_ERR(newmnt)) {
403*4882a593Smuzhiyun cifs_dbg(FYI, "leaving %s [automount failed]\n" , __func__);
404*4882a593Smuzhiyun return newmnt;
405*4882a593Smuzhiyun }
406*4882a593Smuzhiyun
407*4882a593Smuzhiyun mntget(newmnt); /* prevent immediate expiration */
408*4882a593Smuzhiyun mnt_set_expiry(newmnt, &cifs_dfs_automount_list);
409*4882a593Smuzhiyun schedule_delayed_work(&cifs_dfs_automount_task,
410*4882a593Smuzhiyun cifs_dfs_mountpoint_expiry_timeout);
411*4882a593Smuzhiyun cifs_dbg(FYI, "leaving %s [ok]\n" , __func__);
412*4882a593Smuzhiyun return newmnt;
413*4882a593Smuzhiyun }
414*4882a593Smuzhiyun
415*4882a593Smuzhiyun const struct inode_operations cifs_dfs_referral_inode_operations = {
416*4882a593Smuzhiyun };
417