diff options
Diffstat (limited to 'fs/cifs/link.c')
-rw-r--r-- | fs/cifs/link.c | 114 |
1 files changed, 5 insertions, 109 deletions
diff --git a/fs/cifs/link.c b/fs/cifs/link.c index 63f644000ce5..ea9d11e3dcbb 100644 --- a/fs/cifs/link.c +++ b/fs/cifs/link.c | |||
@@ -119,16 +119,11 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd) | |||
119 | full_path = build_path_from_dentry(direntry); | 119 | full_path = build_path_from_dentry(direntry); |
120 | 120 | ||
121 | if (!full_path) | 121 | if (!full_path) |
122 | goto out_no_free; | 122 | goto out; |
123 | 123 | ||
124 | cFYI(1, ("Full path: %s inode = 0x%p", full_path, inode)); | 124 | cFYI(1, ("Full path: %s inode = 0x%p", full_path, inode)); |
125 | cifs_sb = CIFS_SB(inode->i_sb); | 125 | cifs_sb = CIFS_SB(inode->i_sb); |
126 | pTcon = cifs_sb->tcon; | 126 | pTcon = cifs_sb->tcon; |
127 | target_path = kmalloc(PATH_MAX, GFP_KERNEL); | ||
128 | if (!target_path) { | ||
129 | target_path = ERR_PTR(-ENOMEM); | ||
130 | goto out; | ||
131 | } | ||
132 | 127 | ||
133 | /* We could change this to: | 128 | /* We could change this to: |
134 | if (pTcon->unix_ext) | 129 | if (pTcon->unix_ext) |
@@ -138,8 +133,7 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd) | |||
138 | 133 | ||
139 | if (pTcon->ses->capabilities & CAP_UNIX) | 134 | if (pTcon->ses->capabilities & CAP_UNIX) |
140 | rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path, | 135 | rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path, |
141 | target_path, | 136 | &target_path, |
142 | PATH_MAX-1, | ||
143 | cifs_sb->local_nls); | 137 | cifs_sb->local_nls); |
144 | else { | 138 | else { |
145 | /* BB add read reparse point symlink code here */ | 139 | /* BB add read reparse point symlink code here */ |
@@ -148,22 +142,16 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd) | |||
148 | /* BB Add MAC style xsymlink check here if enabled */ | 142 | /* BB Add MAC style xsymlink check here if enabled */ |
149 | } | 143 | } |
150 | 144 | ||
151 | if (rc == 0) { | 145 | if (rc != 0) { |
152 | |||
153 | /* BB Add special case check for Samba DFS symlinks */ | ||
154 | |||
155 | target_path[PATH_MAX-1] = 0; | ||
156 | } else { | ||
157 | kfree(target_path); | 146 | kfree(target_path); |
158 | target_path = ERR_PTR(rc); | 147 | target_path = ERR_PTR(rc); |
159 | } | 148 | } |
160 | 149 | ||
161 | out: | ||
162 | kfree(full_path); | 150 | kfree(full_path); |
163 | out_no_free: | 151 | out: |
164 | FreeXid(xid); | 152 | FreeXid(xid); |
165 | nd_set_link(nd, target_path); | 153 | nd_set_link(nd, target_path); |
166 | return NULL; /* No cookie */ | 154 | return NULL; |
167 | } | 155 | } |
168 | 156 | ||
169 | int | 157 | int |
@@ -224,98 +212,6 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname) | |||
224 | return rc; | 212 | return rc; |
225 | } | 213 | } |
226 | 214 | ||
227 | int | ||
228 | cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen) | ||
229 | { | ||
230 | struct inode *inode = direntry->d_inode; | ||
231 | int rc = -EACCES; | ||
232 | int xid; | ||
233 | int oplock = 0; | ||
234 | struct cifs_sb_info *cifs_sb; | ||
235 | struct cifsTconInfo *pTcon; | ||
236 | char *full_path = NULL; | ||
237 | char *tmpbuffer; | ||
238 | int len; | ||
239 | __u16 fid; | ||
240 | |||
241 | xid = GetXid(); | ||
242 | cifs_sb = CIFS_SB(inode->i_sb); | ||
243 | pTcon = cifs_sb->tcon; | ||
244 | |||
245 | /* BB would it be safe against deadlock to grab this sem | ||
246 | even though rename itself grabs the sem and calls lookup? */ | ||
247 | /* mutex_lock(&inode->i_sb->s_vfs_rename_mutex);*/ | ||
248 | full_path = build_path_from_dentry(direntry); | ||
249 | /* mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);*/ | ||
250 | |||
251 | if (full_path == NULL) { | ||
252 | FreeXid(xid); | ||
253 | return -ENOMEM; | ||
254 | } | ||
255 | |||
256 | cFYI(1, | ||
257 | ("Full path: %s inode = 0x%p pBuffer = 0x%p buflen = %d", | ||
258 | full_path, inode, pBuffer, buflen)); | ||
259 | if (buflen > PATH_MAX) | ||
260 | len = PATH_MAX; | ||
261 | else | ||
262 | len = buflen; | ||
263 | tmpbuffer = kmalloc(len, GFP_KERNEL); | ||
264 | if (tmpbuffer == NULL) { | ||
265 | kfree(full_path); | ||
266 | FreeXid(xid); | ||
267 | return -ENOMEM; | ||
268 | } | ||
269 | |||
270 | /* BB add read reparse point symlink code and | ||
271 | Unix extensions symlink code here BB */ | ||
272 | /* We could disable this based on pTcon->unix_ext flag instead ... but why? */ | ||
273 | if (cifs_sb->tcon->ses->capabilities & CAP_UNIX) | ||
274 | rc = CIFSSMBUnixQuerySymLink(xid, pTcon, full_path, | ||
275 | tmpbuffer, | ||
276 | len - 1, | ||
277 | cifs_sb->local_nls); | ||
278 | else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { | ||
279 | cERROR(1, ("SFU style symlinks not implemented yet")); | ||
280 | /* add open and read as in fs/cifs/inode.c */ | ||
281 | } else { | ||
282 | rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ, | ||
283 | OPEN_REPARSE_POINT, &fid, &oplock, NULL, | ||
284 | cifs_sb->local_nls, | ||
285 | cifs_sb->mnt_cifs_flags & | ||
286 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
287 | if (!rc) { | ||
288 | rc = CIFSSMBQueryReparseLinkInfo(xid, pTcon, full_path, | ||
289 | tmpbuffer, | ||
290 | len - 1, | ||
291 | fid, | ||
292 | cifs_sb->local_nls); | ||
293 | if (CIFSSMBClose(xid, pTcon, fid)) { | ||
294 | cFYI(1, ("Error closing junction point " | ||
295 | "(open for ioctl)")); | ||
296 | } | ||
297 | /* If it is a DFS junction earlier we would have gotten | ||
298 | PATH_NOT_COVERED returned from server so we do | ||
299 | not need to request the DFS info here */ | ||
300 | } | ||
301 | } | ||
302 | /* BB Anything else to do to handle recursive links? */ | ||
303 | /* BB Should we be using page ops here? */ | ||
304 | |||
305 | /* BB null terminate returned string in pBuffer? BB */ | ||
306 | if (rc == 0) { | ||
307 | rc = vfs_readlink(direntry, pBuffer, len, tmpbuffer); | ||
308 | cFYI(1, | ||
309 | ("vfs_readlink called from cifs_readlink returned %d", | ||
310 | rc)); | ||
311 | } | ||
312 | |||
313 | kfree(tmpbuffer); | ||
314 | kfree(full_path); | ||
315 | FreeXid(xid); | ||
316 | return rc; | ||
317 | } | ||
318 | |||
319 | void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie) | 215 | void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie) |
320 | { | 216 | { |
321 | char *p = nd_get_link(nd); | 217 | char *p = nd_get_link(nd); |