mirror of https://gitee.com/openkylin/linux.git
cifs: cleanup cifs_filldir
Use sensible variable names and formatting and remove some superflous checks on entry. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
parent
02f8c6aee8
commit
9feed6f8fb
|
@ -681,57 +681,49 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cifs_filldir(char *pfindEntry, struct file *file, filldir_t filldir,
|
static int cifs_filldir(char *find_entry, struct file *file, filldir_t filldir,
|
||||||
void *direntry, char *scratch_buf, unsigned int max_len)
|
void *dirent, char *scratch_buf, unsigned int max_len)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
struct cifsFileInfo *file_info = file->private_data;
|
||||||
struct qstr qstring;
|
struct super_block *sb = file->f_path.dentry->d_sb;
|
||||||
struct cifsFileInfo *pCifsF;
|
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
|
||||||
u64 inum;
|
|
||||||
ino_t ino;
|
|
||||||
struct super_block *sb;
|
|
||||||
struct cifs_sb_info *cifs_sb;
|
|
||||||
struct dentry *tmp_dentry;
|
|
||||||
struct cifs_fattr fattr;
|
struct cifs_fattr fattr;
|
||||||
|
struct dentry *dentry;
|
||||||
|
struct qstr name;
|
||||||
|
int rc = 0;
|
||||||
|
u64 inum;
|
||||||
|
ino_t ino;
|
||||||
|
|
||||||
/* get filename and len into qstring */
|
|
||||||
/* get dentry */
|
|
||||||
/* decide whether to create and populate ionde */
|
|
||||||
if ((direntry == NULL) || (file == NULL))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
pCifsF = file->private_data;
|
|
||||||
|
|
||||||
if ((scratch_buf == NULL) || (pfindEntry == NULL) || (pCifsF == NULL))
|
|
||||||
return -ENOENT;
|
|
||||||
|
|
||||||
rc = cifs_entry_is_dot(pfindEntry, pCifsF);
|
|
||||||
/* skip . and .. since we added them first */
|
/* skip . and .. since we added them first */
|
||||||
|
rc = cifs_entry_is_dot(find_entry, file_info);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
sb = file->f_path.dentry->d_sb;
|
name.name = scratch_buf;
|
||||||
cifs_sb = CIFS_SB(sb);
|
rc = cifs_get_name_from_search_buf(&name, find_entry,
|
||||||
|
file_info->srch_inf.info_level,
|
||||||
qstring.name = scratch_buf;
|
file_info->srch_inf.unicode,
|
||||||
rc = cifs_get_name_from_search_buf(&qstring, pfindEntry,
|
cifs_sb, max_len, &inum);
|
||||||
pCifsF->srch_inf.info_level,
|
|
||||||
pCifsF->srch_inf.unicode, cifs_sb,
|
|
||||||
max_len, &inum /* returned */);
|
|
||||||
|
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX)
|
switch (file_info->srch_inf.info_level) {
|
||||||
|
case SMB_FIND_FILE_UNIX:
|
||||||
cifs_unix_basic_to_fattr(&fattr,
|
cifs_unix_basic_to_fattr(&fattr,
|
||||||
&((FILE_UNIX_INFO *) pfindEntry)->basic,
|
&((FILE_UNIX_INFO *)find_entry)->basic,
|
||||||
cifs_sb);
|
cifs_sb);
|
||||||
else if (pCifsF->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD)
|
break;
|
||||||
cifs_std_info_to_fattr(&fattr, (FIND_FILE_STANDARD_INFO *)
|
case SMB_FIND_FILE_INFO_STANDARD:
|
||||||
pfindEntry, cifs_sb);
|
cifs_std_info_to_fattr(&fattr,
|
||||||
else
|
(FIND_FILE_STANDARD_INFO *)find_entry,
|
||||||
cifs_dir_info_to_fattr(&fattr, (FILE_DIRECTORY_INFO *)
|
cifs_sb);
|
||||||
pfindEntry, cifs_sb);
|
break;
|
||||||
|
default:
|
||||||
|
cifs_dir_info_to_fattr(&fattr,
|
||||||
|
(FILE_DIRECTORY_INFO *)find_entry,
|
||||||
|
cifs_sb);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (inum && (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) {
|
if (inum && (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) {
|
||||||
fattr.cf_uniqueid = inum;
|
fattr.cf_uniqueid = inum;
|
||||||
|
@ -750,12 +742,12 @@ static int cifs_filldir(char *pfindEntry, struct file *file, filldir_t filldir,
|
||||||
fattr.cf_flags |= CIFS_FATTR_NEED_REVAL;
|
fattr.cf_flags |= CIFS_FATTR_NEED_REVAL;
|
||||||
|
|
||||||
ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid);
|
ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid);
|
||||||
tmp_dentry = cifs_readdir_lookup(file->f_dentry, &qstring, &fattr);
|
dentry = cifs_readdir_lookup(file->f_dentry, &name, &fattr);
|
||||||
|
|
||||||
rc = filldir(direntry, qstring.name, qstring.len, file->f_pos,
|
rc = filldir(dirent, name.name, name.len, file->f_pos, ino,
|
||||||
ino, fattr.cf_dtype);
|
fattr.cf_dtype);
|
||||||
|
|
||||||
dput(tmp_dentry);
|
dput(dentry);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue