Merge branch 'fixes-for-linus' of git://git.monstr.eu/linux-2.6-microblaze
[pandora-kernel.git] / fs / cifs / dir.c
index d9006b0..11431ed 100644 (file)
@@ -149,7 +149,7 @@ cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle,
        pCifsFile->pid = current->tgid;
        pCifsFile->pInode = newinode;
        pCifsFile->invalidHandle = false;
-       pCifsFile->closePend     = false;
+       pCifsFile->closePend = false;
        mutex_init(&pCifsFile->fh_mutex);
        mutex_init(&pCifsFile->lock_mutex);
        INIT_LIST_HEAD(&pCifsFile->llist);
@@ -162,20 +162,18 @@ cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle,
        pCifsInode = CIFS_I(newinode);
        if (pCifsInode) {
                /* if readable file instance put first in list*/
-               if (write_only) {
+               if (write_only)
                        list_add_tail(&pCifsFile->flist,
                                      &pCifsInode->openFileList);
-               } else {
-                       list_add(&pCifsFile->flist,
-                                &pCifsInode->openFileList);
-               }
+               else
+                       list_add(&pCifsFile->flist, &pCifsInode->openFileList);
+
                if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
                        pCifsInode->clientCanCacheAll = true;
                        pCifsInode->clientCanCacheRead = true;
-                       cFYI(1, ("Exclusive Oplock inode %p",
-                               newinode));
+                       cFYI(1, ("Exclusive Oplock inode %p", newinode));
                } else if ((oplock & 0xF) == OPLOCK_READ)
-                       pCifsInode->clientCanCacheRead = true;
+                               pCifsInode->clientCanCacheRead = true;
        }
        write_unlock(&GlobalSMBSeslock);
 }
@@ -283,6 +281,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
        int create_options = CREATE_NOT_DIR;
        int oplock = 0;
        int oflags;
+       bool posix_create = false;
        /*
         * BB below access is probably too much for mknod to request
         *    but we have to do query and setpathinfo so requesting
@@ -330,11 +329,13 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
                   negotation.  EREMOTE indicates DFS junction, which is not
                   handled in posix open */
 
-               if ((rc == 0) && (newinode == NULL))
-                       goto cifs_create_get_file_info; /* query inode info */
-               else if (rc == 0) /* success, no need to query */
-                       goto cifs_create_set_dentry;
-               else if ((rc != -EIO) && (rc != -EREMOTE) &&
+               if (rc == 0) {
+                       posix_create = true;
+                       if (newinode == NULL) /* query inode info */
+                               goto cifs_create_get_file_info;
+                       else /* success, no need to query */
+                               goto cifs_create_set_dentry;
+               } else if ((rc != -EIO) && (rc != -EREMOTE) &&
                         (rc != -EOPNOTSUPP)) /* path not found or net err */
                        goto cifs_create_out;
                /* else fallthrough to retry, using older open call, this is
@@ -466,7 +467,7 @@ cifs_create_set_dentry:
        if ((nd == NULL) || (!(nd->flags & LOOKUP_OPEN))) {
                /* mknod case - do not leave file open */
                CIFSSMBClose(xid, tcon, fileHandle);
-       } else if (newinode) {
+       } else if (!(posix_create) && (newinode)) {
                        cifs_fill_fileinfo(newinode, fileHandle,
                                        cifs_sb->tcon, write_only);
        }
@@ -663,11 +664,21 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
                        if (!((nd->intent.open.flags & O_CREAT) &&
                                        (nd->intent.open.flags & O_EXCL))) {
                                mode = nd->intent.open.create_mode &
-                                               ~current->fs->umask;
+                                               ~current_umask();
                                rc = cifs_posix_open(full_path, &newInode,
                                        parent_dir_inode->i_sb, mode,
                                        nd->intent.open.flags, &oplock,
                                        &fileHandle, xid);
+                               /*
+                                * This code works around a bug in
+                                * samba posix open in samba versions 3.3.1
+                                * and earlier where create works
+                                * but open fails with invalid parameter.
+                                * If either of these error codes are
+                                * returned, follow the normal lookup.
+                                * Otherwise, the error during posix open
+                                * is handled.
+                                */
                                if ((rc != -EINVAL) && (rc != -EOPNOTSUPP))
                                        posix_open = true;
                        }