Lines Matching +full:de +full:- +full:be

1 // SPDX-License-Identifier: LGPL-2.1
27 * To be safe - for UCS to UTF-8 with strings loaded with the rare long
28 * characters alloc more to account for such multibyte target UTF-8
39 cf = file->private_data; in dump_cifs_file_struct()
44 if (cf->invalidHandle) in dump_cifs_file_struct()
46 if (cf->srch_inf.endOfSearch) in dump_cifs_file_struct()
48 if (cf->srch_inf.emptyDir) in dump_cifs_file_struct()
71 struct super_block *sb = parent->d_sb; in cifs_prime_dcache()
75 cifs_dbg(FYI, "%s: for %s\n", __func__, name->name); in cifs_prime_dcache()
80 * If we know that the inode will need to be revalidated in cifs_prime_dcache()
85 if (fattr->cf_flags & CIFS_FATTR_NEED_REVAL) in cifs_prime_dcache()
104 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) in cifs_prime_dcache()
105 fattr->cf_uniqueid = CIFS_I(inode)->uniqueid; in cifs_prime_dcache()
109 if (CIFS_I(inode)->uniqueid == fattr->cf_uniqueid && in cifs_prime_dcache()
121 inode = ERR_PTR(-ENOMEM); in cifs_prime_dcache()
132 if (!(fattr->cf_cifsattrs & ATTR_REPARSE)) in reparse_file_needs_reval()
135 * The DFS tags should be only intepreted by server side as per in reparse_file_needs_reval()
136 * MS-FSCC 2.1.2.1, but let's include them anyway. in reparse_file_needs_reval()
138 * Besides, if cf_cifstag is unset (0), then we still need it to be in reparse_file_needs_reval()
141 switch (fattr->cf_cifstag) { in reparse_file_needs_reval()
155 fattr->cf_uid = cifs_sb->ctx->linux_uid; in cifs_fill_common_info()
156 fattr->cf_gid = cifs_sb->ctx->linux_gid; in cifs_fill_common_info()
166 if (fattr->cf_cifsattrs & ATTR_DIRECTORY) { in cifs_fill_common_info()
167 fattr->cf_mode = S_IFDIR | cifs_sb->ctx->dir_mode; in cifs_fill_common_info()
168 fattr->cf_dtype = DT_DIR; in cifs_fill_common_info()
169 } else if (fattr->cf_cifstag == IO_REPARSE_TAG_LX_SYMLINK) { in cifs_fill_common_info()
170 fattr->cf_mode |= S_IFLNK | cifs_sb->ctx->file_mode; in cifs_fill_common_info()
171 fattr->cf_dtype = DT_LNK; in cifs_fill_common_info()
172 } else if (fattr->cf_cifstag == IO_REPARSE_TAG_LX_FIFO) { in cifs_fill_common_info()
173 fattr->cf_mode |= S_IFIFO | cifs_sb->ctx->file_mode; in cifs_fill_common_info()
174 fattr->cf_dtype = DT_FIFO; in cifs_fill_common_info()
175 } else if (fattr->cf_cifstag == IO_REPARSE_TAG_AF_UNIX) { in cifs_fill_common_info()
176 fattr->cf_mode |= S_IFSOCK | cifs_sb->ctx->file_mode; in cifs_fill_common_info()
177 fattr->cf_dtype = DT_SOCK; in cifs_fill_common_info()
178 } else if (fattr->cf_cifstag == IO_REPARSE_TAG_LX_CHR) { in cifs_fill_common_info()
179 fattr->cf_mode |= S_IFCHR | cifs_sb->ctx->file_mode; in cifs_fill_common_info()
180 fattr->cf_dtype = DT_CHR; in cifs_fill_common_info()
181 } else if (fattr->cf_cifstag == IO_REPARSE_TAG_LX_BLK) { in cifs_fill_common_info()
182 fattr->cf_mode |= S_IFBLK | cifs_sb->ctx->file_mode; in cifs_fill_common_info()
183 fattr->cf_dtype = DT_BLK; in cifs_fill_common_info()
185 fattr->cf_mode = S_IFREG | cifs_sb->ctx->file_mode; in cifs_fill_common_info()
186 fattr->cf_dtype = DT_REG; in cifs_fill_common_info()
195 fattr->cf_flags |= CIFS_FATTR_NEED_REVAL; in cifs_fill_common_info()
197 /* non-unix readdir doesn't provide nlink */ in cifs_fill_common_info()
198 fattr->cf_flags |= CIFS_FATTR_UNKNOWN_NLINK; in cifs_fill_common_info()
200 if (fattr->cf_cifsattrs & ATTR_READONLY) in cifs_fill_common_info()
201 fattr->cf_mode &= ~S_IWUGO; in cifs_fill_common_info()
205 * mark it for revalidation so that "ls -l" will look right. It might in cifs_fill_common_info()
206 * be super-slow, but if we don't do this then the ownership of files in cifs_fill_common_info()
210 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) || in cifs_fill_common_info()
211 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID)) in cifs_fill_common_info()
212 fattr->cf_flags |= CIFS_FATTR_NEED_REVAL; in cifs_fill_common_info()
214 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL && in cifs_fill_common_info()
215 fattr->cf_cifsattrs & ATTR_SYSTEM) { in cifs_fill_common_info()
216 if (fattr->cf_eof == 0) { in cifs_fill_common_info()
217 fattr->cf_mode &= ~S_IFMT; in cifs_fill_common_info()
218 fattr->cf_mode |= S_IFIFO; in cifs_fill_common_info()
219 fattr->cf_dtype = DT_FIFO; in cifs_fill_common_info()
222 * trying to get the type and mode via SFU can be slow, in cifs_fill_common_info()
226 fattr->cf_flags |= CIFS_FATTR_NEED_REVAL; in cifs_fill_common_info()
241 fattr->cf_uniqueid = le64_to_cpu(info->Inode); in cifs_posix_to_fattr()
242 fattr->cf_bytes = le64_to_cpu(info->AllocationSize); in cifs_posix_to_fattr()
243 fattr->cf_eof = le64_to_cpu(info->EndOfFile); in cifs_posix_to_fattr()
245 fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime); in cifs_posix_to_fattr()
246 fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime); in cifs_posix_to_fattr()
247 fattr->cf_ctime = cifs_NTtimeToUnix(info->CreationTime); in cifs_posix_to_fattr()
249 fattr->cf_nlink = le32_to_cpu(info->HardLinks); in cifs_posix_to_fattr()
250 fattr->cf_cifsattrs = le32_to_cpu(info->DosAttributes); in cifs_posix_to_fattr()
257 fattr->cf_mode = le32_to_cpu(info->Mode) & ~S_IFMT; in cifs_posix_to_fattr()
260 le32_to_cpu(info->DeviceId), in cifs_posix_to_fattr()
261 le32_to_cpu(info->ReparseTag), in cifs_posix_to_fattr()
262 le32_to_cpu(info->Mode)); in cifs_posix_to_fattr()
264 if (fattr->cf_cifsattrs & ATTR_DIRECTORY) { in cifs_posix_to_fattr()
265 fattr->cf_mode |= S_IFDIR; in cifs_posix_to_fattr()
266 fattr->cf_dtype = DT_DIR; in cifs_posix_to_fattr()
271 * attribute and will be marked as needing revaluation in cifs_posix_to_fattr()
273 fattr->cf_mode |= S_IFREG; in cifs_posix_to_fattr()
274 fattr->cf_dtype = DT_REG; in cifs_posix_to_fattr()
278 fattr->cf_flags |= CIFS_FATTR_NEED_REVAL; in cifs_posix_to_fattr()
289 fattr->cf_cifsattrs = le32_to_cpu(fi->ExtFileAttributes); in __dir_info_to_fattr()
290 fattr->cf_eof = le64_to_cpu(fi->EndOfFile); in __dir_info_to_fattr()
291 fattr->cf_bytes = le64_to_cpu(fi->AllocationSize); in __dir_info_to_fattr()
292 fattr->cf_createtime = le64_to_cpu(fi->CreationTime); in __dir_info_to_fattr()
293 fattr->cf_atime = cifs_NTtimeToUnix(fi->LastAccessTime); in __dir_info_to_fattr()
294 fattr->cf_ctime = cifs_NTtimeToUnix(fi->ChangeTime); in __dir_info_to_fattr()
295 fattr->cf_mtime = cifs_NTtimeToUnix(fi->LastWriteTime); in __dir_info_to_fattr()
312 /* See MS-FSCC 2.4.19 FileIdFullDirectoryInformation */ in cifs_fulldir_info_to_fattr()
313 if (fattr->cf_cifsattrs & ATTR_REPARSE) in cifs_fulldir_info_to_fattr()
314 fattr->cf_cifstag = le32_to_cpu(info->EaSize); in cifs_fulldir_info_to_fattr()
322 int offset = cifs_sb_master_tcon(cifs_sb)->ses->server->timeAdj; in cifs_std_info_to_fattr()
325 fattr->cf_atime = cnvrtDosUnixTm(info->LastAccessDate, in cifs_std_info_to_fattr()
326 info->LastAccessTime, offset); in cifs_std_info_to_fattr()
327 fattr->cf_ctime = cnvrtDosUnixTm(info->LastWriteDate, in cifs_std_info_to_fattr()
328 info->LastWriteTime, offset); in cifs_std_info_to_fattr()
329 fattr->cf_mtime = cnvrtDosUnixTm(info->LastWriteDate, in cifs_std_info_to_fattr()
330 info->LastWriteTime, offset); in cifs_std_info_to_fattr()
332 fattr->cf_cifsattrs = le16_to_cpu(info->Attributes); in cifs_std_info_to_fattr()
333 fattr->cf_bytes = le32_to_cpu(info->AllocationSize); in cifs_std_info_to_fattr()
334 fattr->cf_eof = le32_to_cpu(info->DataSize); in cifs_std_info_to_fattr()
355 cifs_sb->local_nls,
361 maxpath -1,
363 cifs_sb->local_nls);
383 if (file->private_data == NULL) { in _initiate_cifs_search()
390 rc = -ENOMEM; in _initiate_cifs_search()
393 spin_lock_init(&cifsFile->file_info_lock); in _initiate_cifs_search()
394 file->private_data = cifsFile; in _initiate_cifs_search()
395 cifsFile->tlink = cifs_get_tlink(tlink); in _initiate_cifs_search()
398 cifsFile = file->private_data; in _initiate_cifs_search()
399 tcon = tlink_tcon(cifsFile->tlink); in _initiate_cifs_search()
402 server = tcon->ses->server; in _initiate_cifs_search()
404 if (!server->ops->query_dir_first) { in _initiate_cifs_search()
405 rc = -ENOSYS; in _initiate_cifs_search()
409 cifsFile->invalidHandle = true; in _initiate_cifs_search()
410 cifsFile->srch_inf.endOfSearch = false; in _initiate_cifs_search()
412 cifs_dbg(FYI, "Full path: %s start at: %lld\n", full_path, file->f_pos); in _initiate_cifs_search()
417 /* if (cap_unix(tcon->ses) { */ in _initiate_cifs_search()
418 if (tcon->unix_ext) in _initiate_cifs_search()
419 cifsFile->srch_inf.info_level = SMB_FIND_FILE_UNIX; in _initiate_cifs_search()
420 else if (tcon->posix_extensions) in _initiate_cifs_search()
421 cifsFile->srch_inf.info_level = SMB_FIND_FILE_POSIX_INFO; in _initiate_cifs_search()
422 else if ((tcon->ses->capabilities & in _initiate_cifs_search()
423 tcon->ses->server->vals->cap_nt_find) == 0) { in _initiate_cifs_search()
424 cifsFile->srch_inf.info_level = SMB_FIND_FILE_INFO_STANDARD; in _initiate_cifs_search()
425 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { in _initiate_cifs_search()
426 cifsFile->srch_inf.info_level = SMB_FIND_FILE_ID_FULL_DIR_INFO; in _initiate_cifs_search()
427 } else /* not srvinos - BB fixme add check for backlevel? */ { in _initiate_cifs_search()
428 cifsFile->srch_inf.info_level = SMB_FIND_FILE_DIRECTORY_INFO; in _initiate_cifs_search()
435 rc = server->ops->query_dir_first(xid, tcon, full_path, cifs_sb, in _initiate_cifs_search()
436 &cifsFile->fid, search_flags, in _initiate_cifs_search()
437 &cifsFile->srch_inf); in _initiate_cifs_search()
440 cifsFile->invalidHandle = false; in _initiate_cifs_search()
444 else if ((rc == -EOPNOTSUPP) && in _initiate_cifs_search()
445 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { in _initiate_cifs_search()
446 cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM; in _initiate_cifs_search()
466 if (rc != -EDEADLK) in initiate_cifs_search()
499 pfData->FileNameLength; in nxt_dir_entry()
501 u32 next_offset = le32_to_cpu(pDirInfo->NextEntryOffset); in nxt_dir_entry()
534 static void cifs_fill_dirent_posix(struct cifs_dirent *de, in cifs_fill_dirent_posix() argument
545 de->name = parsed.name; in cifs_fill_dirent_posix()
546 de->namelen = parsed.name_len; in cifs_fill_dirent_posix()
547 de->resume_key = info->Ignored; in cifs_fill_dirent_posix()
548 de->ino = le64_to_cpu(info->Inode); in cifs_fill_dirent_posix()
551 static void cifs_fill_dirent_unix(struct cifs_dirent *de, in cifs_fill_dirent_unix() argument
554 de->name = &info->FileName[0]; in cifs_fill_dirent_unix()
556 de->namelen = cifs_unicode_bytelen(de->name); in cifs_fill_dirent_unix()
558 de->namelen = strnlen(de->name, PATH_MAX); in cifs_fill_dirent_unix()
559 de->resume_key = info->ResumeKey; in cifs_fill_dirent_unix()
560 de->ino = le64_to_cpu(info->basic.UniqueId); in cifs_fill_dirent_unix()
563 static void cifs_fill_dirent_dir(struct cifs_dirent *de, in cifs_fill_dirent_dir() argument
566 de->name = &info->FileName[0]; in cifs_fill_dirent_dir()
567 de->namelen = le32_to_cpu(info->FileNameLength); in cifs_fill_dirent_dir()
568 de->resume_key = info->FileIndex; in cifs_fill_dirent_dir()
571 static void cifs_fill_dirent_full(struct cifs_dirent *de, in cifs_fill_dirent_full() argument
574 de->name = &info->FileName[0]; in cifs_fill_dirent_full()
575 de->namelen = le32_to_cpu(info->FileNameLength); in cifs_fill_dirent_full()
576 de->resume_key = info->FileIndex; in cifs_fill_dirent_full()
579 static void cifs_fill_dirent_search(struct cifs_dirent *de, in cifs_fill_dirent_search() argument
582 de->name = &info->FileName[0]; in cifs_fill_dirent_search()
583 de->namelen = le32_to_cpu(info->FileNameLength); in cifs_fill_dirent_search()
584 de->resume_key = info->FileIndex; in cifs_fill_dirent_search()
585 de->ino = le64_to_cpu(info->UniqueId); in cifs_fill_dirent_search()
588 static void cifs_fill_dirent_both(struct cifs_dirent *de, in cifs_fill_dirent_both() argument
591 de->name = &info->FileName[0]; in cifs_fill_dirent_both()
592 de->namelen = le32_to_cpu(info->FileNameLength); in cifs_fill_dirent_both()
593 de->resume_key = info->FileIndex; in cifs_fill_dirent_both()
596 static void cifs_fill_dirent_std(struct cifs_dirent *de, in cifs_fill_dirent_std() argument
599 de->name = &info->FileName[0]; in cifs_fill_dirent_std()
601 de->namelen = info->FileNameLength; in cifs_fill_dirent_std()
602 de->resume_key = info->ResumeKey; in cifs_fill_dirent_std()
605 static int cifs_fill_dirent(struct cifs_dirent *de, const void *info, in cifs_fill_dirent() argument
608 memset(de, 0, sizeof(*de)); in cifs_fill_dirent()
612 cifs_fill_dirent_posix(de, info); in cifs_fill_dirent()
615 cifs_fill_dirent_unix(de, info, is_unicode); in cifs_fill_dirent()
618 cifs_fill_dirent_dir(de, info); in cifs_fill_dirent()
621 cifs_fill_dirent_full(de, info); in cifs_fill_dirent()
624 cifs_fill_dirent_search(de, info); in cifs_fill_dirent()
627 cifs_fill_dirent_both(de, info); in cifs_fill_dirent()
630 cifs_fill_dirent_std(de, info); in cifs_fill_dirent()
634 return -EINVAL; in cifs_fill_dirent()
643 static int cifs_entry_is_dot(struct cifs_dirent *de, bool is_unicode) in cifs_entry_is_dot() argument
647 if (!de->name) in cifs_entry_is_dot()
651 __le16 *ufilename = (__le16 *)de->name; in cifs_entry_is_dot()
652 if (de->namelen == 2) { in cifs_entry_is_dot()
656 } else if (de->namelen == 4) { in cifs_entry_is_dot()
663 if (de->namelen == 1) { in cifs_entry_is_dot()
664 if (de->name[0] == '.') in cifs_entry_is_dot()
666 } else if (de->namelen == 2) { in cifs_entry_is_dot()
667 if (de->name[0] == '.' && de->name[1] == '.') in cifs_entry_is_dot()
682 if (cifsInfo->time == 0) in is_dir_changed()
692 struct cifs_dirent de; in cifs_save_resume_key() local
695 rc = cifs_fill_dirent(&de, current_entry, file_info->srch_inf.info_level, in cifs_save_resume_key()
696 file_info->srch_inf.unicode); in cifs_save_resume_key()
698 file_info->srch_inf.presume_name = de.name; in cifs_save_resume_key()
699 file_info->srch_inf.resume_name_len = de.namelen; in cifs_save_resume_key()
700 file_info->srch_inf.resume_key = de.resume_key; in cifs_save_resume_key()
722 struct cifsFileInfo *cfile = file->private_data; in find_cifs_entry()
724 struct TCP_Server_Info *server = tcon->ses->server; in find_cifs_entry()
727 if (!server->ops->query_dir_first || !server->ops->query_dir_next) in find_cifs_entry()
728 return -ENOSYS; in find_cifs_entry()
731 return -ENOENT; in find_cifs_entry()
734 first_entry_in_buffer = cfile->srch_inf.index_of_last_entry - in find_cifs_entry()
735 cfile->srch_inf.entries_in_buffer; in find_cifs_entry()
740 * will be in this buffer, although some servers do not return in find_cifs_entry()
746 if (((index_to_find < cfile->srch_inf.index_of_last_entry) && in find_cifs_entry()
749 cifs_dbg(FYI, "search backing up - close and restart search\n"); in find_cifs_entry()
750 spin_lock(&cfile->file_info_lock); in find_cifs_entry()
751 if (server->ops->dir_needs_close(cfile)) { in find_cifs_entry()
752 cfile->invalidHandle = true; in find_cifs_entry()
753 spin_unlock(&cfile->file_info_lock); in find_cifs_entry()
754 if (server->ops->close_dir) in find_cifs_entry()
755 server->ops->close_dir(xid, tcon, &cfile->fid); in find_cifs_entry()
757 spin_unlock(&cfile->file_info_lock); in find_cifs_entry()
758 if (cfile->srch_inf.ntwrk_buf_start) { in find_cifs_entry()
760 if (cfile->srch_inf.smallBuf) in find_cifs_entry()
761 cifs_small_buf_release(cfile->srch_inf. in find_cifs_entry()
764 cifs_buf_release(cfile->srch_inf. in find_cifs_entry()
766 cfile->srch_inf.ntwrk_buf_start = NULL; in find_cifs_entry()
775 if (cfile->srch_inf.last_entry) in find_cifs_entry()
776 cifs_save_resume_key(cfile->srch_inf.last_entry, cfile); in find_cifs_entry()
783 while ((index_to_find >= cfile->srch_inf.index_of_last_entry) && in find_cifs_entry()
784 (rc == 0) && !cfile->srch_inf.endOfSearch) { in find_cifs_entry()
786 rc = server->ops->query_dir_next(xid, tcon, &cfile->fid, in find_cifs_entry()
788 &cfile->srch_inf); in find_cifs_entry()
790 if (cfile->srch_inf.last_entry) in find_cifs_entry()
791 cifs_save_resume_key(cfile->srch_inf.last_entry, cfile); in find_cifs_entry()
793 return -ENOENT; in find_cifs_entry()
795 if (index_to_find < cfile->srch_inf.index_of_last_entry) { in find_cifs_entry()
802 if (cfile->srch_inf.ntwrk_buf_start == NULL) { in find_cifs_entry()
804 return -EIO; in find_cifs_entry()
807 end_of_smb = cfile->srch_inf.ntwrk_buf_start + in find_cifs_entry()
808 server->ops->calc_smb_size( in find_cifs_entry()
809 cfile->srch_inf.ntwrk_buf_start); in find_cifs_entry()
811 cur_ent = cfile->srch_inf.srch_entries_start; in find_cifs_entry()
812 first_entry_in_buffer = cfile->srch_inf.index_of_last_entry in find_cifs_entry()
813 - cfile->srch_inf.entries_in_buffer; in find_cifs_entry()
814 pos_in_buf = index_to_find - first_entry_in_buffer; in find_cifs_entry()
815 cifs_dbg(FYI, "found entry - pos_in_buf %d\n", pos_in_buf); in find_cifs_entry()
820 cfile->srch_inf.info_level); in find_cifs_entry()
823 /* BB fixme - check if we should flag this error */ in find_cifs_entry()
830 cifs_dbg(FYI, "index not in buffer - could not findnext into it\n"); in find_cifs_entry()
834 if (pos_in_buf >= cfile->srch_inf.entries_in_buffer) { in find_cifs_entry()
838 *num_to_ret = cfile->srch_inf.entries_in_buffer - pos_in_buf; in find_cifs_entry()
849 list_for_each_entry(dirent, &cde->entries, entry) { in emit_cached_dirents()
854 if (ctx->pos > dirent->pos) in emit_cached_dirents()
857 * We recorded the current ->pos value for the dirent in emit_cached_dirents()
859 * However, this sequence of ->pos values may have holes in emit_cached_dirents()
860 * in it, for example dot-dirs returned from the server in emit_cached_dirents()
862 * Handle this bu forcing ctx->pos to be the same as the in emit_cached_dirents()
863 * ->pos of the current dirent we emit from the cache. in emit_cached_dirents()
865 * we now emit them with the same ->pos value as in the in emit_cached_dirents()
868 ctx->pos = dirent->pos; in emit_cached_dirents()
869 rc = dir_emit(ctx, dirent->name, dirent->namelen, in emit_cached_dirents()
870 dirent->fattr.cf_uniqueid, in emit_cached_dirents()
871 dirent->fattr.cf_dtype); in emit_cached_dirents()
874 ctx->pos++; in emit_cached_dirents()
882 if (cde->ctx != ctx) in update_cached_dirents_count()
884 if (cde->is_valid || cde->is_failed) in update_cached_dirents_count()
887 cde->pos++; in update_cached_dirents_count()
893 if (cde->ctx != ctx) in finished_cached_dirents_count()
895 if (cde->is_valid || cde->is_failed) in finished_cached_dirents_count()
897 if (ctx->pos != cde->pos) in finished_cached_dirents_count()
900 cde->is_valid = 1; in finished_cached_dirents_count()
908 struct cached_dirent *de; in add_cached_dirent() local
910 if (cde->ctx != ctx) in add_cached_dirent()
912 if (cde->is_valid || cde->is_failed) in add_cached_dirent()
914 if (ctx->pos != cde->pos) { in add_cached_dirent()
915 cde->is_failed = 1; in add_cached_dirent()
918 de = kzalloc(sizeof(*de), GFP_ATOMIC); in add_cached_dirent()
919 if (de == NULL) { in add_cached_dirent()
920 cde->is_failed = 1; in add_cached_dirent()
923 de->namelen = namelen; in add_cached_dirent()
924 de->name = kstrndup(name, namelen, GFP_ATOMIC); in add_cached_dirent()
925 if (de->name == NULL) { in add_cached_dirent()
926 kfree(de); in add_cached_dirent()
927 cde->is_failed = 1; in add_cached_dirent()
930 de->pos = ctx->pos; in add_cached_dirent()
932 memcpy(&de->fattr, fattr, sizeof(struct cifs_fattr)); in add_cached_dirent()
934 list_add_tail(&de->entry, &cde->entries); in add_cached_dirent()
943 ino_t ino = cifs_uniqueid_to_ino_t(fattr->cf_uniqueid); in cifs_dir_emit()
945 rc = dir_emit(ctx, name, namelen, ino, fattr->cf_dtype); in cifs_dir_emit()
950 mutex_lock(&cfid->dirents.de_mutex); in cifs_dir_emit()
951 add_cached_dirent(&cfid->dirents, ctx, name, namelen, in cifs_dir_emit()
953 mutex_unlock(&cfid->dirents.de_mutex); in cifs_dir_emit()
964 struct cifsFileInfo *file_info = file->private_data; in cifs_filldir()
965 struct super_block *sb = file_inode(file)->i_sb; in cifs_filldir()
967 struct cifs_dirent de = { NULL, }; in cifs_filldir() local
972 rc = cifs_fill_dirent(&de, find_entry, file_info->srch_inf.info_level, in cifs_filldir()
973 file_info->srch_inf.unicode); in cifs_filldir()
977 if (de.namelen > max_len) { in cifs_filldir()
979 de.namelen); in cifs_filldir()
980 return -EINVAL; in cifs_filldir()
984 if (cifs_entry_is_dot(&de, file_info->srch_inf.unicode)) in cifs_filldir()
987 if (file_info->srch_inf.unicode) { in cifs_filldir()
988 struct nls_table *nlt = cifs_sb->local_nls; in cifs_filldir()
994 cifs_from_utf16((char *)name.name, (__le16 *)de.name, in cifs_filldir()
996 min_t(size_t, de.namelen, in cifs_filldir()
998 name.len -= nls_nullsize(nlt); in cifs_filldir()
1000 name.name = de.name; in cifs_filldir()
1001 name.len = de.namelen; in cifs_filldir()
1004 switch (file_info->srch_inf.info_level) { in cifs_filldir()
1012 &((FILE_UNIX_INFO *)find_entry)->basic, in cifs_filldir()
1034 if (de.ino && (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { in cifs_filldir()
1035 fattr.cf_uniqueid = de.ino; in cifs_filldir()
1041 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) && in cifs_filldir()
1044 * trying to get the type and mode can be slow, in cifs_filldir()
1083 if (file->private_data == NULL) { in cifs_readdir()
1089 cifsFile = file->private_data; in cifs_readdir()
1090 tcon = tlink_tcon(cifsFile->tlink); in cifs_readdir()
1098 mutex_lock(&cfid->dirents.de_mutex); in cifs_readdir()
1104 if (ctx->pos == 0 && cfid->dirents.ctx == NULL) { in cifs_readdir()
1105 cfid->dirents.ctx = ctx; in cifs_readdir()
1106 cfid->dirents.pos = 2; in cifs_readdir()
1112 if (cfid->dirents.is_valid) { in cifs_readdir()
1114 mutex_unlock(&cfid->dirents.de_mutex); in cifs_readdir()
1117 emit_cached_dirents(&cfid->dirents, ctx); in cifs_readdir()
1118 mutex_unlock(&cfid->dirents.de_mutex); in cifs_readdir()
1121 mutex_unlock(&cfid->dirents.de_mutex); in cifs_readdir()
1124 * find_cifs_entry in case there will be reconnects during in cifs_readdir()
1133 * '..'. Otherwise we won't be able to notify VFS in case of failure. in cifs_readdir()
1135 if (file->private_data == NULL) { in cifs_readdir()
1149 cifsFile = file->private_data; in cifs_readdir()
1150 if (cifsFile->srch_inf.endOfSearch) { in cifs_readdir()
1151 if (cifsFile->srch_inf.emptyDir) { in cifs_readdir()
1157 cifsFile->invalidHandle = true; in cifs_readdir()
1158 tcon->ses->server->close(xid, tcon, &cifsFile->fid); in cifs_readdir()
1161 tcon = tlink_tcon(cifsFile->tlink); in cifs_readdir()
1162 rc = find_cifs_entry(xid, tcon, ctx->pos, file, full_path, in cifs_readdir()
1169 cifs_dbg(FYI, "entry %lld found\n", ctx->pos); in cifs_readdir()
1172 mutex_lock(&cfid->dirents.de_mutex); in cifs_readdir()
1173 finished_cached_dirents_count(&cfid->dirents, ctx); in cifs_readdir()
1174 mutex_unlock(&cfid->dirents.de_mutex); in cifs_readdir()
1180 num_to_fill, cifsFile->srch_inf.ntwrk_buf_start); in cifs_readdir()
1181 max_len = tcon->ses->server->ops->calc_smb_size( in cifs_readdir()
1182 cifsFile->srch_inf.ntwrk_buf_start); in cifs_readdir()
1183 end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len; in cifs_readdir()
1187 rc = -ENOMEM; in cifs_readdir()
1211 ctx->pos++; in cifs_readdir()
1213 mutex_lock(&cfid->dirents.de_mutex); in cifs_readdir()
1214 update_cached_dirents_count(&cfid->dirents, ctx); in cifs_readdir()
1215 mutex_unlock(&cfid->dirents.de_mutex); in cifs_readdir()
1218 if (ctx->pos == in cifs_readdir()
1219 cifsFile->srch_inf.index_of_last_entry) { in cifs_readdir()
1221 ctx->pos, tmp_buf); in cifs_readdir()
1227 cifsFile->srch_inf.info_level); in cifs_readdir()