]> err.no Git - linux-2.6/blobdiff - fs/cifs/readdir.c
Merge branch 'atmel'
[linux-2.6] / fs / cifs / readdir.c
index 487221eeddb7c1daf34919ee7a3d966348bfdf9c..a86bd1c076021bb88bec0da95a4d939b0785d69d 100644 (file)
@@ -91,7 +91,10 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
                }
 
                *ptmp_inode = new_inode(file->f_dentry->d_sb);
-               tmp_dentry->d_op = &cifs_dentry_ops;
+               if (pTcon->nocase)
+                       tmp_dentry->d_op = &cifs_ci_dentry_ops;
+               else
+                       tmp_dentry->d_op = &cifs_dentry_ops;
                if(*ptmp_inode == NULL)
                        return rc;
                rc = 1;
@@ -148,6 +151,13 @@ static void fill_in_inode(struct inode *tmp_inode,
                        tmp_inode->i_mode = cifs_sb->mnt_dir_mode;
                }
                tmp_inode->i_mode |= S_IFDIR;
+       } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) && 
+                  (attr & ATTR_SYSTEM) && (end_of_file == 0)) {
+               *pobject_type = DT_FIFO;
+               tmp_inode->i_mode |= S_IFIFO;
+/* BB Finish for SFU style symlinks and devies */
+/*     } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) &&
+               (attr & ATTR_SYSTEM) && ) { */
 /* we no longer mark these because we could not follow them */
 /*        } else if (attr & ATTR_REPARSE) {
                 *pobject_type = DT_LNK;
@@ -187,8 +197,13 @@ static void fill_in_inode(struct inode *tmp_inode,
                        tmp_inode->i_fop = &cifs_file_direct_ops;
                else
                        tmp_inode->i_fop = &cifs_file_ops;
+               if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
+                       tmp_inode->i_fop->lock = NULL;
                tmp_inode->i_data.a_ops = &cifs_addr_ops;
-
+               if((cifs_sb->tcon) && (cifs_sb->tcon->ses) &&
+                  (cifs_sb->tcon->ses->server->maxBuf <
+                       4096 + MAX_CIFS_HDR_SIZE))
+                       tmp_inode->i_data.a_ops->readpages = NULL;
                if(isNewInode)
                        return; /* No sense invalidating pages for new inode
                                   since have not started caching readahead file
@@ -291,7 +306,13 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
                        tmp_inode->i_fop = &cifs_file_direct_ops;
                else
                        tmp_inode->i_fop = &cifs_file_ops;
+               if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
+                       tmp_inode->i_fop->lock = NULL;
                tmp_inode->i_data.a_ops = &cifs_addr_ops;
+               if((cifs_sb->tcon) && (cifs_sb->tcon->ses) &&
+                  (cifs_sb->tcon->ses->server->maxBuf < 
+                       4096 + MAX_CIFS_HDR_SIZE))
+                       tmp_inode->i_data.a_ops->readpages = NULL;
 
                if(isNewInode)
                        return; /* No sense invalidating pages for new inode since we
@@ -375,7 +396,8 @@ ffirst_retry:
 
        rc = CIFSFindFirst(xid, pTcon,full_path,cifs_sb->local_nls,
                &cifsFile->netfid, &cifsFile->srch_inf,
-               cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
+               cifs_sb->mnt_cifs_flags & 
+                       CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb));
        if(rc == 0)
                cifsFile->invalidHandle = FALSE;
        if((rc == -EOPNOTSUPP) && 
@@ -492,6 +514,30 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
        return rc;
 }
 
+/* Check if directory that we are searching has changed so we can decide
+   whether we can use the cached search results from the previous search */
+static int is_dir_changed(struct file * file)
+{
+       struct inode * inode;
+       struct cifsInodeInfo *cifsInfo;
+
+       if(file->f_dentry == NULL)
+               return 0;
+
+       inode = file->f_dentry->d_inode;
+
+       if(inode == NULL)
+               return 0;
+
+       cifsInfo = CIFS_I(inode);
+
+       if(cifsInfo->time == 0)
+               return 1; /* directory was changed, perhaps due to unlink */
+       else
+               return 0;
+
+}
+
 /* find the corresponding entry in the search */
 /* Note that the SMB server returns search entries for . and .. which
    complicates logic here if we choose to parse for them and we do not
@@ -508,7 +554,8 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
        struct cifsFileInfo * cifsFile = file->private_data;
        /* check if index in the buffer */
        
-       if((cifsFile == NULL) || (ppCurrentEntry == NULL) || (num_to_ret == NULL))
+       if((cifsFile == NULL) || (ppCurrentEntry == NULL) || 
+          (num_to_ret == NULL))
                return -ENOENT;
        
        *ppCurrentEntry = NULL;
@@ -516,7 +563,9 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
                cifsFile->srch_inf.index_of_last_entry - 
                        cifsFile->srch_inf.entries_in_buffer;
 /*     dump_cifs_file_struct(file, "In fce ");*/
-       if(index_to_find < first_entry_in_buffer) {
+       if(((index_to_find < cifsFile->srch_inf.index_of_last_entry) && 
+            is_dir_changed(file)) || 
+          (index_to_find < first_entry_in_buffer)) {
                /* close and restart search */
                cFYI(1,("search backing up - close and restart search"));
                cifsFile->invalidHandle = TRUE;
@@ -550,7 +599,6 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
                char * end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + 
                        smbCalcSize((struct smb_hdr *)
                                cifsFile->srch_inf.ntwrk_buf_start);
-/*     dump_cifs_file_struct(file,"found entry in fce "); */
                first_entry_in_buffer = cifsFile->srch_inf.index_of_last_entry
                                        - cifsFile->srch_inf.entries_in_buffer;
                pos_in_buf = index_to_find - first_entry_in_buffer;
@@ -584,11 +632,10 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
        }
 
        if(pos_in_buf >= cifsFile->srch_inf.entries_in_buffer) {
-               cFYI(1,("can not return entries when pos_in_buf beyond last entry"));
+               cFYI(1,("can not return entries pos_in_buf beyond last entry"));
                *num_to_ret = 0;
        } else
                *num_to_ret = cifsFile->srch_inf.entries_in_buffer - pos_in_buf;
-/*     dump_cifs_file_struct(file, "end fce ");*/
 
        return rc;
 }
@@ -808,15 +855,12 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
                FreeXid(xid);
                return -EIO;
        }
-/*     dump_cifs_file_struct(file, "Begin rdir "); */
 
        cifs_sb = CIFS_SB(file->f_dentry->d_sb);
        pTcon = cifs_sb->tcon;
        if(pTcon == NULL)
                return -EINVAL;
 
-/*     cFYI(1,("readdir2 pos: %lld",file->f_pos)); */
-
        switch ((int) file->f_pos) {
        case 0:
                /*if (filldir(direntry, ".", 1, file->f_pos,
@@ -869,7 +913,6 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
                cifsFile->search_resume_name = NULL; */
 
                /* BB account for . and .. in f_pos as special case */
-               /* dump_cifs_file_struct(file, "rdir after default ");*/
 
                rc = find_cifs_entry(xid,pTcon, file,
                                &current_entry,&num_to_fill);
@@ -917,7 +960,6 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
        } /* end switch */
 
 rddir2_exit:
-       /* dump_cifs_file_struct(file, "end rdir ");  */
        FreeXid(xid);
        return rc;
 }