Skip to content

Commit 9feed6f

Browse files
Christoph HellwigSteve French
authored andcommitted
cifs: cleanup cifs_filldir
Use sensible variable names and formatting and remove some superflous checks on entry. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 02f8c6a commit 9feed6f

File tree

1 file changed

+36
-44
lines changed

1 file changed

+36
-44
lines changed

fs/cifs/readdir.c

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -681,57 +681,49 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
681681
return rc;
682682
}
683683

684-
static int cifs_filldir(char *pfindEntry, struct file *file, filldir_t filldir,
685-
void *direntry, char *scratch_buf, unsigned int max_len)
684+
static int cifs_filldir(char *find_entry, struct file *file, filldir_t filldir,
685+
void *dirent, char *scratch_buf, unsigned int max_len)
686686
{
687-
int rc = 0;
688-
struct qstr qstring;
689-
struct cifsFileInfo *pCifsF;
690-
u64 inum;
691-
ino_t ino;
692-
struct super_block *sb;
693-
struct cifs_sb_info *cifs_sb;
694-
struct dentry *tmp_dentry;
687+
struct cifsFileInfo *file_info = file->private_data;
688+
struct super_block *sb = file->f_path.dentry->d_sb;
689+
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
695690
struct cifs_fattr fattr;
691+
struct dentry *dentry;
692+
struct qstr name;
693+
int rc = 0;
694+
u64 inum;
695+
ino_t ino;
696696

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);
709697
/* skip . and .. since we added them first */
698+
rc = cifs_entry_is_dot(find_entry, file_info);
710699
if (rc != 0)
711700
return 0;
712701

713-
sb = file->f_path.dentry->d_sb;
714-
cifs_sb = CIFS_SB(sb);
715-
716-
qstring.name = scratch_buf;
717-
rc = cifs_get_name_from_search_buf(&qstring, pfindEntry,
718-
pCifsF->srch_inf.info_level,
719-
pCifsF->srch_inf.unicode, cifs_sb,
720-
max_len, &inum /* returned */);
721-
702+
name.name = scratch_buf;
703+
rc = cifs_get_name_from_search_buf(&name, find_entry,
704+
file_info->srch_inf.info_level,
705+
file_info->srch_inf.unicode,
706+
cifs_sb, max_len, &inum);
722707
if (rc)
723708
return rc;
724709

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:
726712
cifs_unix_basic_to_fattr(&fattr,
727-
&((FILE_UNIX_INFO *) pfindEntry)->basic,
728-
cifs_sb);
729-
else if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD)
730-
cifs_std_info_to_fattr(&fattr, (FIND_FILE_STANDARD_INFO *)
731-
pfindEntry, cifs_sb);
732-
else
733-
cifs_dir_info_to_fattr(&fattr, (FILE_DIRECTORY_INFO *)
734-
pfindEntry, cifs_sb);
713+
&((FILE_UNIX_INFO *)find_entry)->basic,
714+
cifs_sb);
715+
break;
716+
case SMB_FIND_FILE_INFO_STANDARD:
717+
cifs_std_info_to_fattr(&fattr,
718+
(FIND_FILE_STANDARD_INFO *)find_entry,
719+
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+
}
735727

736728
if (inum && (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) {
737729
fattr.cf_uniqueid = inum;
@@ -750,12 +742,12 @@ static int cifs_filldir(char *pfindEntry, struct file *file, filldir_t filldir,
750742
fattr.cf_flags |= CIFS_FATTR_NEED_REVAL;
751743

752744
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);
754746

755-
rc = filldir(direntry, qstring.name, qstring.len, file->f_pos,
756-
ino, fattr.cf_dtype);
747+
rc = filldir(dirent, name.name, name.len, file->f_pos, ino,
748+
fattr.cf_dtype);
757749

758-
dput(tmp_dentry);
750+
dput(dentry);
759751
return rc;
760752
}
761753

0 commit comments

Comments
 (0)