aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/readdir.c
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2007-04-30 16:13:06 -0400
committerSteve French <sfrench@us.ibm.com>2007-04-30 16:13:06 -0400
commit4523cc3044d1bc7fcf3d7fee75d62bc76b8e1abb (patch)
tree31c2b6c0a81f14ec812d09586eb8ef5a586743cb /fs/cifs/readdir.c
parent984acfe1cfb613257a15f30b3cf60ae7e4ed8f06 (diff)
[CIFS] UID/GID override on CIFS mounts to Samba
When CIFS Unix Extensions are negotiated we get the Unix uid and gid owners of the file from the server (on the Unix Query Path Info levels), but if the server's uids don't match the client uid's users were having to disable the Unix Extensions (which turned off features they still wanted). The changeset patch allows users to override uid and/or gid for file/directory owner with a default uid and/or gid specified at mount (as is often done when mounting from Linux cifs client to Windows server). This changeset also displays the uid and gid used by default in /proc/mounts (if applicable). Also cleans up code by adding some of the missing spaces after "if" keywords per-kernel style guidelines (as suggested by Randy Dunlap when he reviewed the patch). Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/readdir.c')
-rw-r--r--fs/cifs/readdir.c129
1 files changed, 67 insertions, 62 deletions
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index b80b0fc1c4c..b5364f90d55 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -37,19 +37,19 @@ static void dump_cifs_file_struct(struct file *file, char *label)
37{ 37{
38 struct cifsFileInfo * cf; 38 struct cifsFileInfo * cf;
39 39
40 if(file) { 40 if (file) {
41 cf = file->private_data; 41 cf = file->private_data;
42 if(cf == NULL) { 42 if (cf == NULL) {
43 cFYI(1,("empty cifs private file data")); 43 cFYI(1,("empty cifs private file data"));
44 return; 44 return;
45 } 45 }
46 if(cf->invalidHandle) { 46 if (cf->invalidHandle) {
47 cFYI(1,("invalid handle")); 47 cFYI(1,("invalid handle"));
48 } 48 }
49 if(cf->srch_inf.endOfSearch) { 49 if (cf->srch_inf.endOfSearch) {
50 cFYI(1,("end of search")); 50 cFYI(1,("end of search"));
51 } 51 }
52 if(cf->srch_inf.emptyDir) { 52 if (cf->srch_inf.emptyDir) {
53 cFYI(1,("empty dir")); 53 cFYI(1,("empty dir"));
54 } 54 }
55 55
@@ -77,17 +77,17 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
77 cFYI(0, ("existing dentry with inode 0x%p", tmp_dentry->d_inode)); 77 cFYI(0, ("existing dentry with inode 0x%p", tmp_dentry->d_inode));
78 *ptmp_inode = tmp_dentry->d_inode; 78 *ptmp_inode = tmp_dentry->d_inode;
79/* BB overwrite old name? i.e. tmp_dentry->d_name and tmp_dentry->d_name.len??*/ 79/* BB overwrite old name? i.e. tmp_dentry->d_name and tmp_dentry->d_name.len??*/
80 if(*ptmp_inode == NULL) { 80 if (*ptmp_inode == NULL) {
81 *ptmp_inode = new_inode(file->f_path.dentry->d_sb); 81 *ptmp_inode = new_inode(file->f_path.dentry->d_sb);
82 if(*ptmp_inode == NULL) 82 if (*ptmp_inode == NULL)
83 return rc; 83 return rc;
84 rc = 1; 84 rc = 1;
85 } 85 }
86 if(file->f_path.dentry->d_sb->s_flags & MS_NOATIME) 86 if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME)
87 (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME; 87 (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME;
88 } else { 88 } else {
89 tmp_dentry = d_alloc(file->f_path.dentry, qstring); 89 tmp_dentry = d_alloc(file->f_path.dentry, qstring);
90 if(tmp_dentry == NULL) { 90 if (tmp_dentry == NULL) {
91 cERROR(1,("Failed allocating dentry")); 91 cERROR(1,("Failed allocating dentry"));
92 *ptmp_inode = NULL; 92 *ptmp_inode = NULL;
93 return rc; 93 return rc;
@@ -98,9 +98,9 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
98 tmp_dentry->d_op = &cifs_ci_dentry_ops; 98 tmp_dentry->d_op = &cifs_ci_dentry_ops;
99 else 99 else
100 tmp_dentry->d_op = &cifs_dentry_ops; 100 tmp_dentry->d_op = &cifs_dentry_ops;
101 if(*ptmp_inode == NULL) 101 if (*ptmp_inode == NULL)
102 return rc; 102 return rc;
103 if(file->f_path.dentry->d_sb->s_flags & MS_NOATIME) 103 if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME)
104 (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME; 104 (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME;
105 rc = 2; 105 rc = 2;
106 } 106 }
@@ -112,7 +112,7 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
112 112
113static void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode) 113static void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode)
114{ 114{
115 if((tcon) && (tcon->ses) && (tcon->ses->server)) { 115 if ((tcon) && (tcon->ses) && (tcon->ses->server)) {
116 inode->i_ctime.tv_sec += tcon->ses->server->timeAdj; 116 inode->i_ctime.tv_sec += tcon->ses->server->timeAdj;
117 inode->i_mtime.tv_sec += tcon->ses->server->timeAdj; 117 inode->i_mtime.tv_sec += tcon->ses->server->timeAdj;
118 inode->i_atime.tv_sec += tcon->ses->server->timeAdj; 118 inode->i_atime.tv_sec += tcon->ses->server->timeAdj;
@@ -137,7 +137,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
137 local_mtime = tmp_inode->i_mtime; 137 local_mtime = tmp_inode->i_mtime;
138 local_size = tmp_inode->i_size; 138 local_size = tmp_inode->i_size;
139 139
140 if(new_buf_type) { 140 if (new_buf_type) {
141 FILE_DIRECTORY_INFO *pfindData = (FILE_DIRECTORY_INFO *)buf; 141 FILE_DIRECTORY_INFO *pfindData = (FILE_DIRECTORY_INFO *)buf;
142 142
143 attr = le32_to_cpu(pfindData->ExtFileAttributes); 143 attr = le32_to_cpu(pfindData->ExtFileAttributes);
@@ -193,7 +193,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
193 if (attr & ATTR_DIRECTORY) { 193 if (attr & ATTR_DIRECTORY) {
194 *pobject_type = DT_DIR; 194 *pobject_type = DT_DIR;
195 /* override default perms since we do not lock dirs */ 195 /* override default perms since we do not lock dirs */
196 if(atomic_read(&cifsInfo->inUse) == 0) { 196 if (atomic_read(&cifsInfo->inUse) == 0) {
197 tmp_inode->i_mode = cifs_sb->mnt_dir_mode; 197 tmp_inode->i_mode = cifs_sb->mnt_dir_mode;
198 } 198 }
199 tmp_inode->i_mode |= S_IFDIR; 199 tmp_inode->i_mode |= S_IFDIR;
@@ -250,25 +250,25 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
250 if (S_ISREG(tmp_inode->i_mode)) { 250 if (S_ISREG(tmp_inode->i_mode)) {
251 cFYI(1, ("File inode")); 251 cFYI(1, ("File inode"));
252 tmp_inode->i_op = &cifs_file_inode_ops; 252 tmp_inode->i_op = &cifs_file_inode_ops;
253 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { 253 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
254 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) 254 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
255 tmp_inode->i_fop = &cifs_file_direct_nobrl_ops; 255 tmp_inode->i_fop = &cifs_file_direct_nobrl_ops;
256 else 256 else
257 tmp_inode->i_fop = &cifs_file_direct_ops; 257 tmp_inode->i_fop = &cifs_file_direct_ops;
258 258
259 } else if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) 259 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
260 tmp_inode->i_fop = &cifs_file_nobrl_ops; 260 tmp_inode->i_fop = &cifs_file_nobrl_ops;
261 else 261 else
262 tmp_inode->i_fop = &cifs_file_ops; 262 tmp_inode->i_fop = &cifs_file_ops;
263 263
264 if((cifs_sb->tcon) && (cifs_sb->tcon->ses) && 264 if ((cifs_sb->tcon) && (cifs_sb->tcon->ses) &&
265 (cifs_sb->tcon->ses->server->maxBuf < 265 (cifs_sb->tcon->ses->server->maxBuf <
266 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) 266 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE))
267 tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; 267 tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
268 else 268 else
269 tmp_inode->i_data.a_ops = &cifs_addr_ops; 269 tmp_inode->i_data.a_ops = &cifs_addr_ops;
270 270
271 if(isNewInode) 271 if (isNewInode)
272 return; /* No sense invalidating pages for new inode 272 return; /* No sense invalidating pages for new inode
273 since have not started caching readahead file 273 since have not started caching readahead file
274 data yet */ 274 data yet */
@@ -357,8 +357,14 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
357 cFYI(1,("unknown inode type %d",type)); 357 cFYI(1,("unknown inode type %d",type));
358 } 358 }
359 359
360 tmp_inode->i_uid = le64_to_cpu(pfindData->Uid); 360 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
361 tmp_inode->i_gid = le64_to_cpu(pfindData->Gid); 361 tmp_inode->i_uid = cifs_sb->mnt_uid;
362 else
363 tmp_inode->i_uid = le64_to_cpu(pfindData->Uid);
364 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)
365 tmp_inode->i_gid = cifs_sb->mnt_gid;
366 else
367 tmp_inode->i_gid = le64_to_cpu(pfindData->Gid);
362 tmp_inode->i_nlink = le64_to_cpu(pfindData->Nlinks); 368 tmp_inode->i_nlink = le64_to_cpu(pfindData->Nlinks);
363 369
364 spin_lock(&tmp_inode->i_lock); 370 spin_lock(&tmp_inode->i_lock);
@@ -377,25 +383,24 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
377 cFYI(1, ("File inode")); 383 cFYI(1, ("File inode"));
378 tmp_inode->i_op = &cifs_file_inode_ops; 384 tmp_inode->i_op = &cifs_file_inode_ops;
379 385
380 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { 386 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
381 if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) 387 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
382 tmp_inode->i_fop = &cifs_file_direct_nobrl_ops; 388 tmp_inode->i_fop = &cifs_file_direct_nobrl_ops;
383 else 389 else
384 tmp_inode->i_fop = &cifs_file_direct_ops; 390 tmp_inode->i_fop = &cifs_file_direct_ops;
385 391 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
386 } else if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
387 tmp_inode->i_fop = &cifs_file_nobrl_ops; 392 tmp_inode->i_fop = &cifs_file_nobrl_ops;
388 else 393 else
389 tmp_inode->i_fop = &cifs_file_ops; 394 tmp_inode->i_fop = &cifs_file_ops;
390 395
391 if((cifs_sb->tcon) && (cifs_sb->tcon->ses) && 396 if ((cifs_sb->tcon) && (cifs_sb->tcon->ses) &&
392 (cifs_sb->tcon->ses->server->maxBuf < 397 (cifs_sb->tcon->ses->server->maxBuf <
393 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) 398 PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE))
394 tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; 399 tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
395 else 400 else
396 tmp_inode->i_data.a_ops = &cifs_addr_ops; 401 tmp_inode->i_data.a_ops = &cifs_addr_ops;
397 402
398 if(isNewInode) 403 if (isNewInode)
399 return; /* No sense invalidating pages for new inode since we 404 return; /* No sense invalidating pages for new inode since we
400 have not started caching readahead file data yet */ 405 have not started caching readahead file data yet */
401 406
@@ -430,28 +435,28 @@ static int initiate_cifs_search(const int xid, struct file *file)
430 struct cifs_sb_info *cifs_sb; 435 struct cifs_sb_info *cifs_sb;
431 struct cifsTconInfo *pTcon; 436 struct cifsTconInfo *pTcon;
432 437
433 if(file->private_data == NULL) { 438 if (file->private_data == NULL) {
434 file->private_data = 439 file->private_data =
435 kzalloc(sizeof(struct cifsFileInfo),GFP_KERNEL); 440 kzalloc(sizeof(struct cifsFileInfo),GFP_KERNEL);
436 } 441 }
437 442
438 if(file->private_data == NULL) 443 if (file->private_data == NULL)
439 return -ENOMEM; 444 return -ENOMEM;
440 cifsFile = file->private_data; 445 cifsFile = file->private_data;
441 cifsFile->invalidHandle = TRUE; 446 cifsFile->invalidHandle = TRUE;
442 cifsFile->srch_inf.endOfSearch = FALSE; 447 cifsFile->srch_inf.endOfSearch = FALSE;
443 448
444 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 449 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
445 if(cifs_sb == NULL) 450 if (cifs_sb == NULL)
446 return -EINVAL; 451 return -EINVAL;
447 452
448 pTcon = cifs_sb->tcon; 453 pTcon = cifs_sb->tcon;
449 if(pTcon == NULL) 454 if (pTcon == NULL)
450 return -EINVAL; 455 return -EINVAL;
451 456
452 full_path = build_path_from_dentry(file->f_path.dentry); 457 full_path = build_path_from_dentry(file->f_path.dentry);
453 458
454 if(full_path == NULL) { 459 if (full_path == NULL) {
455 return -ENOMEM; 460 return -ENOMEM;
456 } 461 }
457 462
@@ -474,9 +479,9 @@ ffirst_retry:
474 &cifsFile->netfid, &cifsFile->srch_inf, 479 &cifsFile->netfid, &cifsFile->srch_inf,
475 cifs_sb->mnt_cifs_flags & 480 cifs_sb->mnt_cifs_flags &
476 CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb)); 481 CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb));
477 if(rc == 0) 482 if (rc == 0)
478 cifsFile->invalidHandle = FALSE; 483 cifsFile->invalidHandle = FALSE;
479 if((rc == -EOPNOTSUPP) && 484 if ((rc == -EOPNOTSUPP) &&
480 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { 485 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) {
481 cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM; 486 cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM;
482 goto ffirst_retry; 487 goto ffirst_retry;
@@ -492,7 +497,7 @@ static int cifs_unicode_bytelen(char *str)
492 __le16 * ustr = (__le16 *)str; 497 __le16 * ustr = (__le16 *)str;
493 498
494 for(len=0;len <= PATH_MAX;len++) { 499 for(len=0;len <= PATH_MAX;len++) {
495 if(ustr[len] == 0) 500 if (ustr[len] == 0)
496 return len << 1; 501 return len << 1;
497 } 502 }
498 cFYI(1,("Unicode string longer than PATH_MAX found")); 503 cFYI(1,("Unicode string longer than PATH_MAX found"));
@@ -504,7 +509,7 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level)
504 char * new_entry; 509 char * new_entry;
505 FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry; 510 FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry;
506 511
507 if(level == SMB_FIND_FILE_INFO_STANDARD) { 512 if (level == SMB_FIND_FILE_INFO_STANDARD) {
508 FIND_FILE_STANDARD_INFO * pfData; 513 FIND_FILE_STANDARD_INFO * pfData;
509 pfData = (FIND_FILE_STANDARD_INFO *)pDirInfo; 514 pfData = (FIND_FILE_STANDARD_INFO *)pDirInfo;
510 515
@@ -514,12 +519,12 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level)
514 new_entry = old_entry + le32_to_cpu(pDirInfo->NextEntryOffset); 519 new_entry = old_entry + le32_to_cpu(pDirInfo->NextEntryOffset);
515 cFYI(1,("new entry %p old entry %p",new_entry,old_entry)); 520 cFYI(1,("new entry %p old entry %p",new_entry,old_entry));
516 /* validate that new_entry is not past end of SMB */ 521 /* validate that new_entry is not past end of SMB */
517 if(new_entry >= end_of_smb) { 522 if (new_entry >= end_of_smb) {
518 cERROR(1, 523 cERROR(1,
519 ("search entry %p began after end of SMB %p old entry %p", 524 ("search entry %p began after end of SMB %p old entry %p",
520 new_entry, end_of_smb, old_entry)); 525 new_entry, end_of_smb, old_entry));
521 return NULL; 526 return NULL;
522 } else if(((level == SMB_FIND_FILE_INFO_STANDARD) && 527 } else if (((level == SMB_FIND_FILE_INFO_STANDARD) &&
523 (new_entry + sizeof(FIND_FILE_STANDARD_INFO) > end_of_smb)) || 528 (new_entry + sizeof(FIND_FILE_STANDARD_INFO) > end_of_smb)) ||
524 ((level != SMB_FIND_FILE_INFO_STANDARD) && 529 ((level != SMB_FIND_FILE_INFO_STANDARD) &&
525 (new_entry + sizeof(FILE_DIRECTORY_INFO) > end_of_smb))) { 530 (new_entry + sizeof(FILE_DIRECTORY_INFO) > end_of_smb))) {
@@ -540,39 +545,39 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
540 char * filename = NULL; 545 char * filename = NULL;
541 int len = 0; 546 int len = 0;
542 547
543 if(cfile->srch_inf.info_level == SMB_FIND_FILE_UNIX) { 548 if (cfile->srch_inf.info_level == SMB_FIND_FILE_UNIX) {
544 FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry; 549 FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry;
545 filename = &pFindData->FileName[0]; 550 filename = &pFindData->FileName[0];
546 if(cfile->srch_inf.unicode) { 551 if (cfile->srch_inf.unicode) {
547 len = cifs_unicode_bytelen(filename); 552 len = cifs_unicode_bytelen(filename);
548 } else { 553 } else {
549 /* BB should we make this strnlen of PATH_MAX? */ 554 /* BB should we make this strnlen of PATH_MAX? */
550 len = strnlen(filename, 5); 555 len = strnlen(filename, 5);
551 } 556 }
552 } else if(cfile->srch_inf.info_level == SMB_FIND_FILE_DIRECTORY_INFO) { 557 } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_DIRECTORY_INFO) {
553 FILE_DIRECTORY_INFO * pFindData = 558 FILE_DIRECTORY_INFO * pFindData =
554 (FILE_DIRECTORY_INFO *)current_entry; 559 (FILE_DIRECTORY_INFO *)current_entry;
555 filename = &pFindData->FileName[0]; 560 filename = &pFindData->FileName[0];
556 len = le32_to_cpu(pFindData->FileNameLength); 561 len = le32_to_cpu(pFindData->FileNameLength);
557 } else if(cfile->srch_inf.info_level == 562 } else if (cfile->srch_inf.info_level ==
558 SMB_FIND_FILE_FULL_DIRECTORY_INFO) { 563 SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
559 FILE_FULL_DIRECTORY_INFO * pFindData = 564 FILE_FULL_DIRECTORY_INFO * pFindData =
560 (FILE_FULL_DIRECTORY_INFO *)current_entry; 565 (FILE_FULL_DIRECTORY_INFO *)current_entry;
561 filename = &pFindData->FileName[0]; 566 filename = &pFindData->FileName[0];
562 len = le32_to_cpu(pFindData->FileNameLength); 567 len = le32_to_cpu(pFindData->FileNameLength);
563 } else if(cfile->srch_inf.info_level == 568 } else if (cfile->srch_inf.info_level ==
564 SMB_FIND_FILE_ID_FULL_DIR_INFO) { 569 SMB_FIND_FILE_ID_FULL_DIR_INFO) {
565 SEARCH_ID_FULL_DIR_INFO * pFindData = 570 SEARCH_ID_FULL_DIR_INFO * pFindData =
566 (SEARCH_ID_FULL_DIR_INFO *)current_entry; 571 (SEARCH_ID_FULL_DIR_INFO *)current_entry;
567 filename = &pFindData->FileName[0]; 572 filename = &pFindData->FileName[0];
568 len = le32_to_cpu(pFindData->FileNameLength); 573 len = le32_to_cpu(pFindData->FileNameLength);
569 } else if(cfile->srch_inf.info_level == 574 } else if (cfile->srch_inf.info_level ==
570 SMB_FIND_FILE_BOTH_DIRECTORY_INFO) { 575 SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
571 FILE_BOTH_DIRECTORY_INFO * pFindData = 576 FILE_BOTH_DIRECTORY_INFO * pFindData =
572 (FILE_BOTH_DIRECTORY_INFO *)current_entry; 577 (FILE_BOTH_DIRECTORY_INFO *)current_entry;
573 filename = &pFindData->FileName[0]; 578 filename = &pFindData->FileName[0];
574 len = le32_to_cpu(pFindData->FileNameLength); 579 len = le32_to_cpu(pFindData->FileNameLength);
575 } else if(cfile->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) { 580 } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) {
576 FIND_FILE_STANDARD_INFO * pFindData = 581 FIND_FILE_STANDARD_INFO * pFindData =
577 (FIND_FILE_STANDARD_INFO *)current_entry; 582 (FIND_FILE_STANDARD_INFO *)current_entry;
578 filename = &pFindData->FileName[0]; 583 filename = &pFindData->FileName[0];
@@ -581,25 +586,25 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
581 cFYI(1,("Unknown findfirst level %d",cfile->srch_inf.info_level)); 586 cFYI(1,("Unknown findfirst level %d",cfile->srch_inf.info_level));
582 } 587 }
583 588
584 if(filename) { 589 if (filename) {
585 if(cfile->srch_inf.unicode) { 590 if (cfile->srch_inf.unicode) {
586 __le16 *ufilename = (__le16 *)filename; 591 __le16 *ufilename = (__le16 *)filename;
587 if(len == 2) { 592 if (len == 2) {
588 /* check for . */ 593 /* check for . */
589 if(ufilename[0] == UNICODE_DOT) 594 if (ufilename[0] == UNICODE_DOT)
590 rc = 1; 595 rc = 1;
591 } else if(len == 4) { 596 } else if (len == 4) {
592 /* check for .. */ 597 /* check for .. */
593 if((ufilename[0] == UNICODE_DOT) 598 if ((ufilename[0] == UNICODE_DOT)
594 &&(ufilename[1] == UNICODE_DOT)) 599 &&(ufilename[1] == UNICODE_DOT))
595 rc = 2; 600 rc = 2;
596 } 601 }
597 } else /* ASCII */ { 602 } else /* ASCII */ {
598 if(len == 1) { 603 if (len == 1) {
599 if(filename[0] == '.') 604 if (filename[0] == '.')
600 rc = 1; 605 rc = 1;
601 } else if(len == 2) { 606 } else if (len == 2) {
602 if((filename[0] == '.') && (filename[1] == '.')) 607 if((filename[0] == '.') && (filename[1] == '.'))
603 rc = 2; 608 rc = 2;
604 } 609 }
605 } 610 }
@@ -638,7 +643,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
638 struct cifsFileInfo * cifsFile = file->private_data; 643 struct cifsFileInfo * cifsFile = file->private_data;
639 /* check if index in the buffer */ 644 /* check if index in the buffer */
640 645
641 if((cifsFile == NULL) || (ppCurrentEntry == NULL) || 646 if ((cifsFile == NULL) || (ppCurrentEntry == NULL) ||
642 (num_to_ret == NULL)) 647 (num_to_ret == NULL))
643 return -ENOENT; 648 return -ENOENT;
644 649
@@ -656,7 +661,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
656#ifdef CONFIG_CIFS_DEBUG2 661#ifdef CONFIG_CIFS_DEBUG2
657 dump_cifs_file_struct(file, "In fce "); 662 dump_cifs_file_struct(file, "In fce ");
658#endif 663#endif
659 if(((index_to_find < cifsFile->srch_inf.index_of_last_entry) && 664 if (((index_to_find < cifsFile->srch_inf.index_of_last_entry) &&
660 is_dir_changed(file)) || 665 is_dir_changed(file)) ||
661 (index_to_find < first_entry_in_buffer)) { 666 (index_to_find < first_entry_in_buffer)) {
662 /* close and restart search */ 667 /* close and restart search */
@@ -665,9 +670,9 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
665 CIFSFindClose(xid, pTcon, cifsFile->netfid); 670 CIFSFindClose(xid, pTcon, cifsFile->netfid);
666 kfree(cifsFile->search_resume_name); 671 kfree(cifsFile->search_resume_name);
667 cifsFile->search_resume_name = NULL; 672 cifsFile->search_resume_name = NULL;
668 if(cifsFile->srch_inf.ntwrk_buf_start) { 673 if (cifsFile->srch_inf.ntwrk_buf_start) {
669 cFYI(1,("freeing SMB ff cache buf on search rewind")); 674 cFYI(1,("freeing SMB ff cache buf on search rewind"));
670 if(cifsFile->srch_inf.smallBuf) 675 if (cifsFile->srch_inf.smallBuf)
671 cifs_small_buf_release(cifsFile->srch_inf. 676 cifs_small_buf_release(cifsFile->srch_inf.
672 ntwrk_buf_start); 677 ntwrk_buf_start);
673 else 678 else
@@ -675,7 +680,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
675 ntwrk_buf_start); 680 ntwrk_buf_start);
676 } 681 }
677 rc = initiate_cifs_search(xid,file); 682 rc = initiate_cifs_search(xid,file);
678 if(rc) { 683 if (rc) {
679 cFYI(1,("error %d reinitiating a search on rewind",rc)); 684 cFYI(1,("error %d reinitiating a search on rewind",rc));
680 return rc; 685 return rc;
681 } 686 }
@@ -686,10 +691,10 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
686 cFYI(1,("calling findnext2")); 691 cFYI(1,("calling findnext2"));
687 rc = CIFSFindNext(xid,pTcon,cifsFile->netfid, 692 rc = CIFSFindNext(xid,pTcon,cifsFile->netfid,
688 &cifsFile->srch_inf); 693 &cifsFile->srch_inf);
689 if(rc) 694 if (rc)
690 return -ENOENT; 695 return -ENOENT;
691 } 696 }
692 if(index_to_find < cifsFile->srch_inf.index_of_last_entry) { 697 if (index_to_find < cifsFile->srch_inf.index_of_last_entry) {
693 /* we found the buffer that contains the entry */ 698 /* we found the buffer that contains the entry */
694 /* scan and find it */ 699 /* scan and find it */
695 int i; 700 int i;