@@ -60,7 +60,7 @@ void cifs_dfs_release_automount_timer(void)
6060 * Returns pointer to the built string, or a ERR_PTR. Caller is responsible
6161 * for freeing the returned string.
6262 */
63- static char *
63+ char *
6464cifs_build_devname (char * nodename , const char * prepath )
6565{
6666 size_t pplen ;
@@ -119,145 +119,6 @@ cifs_build_devname(char *nodename, const char *prepath)
119119 return dev ;
120120}
121121
122-
123- /**
124- * cifs_compose_mount_options - creates mount options for referral
125- * @sb_mountdata: parent/root DFS mount options (template)
126- * @fullpath: full path in UNC format
127- * @ref: optional server's referral
128- * @devname: return the built cifs device name if passed pointer not NULL
129- * creates mount options for submount based on template options sb_mountdata
130- * and replacing unc,ip,prefixpath options with ones we've got form ref_unc.
131- *
132- * Returns: pointer to new mount options or ERR_PTR.
133- * Caller is responsible for freeing returned value if it is not error.
134- */
135- char * cifs_compose_mount_options (const char * sb_mountdata ,
136- const char * fullpath ,
137- const struct dfs_info3_param * ref ,
138- char * * devname )
139- {
140- int rc ;
141- char * name ;
142- char * mountdata = NULL ;
143- const char * prepath = NULL ;
144- int md_len ;
145- char * tkn_e ;
146- char * srvIP = NULL ;
147- char sep = ',' ;
148- int off , noff ;
149-
150- if (sb_mountdata == NULL )
151- return ERR_PTR (- EINVAL );
152-
153- if (ref ) {
154- if (WARN_ON_ONCE (!ref -> node_name || ref -> path_consumed < 0 ))
155- return ERR_PTR (- EINVAL );
156-
157- if (strlen (fullpath ) - ref -> path_consumed ) {
158- prepath = fullpath + ref -> path_consumed ;
159- /* skip initial delimiter */
160- if (* prepath == '/' || * prepath == '\\' )
161- prepath ++ ;
162- }
163-
164- name = cifs_build_devname (ref -> node_name , prepath );
165- if (IS_ERR (name )) {
166- rc = PTR_ERR (name );
167- name = NULL ;
168- goto compose_mount_options_err ;
169- }
170- } else {
171- name = cifs_build_devname ((char * )fullpath , NULL );
172- if (IS_ERR (name )) {
173- rc = PTR_ERR (name );
174- name = NULL ;
175- goto compose_mount_options_err ;
176- }
177- }
178-
179- rc = dns_resolve_server_name_to_ip (name , & srvIP , NULL );
180- if (rc < 0 ) {
181- cifs_dbg (FYI , "%s: Failed to resolve server part of %s to IP: %d\n" ,
182- __func__ , name , rc );
183- goto compose_mount_options_err ;
184- }
185-
186- /*
187- * In most cases, we'll be building a shorter string than the original,
188- * but we do have to assume that the address in the ip= option may be
189- * much longer than the original. Add the max length of an address
190- * string to the length of the original string to allow for worst case.
191- */
192- md_len = strlen (sb_mountdata ) + INET6_ADDRSTRLEN ;
193- mountdata = kzalloc (md_len + sizeof ("ip=" ) + 1 , GFP_KERNEL );
194- if (mountdata == NULL ) {
195- rc = - ENOMEM ;
196- goto compose_mount_options_err ;
197- }
198-
199- /* copy all options except of unc,ip,prefixpath */
200- off = 0 ;
201- if (strncmp (sb_mountdata , "sep=" , 4 ) == 0 ) {
202- sep = sb_mountdata [4 ];
203- strncpy (mountdata , sb_mountdata , 5 );
204- off += 5 ;
205- }
206-
207- do {
208- tkn_e = strchr (sb_mountdata + off , sep );
209- if (tkn_e == NULL )
210- noff = strlen (sb_mountdata + off );
211- else
212- noff = tkn_e - (sb_mountdata + off ) + 1 ;
213-
214- if (strncasecmp (sb_mountdata + off , "cruid=" , 6 ) == 0 ) {
215- off += noff ;
216- continue ;
217- }
218- if (strncasecmp (sb_mountdata + off , "unc=" , 4 ) == 0 ) {
219- off += noff ;
220- continue ;
221- }
222- if (strncasecmp (sb_mountdata + off , "ip=" , 3 ) == 0 ) {
223- off += noff ;
224- continue ;
225- }
226- if (strncasecmp (sb_mountdata + off , "prefixpath=" , 11 ) == 0 ) {
227- off += noff ;
228- continue ;
229- }
230- strncat (mountdata , sb_mountdata + off , noff );
231- off += noff ;
232- } while (tkn_e );
233- strcat (mountdata , sb_mountdata + off );
234- mountdata [md_len ] = '\0' ;
235-
236- /* copy new IP and ref share name */
237- if (mountdata [strlen (mountdata ) - 1 ] != sep )
238- strncat (mountdata , & sep , 1 );
239- strcat (mountdata , "ip=" );
240- strcat (mountdata , srvIP );
241-
242- if (devname )
243- * devname = name ;
244- else
245- kfree (name );
246-
247- /*cifs_dbg(FYI, "%s: parent mountdata: %s\n", __func__, sb_mountdata);*/
248- /*cifs_dbg(FYI, "%s: submount mountdata: %s\n", __func__, mountdata );*/
249-
250- compose_mount_options_out :
251- kfree (srvIP );
252- return mountdata ;
253-
254- compose_mount_options_err :
255- kfree (mountdata );
256- mountdata = ERR_PTR (rc );
257- kfree (name );
258- goto compose_mount_options_out ;
259- }
260-
261122/*
262123 * Create a vfsmount that we can automount
263124 */
0 commit comments