Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / fs / cifs / link.c
index 1455810..a57f5d6 100644 (file)
@@ -48,10 +48,8 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
 /* No need to check for cross device links since server will do that
    BB note DFS case in future though (when we may have to check) */
 
-       down(&inode->i_sb->s_vfs_rename_sem);
        fromName = build_path_from_dentry(old_file);
        toName = build_path_from_dentry(direntry);
-       up(&inode->i_sb->s_vfs_rename_sem);
        if((fromName == NULL) || (toName == NULL)) {
                rc = -ENOMEM;
                goto cifs_hl_exit;
@@ -59,11 +57,15 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
 
        if (cifs_sb_target->tcon->ses->capabilities & CAP_UNIX)
                rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName,
-                                           cifs_sb_target->local_nls);
+                                           cifs_sb_target->local_nls, 
+                                           cifs_sb_target->mnt_cifs_flags &
+                                               CIFS_MOUNT_MAP_SPECIAL_CHR);
        else {
                rc = CIFSCreateHardLink(xid, pTcon, fromName, toName,
-                                       cifs_sb_target->local_nls);
-               if(rc == -EIO)
+                                       cifs_sb_target->local_nls, 
+                                       cifs_sb_target->mnt_cifs_flags &
+                                               CIFS_MOUNT_MAP_SPECIAL_CHR);
+               if((rc == -EIO) || (rc == -EINVAL))
                        rc = -EOPNOTSUPP;  
        }
 
@@ -80,15 +82,13 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
        cifsInode->time = 0;    /* will force revalidate to go get info when needed */
 
 cifs_hl_exit:
-       if (fromName)
-               kfree(fromName);
-       if (toName)
-               kfree(toName);
+       kfree(fromName);
+       kfree(toName);
        FreeXid(xid);
        return rc;
 }
 
-int
+void *
 cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
 {
        struct inode *inode = direntry->d_inode;
@@ -101,9 +101,7 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
 
        xid = GetXid();
 
-       down(&direntry->d_sb->s_vfs_rename_sem);
        full_path = build_path_from_dentry(direntry);
-       up(&direntry->d_sb->s_vfs_rename_sem);
 
        if (!full_path)
                goto out_no_free;
@@ -144,7 +142,7 @@ out:
 out_no_free:
        FreeXid(xid);
        nd_set_link(nd, target_path);
-       return 0;
+       return NULL;    /* No cookie */
 }
 
 int
@@ -162,16 +160,14 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
        cifs_sb = CIFS_SB(inode->i_sb);
        pTcon = cifs_sb->tcon;
 
-       down(&inode->i_sb->s_vfs_rename_sem);
        full_path = build_path_from_dentry(direntry);
-       up(&inode->i_sb->s_vfs_rename_sem);
 
        if(full_path == NULL) {
                FreeXid(xid);
                return -ENOMEM;
        }
 
-       cFYI(1, ("Full path: %s ", full_path));
+       cFYI(1, ("Full path: %s", full_path));
        cFYI(1, ("symname is %s", symname));
 
        /* BB what if DFS and this volume is on different share? BB */
@@ -190,17 +186,18 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
                                                 inode->i_sb,xid);
 
                if (rc != 0) {
-                       cFYI(1,
-                            ("Create symlink worked but get_inode_info failed with rc = %d ",
+                       cFYI(1, ("Create symlink ok, getinodeinfo fail rc = %d",
                              rc));
                } else {
-                       direntry->d_op = &cifs_dentry_ops;
+                       if (pTcon->nocase)
+                               direntry->d_op = &cifs_ci_dentry_ops;
+                       else
+                               direntry->d_op = &cifs_dentry_ops;
                        d_instantiate(direntry, newinode);
                }
        }
 
-       if (full_path)
-               kfree(full_path);
+       kfree(full_path);
        FreeXid(xid);
        return rc;
 }
@@ -228,9 +225,9 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
 
 /* BB would it be safe against deadlock to grab this sem 
       even though rename itself grabs the sem and calls lookup? */
-/*       down(&inode->i_sb->s_vfs_rename_sem);*/
+/*       mutex_lock(&inode->i_sb->s_vfs_rename_mutex);*/
        full_path = build_path_from_dentry(direntry);
-/*       up(&inode->i_sb->s_vfs_rename_sem);*/
+/*       mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);*/
 
        if(full_path == NULL) {
                FreeXid(xid);
@@ -246,8 +243,7 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
                len = buflen;
        tmpbuffer = kmalloc(len,GFP_KERNEL);   
        if(tmpbuffer == NULL) {
-               if (full_path)
-                       kfree(full_path);
+               kfree(full_path);
                FreeXid(xid);
                return -ENOMEM;
        }
@@ -260,7 +256,10 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
                                cifs_sb->local_nls);
        else {
                rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ,
-                               OPEN_REPARSE_POINT,&fid, &oplock, NULL, cifs_sb->local_nls);
+                               OPEN_REPARSE_POINT,&fid, &oplock, NULL, 
+                               cifs_sb->local_nls, 
+                               cifs_sb->mnt_cifs_flags & 
+                                       CIFS_MOUNT_MAP_SPECIAL_CHR);
                if(!rc) {
                        rc = CIFSSMBQueryReparseLinkInfo(xid, pTcon, full_path,
                                tmpbuffer,
@@ -279,19 +278,21 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
                                        strncpy(tmp_path, pTcon->treeName, MAX_TREE_SIZE);
                                        strncat(tmp_path, full_path, MAX_PATHCONF);
                                        rc = get_dfs_path(xid, pTcon->ses, tmp_path,
-                                               cifs_sb->local_nls, &num_referrals, &referrals);
+                                               cifs_sb->local_nls,
+                                               &num_referrals, &referrals,
+                                               cifs_sb->mnt_cifs_flags &
+                                                   CIFS_MOUNT_MAP_SPECIAL_CHR);
                                        cFYI(1,("Get DFS for %s rc = %d ",tmp_path, rc));
                                        if((num_referrals == 0) && (rc == 0))
                                                rc = -EACCES;
                                        else {
                                                cFYI(1,("num referral: %d",num_referrals));
                                                if(referrals) {
-                                                       cFYI(1,("referral string: %s ",referrals));
+                                                       cFYI(1,("referral string: %s",referrals));
                                                        strncpy(tmpbuffer, referrals, len-1);                            
                                                }
                                        }
-                                       if(referrals)
-                                               kfree(referrals);
+                                       kfree(referrals);
                                        kfree(tmp_path);
 }
                                /* BB add code like else decode referrals then memcpy to
@@ -310,17 +311,13 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
                      rc));
        }
 
-       if (tmpbuffer) {
-               kfree(tmpbuffer);
-       }
-       if (full_path) {
-               kfree(full_path);
-       }
+       kfree(tmpbuffer);
+       kfree(full_path);
        FreeXid(xid);
        return rc;
 }
 
-void cifs_put_link(struct dentry *direntry, struct nameidata *nd)
+void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
 {
        char *p = nd_get_link(nd);
        if (!IS_ERR(p))