aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/readdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/readdir.c')
-rw-r--r--fs/cifs/readdir.c84
1 files changed, 45 insertions, 39 deletions
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 34ec32100c72..83f306954883 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -132,6 +132,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
132 __u32 attr; 132 __u32 attr;
133 __u64 allocation_size; 133 __u64 allocation_size;
134 __u64 end_of_file; 134 __u64 end_of_file;
135 umode_t default_mode;
135 136
136 /* save mtime and size */ 137 /* save mtime and size */
137 local_mtime = tmp_inode->i_mtime; 138 local_mtime = tmp_inode->i_mtime;
@@ -187,48 +188,54 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
187 if (atomic_read(&cifsInfo->inUse) == 0) { 188 if (atomic_read(&cifsInfo->inUse) == 0) {
188 tmp_inode->i_uid = cifs_sb->mnt_uid; 189 tmp_inode->i_uid = cifs_sb->mnt_uid;
189 tmp_inode->i_gid = cifs_sb->mnt_gid; 190 tmp_inode->i_gid = cifs_sb->mnt_gid;
190 /* set default mode. will override for dirs below */ 191 }
191 tmp_inode->i_mode = cifs_sb->mnt_file_mode; 192
192 } else { 193 if (attr & ATTR_DIRECTORY)
193 /* mask off the type bits since it gets set 194 default_mode = cifs_sb->mnt_dir_mode;
194 below and we do not want to get two type 195 else
195 bits set */ 196 default_mode = cifs_sb->mnt_file_mode;
197
198 /* set initial permissions */
199 if ((atomic_read(&cifsInfo->inUse) == 0) ||
200 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) == 0)
201 tmp_inode->i_mode = default_mode;
202 else {
203 /* just reenable write bits if !ATTR_READONLY */
204 if ((tmp_inode->i_mode & S_IWUGO) == 0 &&
205 (attr & ATTR_READONLY) == 0)
206 tmp_inode->i_mode |= (S_IWUGO & default_mode);
207
196 tmp_inode->i_mode &= ~S_IFMT; 208 tmp_inode->i_mode &= ~S_IFMT;
197 } 209 }
198 210
199 if (attr & ATTR_DIRECTORY) { 211 /* clear write bits if ATTR_READONLY is set */
200 *pobject_type = DT_DIR; 212 if (attr & ATTR_READONLY)
201 /* override default perms since we do not lock dirs */ 213 tmp_inode->i_mode &= ~S_IWUGO;
202 if (atomic_read(&cifsInfo->inUse) == 0) 214
203 tmp_inode->i_mode = cifs_sb->mnt_dir_mode; 215 /* set inode type */
204 tmp_inode->i_mode |= S_IFDIR; 216 if ((attr & ATTR_SYSTEM) &&
205 } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) && 217 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)) {
206 (attr & ATTR_SYSTEM)) {
207 if (end_of_file == 0) { 218 if (end_of_file == 0) {
208 *pobject_type = DT_FIFO;
209 tmp_inode->i_mode |= S_IFIFO; 219 tmp_inode->i_mode |= S_IFIFO;
220 *pobject_type = DT_FIFO;
210 } else { 221 } else {
211 /* rather than get the type here, we mark the 222 /*
212 inode as needing revalidate and get the real type 223 * trying to get the type can be slow, so just call
213 (blk vs chr vs. symlink) later ie in lookup */ 224 * this a regular file for now, and mark for reval
214 *pobject_type = DT_REG; 225 */
215 tmp_inode->i_mode |= S_IFREG; 226 tmp_inode->i_mode |= S_IFREG;
227 *pobject_type = DT_REG;
216 cifsInfo->time = 0; 228 cifsInfo->time = 0;
217 } 229 }
218/* we no longer mark these because we could not follow them */
219/* } else if (attr & ATTR_REPARSE) {
220 *pobject_type = DT_LNK;
221 tmp_inode->i_mode |= S_IFLNK; */
222 } else { 230 } else {
223 *pobject_type = DT_REG; 231 if (attr & ATTR_DIRECTORY) {
224 tmp_inode->i_mode |= S_IFREG; 232 tmp_inode->i_mode |= S_IFDIR;
225 if (attr & ATTR_READONLY) 233 *pobject_type = DT_DIR;
226 tmp_inode->i_mode &= ~(S_IWUGO); 234 } else {
227 else if ((tmp_inode->i_mode & S_IWUGO) == 0) 235 tmp_inode->i_mode |= S_IFREG;
228 /* the ATTR_READONLY flag may have been changed on */ 236 *pobject_type = DT_REG;
229 /* server -- set any w bits allowed by mnt_file_mode */ 237 }
230 tmp_inode->i_mode |= (S_IWUGO & cifs_sb->mnt_file_mode); 238 }
231 } /* could add code here - to validate if device or weird share type? */
232 239
233 /* can not fill in nlink here as in qpathinfo version and Unx search */ 240 /* can not fill in nlink here as in qpathinfo version and Unx search */
234 if (atomic_read(&cifsInfo->inUse) == 0) 241 if (atomic_read(&cifsInfo->inUse) == 0)
@@ -670,10 +677,11 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
670 (index_to_find < first_entry_in_buffer)) { 677 (index_to_find < first_entry_in_buffer)) {
671 /* close and restart search */ 678 /* close and restart search */
672 cFYI(1, ("search backing up - close and restart search")); 679 cFYI(1, ("search backing up - close and restart search"));
673 cifsFile->invalidHandle = true; 680 if (!cifsFile->srch_inf.endOfSearch &&
674 CIFSFindClose(xid, pTcon, cifsFile->netfid); 681 !cifsFile->invalidHandle) {
675 kfree(cifsFile->search_resume_name); 682 cifsFile->invalidHandle = true;
676 cifsFile->search_resume_name = NULL; 683 CIFSFindClose(xid, pTcon, cifsFile->netfid);
684 }
677 if (cifsFile->srch_inf.ntwrk_buf_start) { 685 if (cifsFile->srch_inf.ntwrk_buf_start) {
678 cFYI(1, ("freeing SMB ff cache buf on search rewind")); 686 cFYI(1, ("freeing SMB ff cache buf on search rewind"));
679 if (cifsFile->srch_inf.smallBuf) 687 if (cifsFile->srch_inf.smallBuf)
@@ -1040,9 +1048,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
1040 } /* else { 1048 } /* else {
1041 cifsFile->invalidHandle = true; 1049 cifsFile->invalidHandle = true;
1042 CIFSFindClose(xid, pTcon, cifsFile->netfid); 1050 CIFSFindClose(xid, pTcon, cifsFile->netfid);
1043 } 1051 } */
1044 kfree(cifsFile->search_resume_name);
1045 cifsFile->search_resume_name = NULL; */
1046 1052
1047 rc = find_cifs_entry(xid, pTcon, file, 1053 rc = find_cifs_entry(xid, pTcon, file,
1048 &current_entry, &num_to_fill); 1054 &current_entry, &num_to_fill);