diff options
-rw-r--r-- | fs/cifs/readdir.c | 80 |
1 files changed, 36 insertions, 44 deletions
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index 6751e745bbc6..04c9b9fbebb4 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c | |||
@@ -681,57 +681,49 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst, | |||
681 | return rc; | 681 | return rc; |
682 | } | 682 | } |
683 | 683 | ||
684 | static int cifs_filldir(char *pfindEntry, struct file *file, filldir_t filldir, | 684 | static int cifs_filldir(char *find_entry, struct file *file, filldir_t filldir, |
685 | void *direntry, char *scratch_buf, unsigned int max_len) | 685 | void *dirent, char *scratch_buf, unsigned int max_len) |
686 | { | 686 | { |
687 | int rc = 0; | 687 | struct cifsFileInfo *file_info = file->private_data; |
688 | struct qstr qstring; | 688 | struct super_block *sb = file->f_path.dentry->d_sb; |
689 | struct cifsFileInfo *pCifsF; | 689 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); |
690 | u64 inum; | ||
691 | ino_t ino; | ||
692 | struct super_block *sb; | ||
693 | struct cifs_sb_info *cifs_sb; | ||
694 | struct dentry *tmp_dentry; | ||
695 | struct cifs_fattr fattr; | 690 | struct cifs_fattr fattr; |
691 | struct dentry *dentry; | ||
692 | struct qstr name; | ||
693 | int rc = 0; | ||
694 | u64 inum; | ||
695 | ino_t ino; | ||
696 | 696 | ||
697 | /* get filename and len into qstring */ | ||
698 | /* get dentry */ | ||
699 | /* decide whether to create and populate ionde */ | ||
700 | if ((direntry == NULL) || (file == NULL)) | ||
701 | return -EINVAL; | ||
702 | |||
703 | pCifsF = file->private_data; | ||
704 | |||
705 | if ((scratch_buf == NULL) || (pfindEntry == NULL) || (pCifsF == NULL)) | ||
706 | return -ENOENT; | ||
707 | |||
708 | rc = cifs_entry_is_dot(pfindEntry, pCifsF); | ||
709 | /* skip . and .. since we added them first */ | 697 | /* skip . and .. since we added them first */ |
698 | rc = cifs_entry_is_dot(find_entry, file_info); | ||
710 | if (rc != 0) | 699 | if (rc != 0) |
711 | return 0; | 700 | return 0; |
712 | 701 | ||
713 | sb = file->f_path.dentry->d_sb; | 702 | name.name = scratch_buf; |
714 | cifs_sb = CIFS_SB(sb); | 703 | rc = cifs_get_name_from_search_buf(&name, find_entry, |
715 | 704 | file_info->srch_inf.info_level, | |
716 | qstring.name = scratch_buf; | 705 | file_info->srch_inf.unicode, |
717 | rc = cifs_get_name_from_search_buf(&qstring, pfindEntry, | 706 | cifs_sb, max_len, &inum); |
718 | pCifsF->srch_inf.info_level, | ||
719 | pCifsF->srch_inf.unicode, cifs_sb, | ||
720 | max_len, &inum /* returned */); | ||
721 | |||
722 | if (rc) | 707 | if (rc) |
723 | return rc; | 708 | return rc; |
724 | 709 | ||
725 | if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX) | 710 | switch (file_info->srch_inf.info_level) { |
711 | case SMB_FIND_FILE_UNIX: | ||
726 | cifs_unix_basic_to_fattr(&fattr, | 712 | cifs_unix_basic_to_fattr(&fattr, |
727 | &((FILE_UNIX_INFO *) pfindEntry)->basic, | 713 | &((FILE_UNIX_INFO *)find_entry)->basic, |
728 | cifs_sb); | 714 | cifs_sb); |
729 | else if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) | 715 | break; |
730 | cifs_std_info_to_fattr(&fattr, (FIND_FILE_STANDARD_INFO *) | 716 | case SMB_FIND_FILE_INFO_STANDARD: |
731 | pfindEntry, cifs_sb); | 717 | cifs_std_info_to_fattr(&fattr, |
732 | else | 718 | (FIND_FILE_STANDARD_INFO *)find_entry, |
733 | cifs_dir_info_to_fattr(&fattr, (FILE_DIRECTORY_INFO *) | 719 | cifs_sb); |
734 | pfindEntry, cifs_sb); | 720 | break; |
721 | default: | ||
722 | cifs_dir_info_to_fattr(&fattr, | ||
723 | (FILE_DIRECTORY_INFO *)find_entry, | ||
724 | cifs_sb); | ||
725 | break; | ||
726 | } | ||
735 | 727 | ||
736 | if (inum && (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { | 728 | if (inum && (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { |
737 | fattr.cf_uniqueid = inum; | 729 | fattr.cf_uniqueid = inum; |
@@ -750,12 +742,12 @@ static int cifs_filldir(char *pfindEntry, struct file *file, filldir_t filldir, | |||
750 | fattr.cf_flags |= CIFS_FATTR_NEED_REVAL; | 742 | fattr.cf_flags |= CIFS_FATTR_NEED_REVAL; |
751 | 743 | ||
752 | ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid); | 744 | ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid); |
753 | tmp_dentry = cifs_readdir_lookup(file->f_dentry, &qstring, &fattr); | 745 | dentry = cifs_readdir_lookup(file->f_dentry, &name, &fattr); |
754 | 746 | ||
755 | rc = filldir(direntry, qstring.name, qstring.len, file->f_pos, | 747 | rc = filldir(dirent, name.name, name.len, file->f_pos, ino, |
756 | ino, fattr.cf_dtype); | 748 | fattr.cf_dtype); |
757 | 749 | ||
758 | dput(tmp_dentry); | 750 | dput(dentry); |
759 | return rc; | 751 | return rc; |
760 | } | 752 | } |
761 | 753 | ||